Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

***
grep -c ^processor /proc/cpuinfo
***
will count the number of lines starting with "processor" in /proc/cpuinfo

For systems with hyper-threading, you can use
***
grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}'
***
which should return (for example) 8 (whereas the command above would return 16)
4 years ago
Simple solution (if you are not interested in coming back to the process, just want it to keep running):
***
nohup node server.js &
***
There's also the jobs command to see an indexed list of those backgrounded processes. And you can kill a backgrounded process by running kill %1 or kill %2 with the number being the index of the process.

Powerful solution (allows you to reconnect to the process if it is interactive):
***
screen
***
You can then detach by pressing Ctrl+a+d and then attach back by running screen -r

Also consider the newer alternative to screen, tmux.
4 years ago
Try:

1.Use NOPASSWD line for all commands, I mean:
***
jenkins ALL=(ALL) NOPASSWD: ALL
***
2.Put the line after all other lines in the sudoers file.

That worked for me (Ubuntu 14.04).
4 years ago
Try uname -m. Which is short of uname --machine and it outputs:
***
x86_64 ==> 64-bit kernel
i686 ==> 32-bit kernel
***
4 years ago
This piece of code helps.
***
Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);
***
Here a version where the image gets downloaded.
***
String name = c.getString(str_url);
URL url_value = new URL(name);
ImageView profile = (ImageView)v.findViewById(R.id.vdo_icon);
if (profile != null) {
Bitmap mIcon1 =
BitmapFactory.decodeStream(url_value.openConnection().getInputStream());
profile.setImageBitmap(mIcon1);
}
***
4 years ago
There are working combinations of OS, JDK and Eclipse bitness. In my case, I was using a 64-bit JDK with a 32-bit Eclipse on a 64-bit OS. After downgrading the JDK to 32-bit, Eclipse started working.

Use one of the following combinations.

32-bit OS, 32-bit JDK, 32-bit Eclipse (32-bit only)
64-bit OS, 32-bit JDK, 32-bit Eclipse
64-bit OS, 64-bit JDK, 64-bit Eclipse (64-bit only)
4 years ago
Add this android:screenOrientation="portrait" in your manifest file where you declare your activity like this
***
....
android:screenOrientation="portrait" />
***
If you want to do using java code try

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before you call setContentView method for your activity in onCreate().

Hope this help and easily understandable for all...
4 years ago
1. Connect device via USB and make sure debugging is working, then run:
***
adb tcpip 5555
adb connect :5555
***
2. Disconnect USB and proceed with wireless debugging.
3. When you're done and want to switch back to USB debugging, run:
***
adb -s :5555
***
To find the IP address of your device, go to Settings > Wi-Fi > Advanced > IP Address on your device or run adb shell netcfg.

No root required. Only one device can be debugged at a time.
The adb command is located in the platform-tools folder of the Android SDK.
4 years ago
Java code:
***
// Converts 14 dip into its equivalent px
float dip = 14f;
Resources r = getResources();
float px = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
dip,
r.getDisplayMetrics()
);
***
Kotlin code:
***
val dip = 14f
val r: Resources = resources
val px = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
dip,
r.displayMetrics
)
***
4 years ago
One option could be letting your custom class implement the Serializable interface and then you can pass object instances in the intent extra using the putExtra(Serializable..) variant of the Intent#putExtra() method.

Pseudocode:
***
//To pass:
intent.putExtra("MyClass", obj);

// To retrieve object in second Activity
getIntent().getSerializableExtra("MyClass");
***
Note: Make sure each nested class of your main custom class has implemented Serializable interface to avoid any serialization exceptions. For example:
***
class MainClass implements Serializable {

public MainClass() {}

public static class ChildClass implements Serializable {

public ChildClass() {}
}
}
***
4 years ago
Kotlin
***
Handler(Looper.getMainLooper()).postDelayed({
//Do something after 100ms
}, 100)
***
Java
***
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
}
}, 100);
***
4 years ago
First, get the intent which has started your activity using the getIntent() method:
***
Intent intent = getIntent();
***
If your extra data is represented as strings, then you can use intent.getStringExtra(String name) method. In your case:
***
String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");
***
4 years ago