[Solved] Very new in R, subsetting columns

#columns 4 to the last one myselec<-mydata[ 1, 4 : ncol(mydata)] #put the columns you want to keep in a vector columnsIWantToKeep <- c(4, 5, 6, 10, 12) #subset your DFusing this vector myselec<-mydata[1, columnsIWantToKeep] The same applies to rows… myselec<-mydata[ 4:nrow(mydata),] #get from row 4 to the end myselec<-mydata[ c(1,3,5,7),] #get rows 1,3,5,7 You … Read more

[Solved] What is the output ? How?

Let’s try to visualize what happens by adding some more prints: class B{ B(){ System.out.println(“binit”); f(); } public void f(){ System.out.println(“B ctor”); } } class A extends B{ A(){ System.out.println(“ainit”); f(); } @Override public void f(){ System.out.println(“A ctor”); } public static void main(String[] args) { System.out.println(1); A a = new A(); System.out.println(2); a.f(); System.out.println(3); B … Read more

[Solved] Close activity after x minutes of inactive

Here is a code of Activity that will automatically close itself after five seconds. public class TestActivity extends ActionBarActivity { private static final int DELAY = 5000; public boolean inactive; Handler mHideHandler = new Handler(); Runnable mHideRunnable = new Runnable() { @Override public void run() { if(inactive) { finish(); } else { mHideHandler.postDelayed(mHideRunnable, DELAY); } … Read more

[Solved] How to create a shadow border in CSS3? [closed]

Here is an example: <div id=”box”>Content</div> #box { position: relative; width: 60%; background: #ddd; -moz-border-radius: 4px; border-radius: 4px; padding: 2em 1.5em; color: rgba(0,0,0, .8); text-shadow: 0 1px 0 #fff; line-height: 1.5; margin: 60px auto; } #box:before, #box:after { z-index: -1; position: absolute; content: “”; bottom: 15px; left: 10px; width: 50%; top: 80%; max-width:300px; background: rgba(0, … Read more

[Solved] Calling #[] on a ruby method [closed]

If I understand the question, you want a method that takes any number of arguments, and returns an object that will create a range of numbers when the [] method is used. This method takes any number of arguments (using the * splat operator), and then returns a proc, which [] can be used on. … Read more

[Solved] How to make a iOS App which only runs for e.g. 1 Day? [closed]

USE ONLY IF YOU WANT TO USE IT AS INHOUSE APP. Write following code in – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method if (![[NSUserDefaults standardUserDefaults] objectForKey:IS_APP_RUNNING_FIRST_TIME]) { [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:IS_APP_RUNNING_FIRST_TIME]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { NSDate * firstDate = [[NSUserDefaults standardUserDefaults] objectForKey:IS_APP_RUNNING_FIRST_TIME]; NSDate * todayDate = [NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] … Read more

[Solved] How to store the array of string in shared preferences? [closed]

first activity. public class MainActivity extends ActionBarActivity { private Button button; private SharedPreferences preferences; private String[] name = {“aa”, “bb”, “cc”}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button=(Button)findViewById(R.id.button1); preferences=getSharedPreferences(“testarray”, MODE_PRIVATE); for(int i=0;i<3;i++) { SharedPreferences.Editor editor=preferences.edit(); editor.putString(“str”+i, name[i]); editor.commit(); } button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this,Secondact.class)); } }); } … Read more

[Solved] how to implement request GET in Python [closed]

If you don’t want to install an extra library, you can use pythons urllib2 library that is just as easy for something like connecting to a url. import urllib2 print urllib2.urlopen(“https://www.bitstamp.net/api/transactions/”).read() For parsing that, use pythons json library. solved how to implement request GET in Python [closed]

[Solved] extract information from xml using regular expression

Why couldn’t regex: <post\\s*author=\”([^\”]+)\”[^>]+>[^</post>]*</post> extract the author in following text. Because [^</post>]* represents a character class and will match everything but the characters <, /, p, o, s, t, and > 0 or more times. That doesn’t happen in your text. As for how to fix it, consider using the following regex <post\s*author=\”([^\”]+?)\”[^>]+>(.|\s)*?<\/post> // obviously, … Read more