Skip to content

Instantly share code, notes, and snippets.

View dmpatel151282's full-sized avatar

Dharmesh Patel dmpatel151282

View GitHub Profile
Mount :-
Install qemu-utils and enable ndb module
sudo apt-get install qemu-utils
sudo modprobe nbd
Connect the image to the first nbd device
sudo qemu-nbd -c /dev/nbd0 xyz.qcow2
Convert between PEM and P12
PEM
It is an ASCII format and can be opened with a text editor. It is used by most SSL-based tools. Key and certificate are two separate files.
P12
Acutally: Pkcs12 is used by most browsers. Key and certificate are in one file.
PEM to P12
The key and the certificate are require.
libspice video detection (mjpeg encode it)
++++++++++++++++++++++++++++++++++++++++++
- spice中视频处理相关: http://blog.csdn.net/mlfcjob/article/details/26218755
- spice关于display_channel导读: http://blog.chinaunix.net/uid-21706718-id-4863668.html
- main
- red_worker_main()
java -jar signapk.jar -w platform.x509.pem platform.pk8 myupdate.zip myupdate-signed.zip
Note:-
1. -w flag to sign the whole zip file.
2. The sequence of the two key files: pem file goes first, then the pk8 file.
From PNG file to RLE file
ffmpeg -vcodec png -i logo.png -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 initlogo.rle
Note:- Replace format as per requirement.
From RLE file to PNG file
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 1024x768 -i initlogo.rle -vcodec png logo.png
There are three ways to achieve this in Android.
Through Worker thread:-
private static final ScheduledExecutorService worker =
Executors.newSingleThreadScheduledExecutor();
void someMethod() {
...
Runnable task = new Runnable() {
#define _GNU_SOURCE
#include <sched.h>
Set:-
cpu_set_t mask;
CPU_ZERO(&mask);
pid_t pid = gettid(); // Thread. For pid, use getpid()
CPU_SET(1, &mask);
Add below permission in Androidmenifest.xml file.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Code snippet:-
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String deviceID =telephonyManager.getDeviceId();
Bitmap snapshot = null;
Drawable drawable = null;
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_AUTO); // Quality of the snpashot
try {
view.layout(0, 0, 110, 110);
snapshot = Bitmap.createBitmap(view.getDrawingCache(true)); // You can tell how to crop the snapshot and whatever in this method
drawable = new BitmapDrawable(snapshot);
} catch(Exception ex) {
ex.printStackTrace();
There are generally three ways to do this:
1. As some of the answers suggested, you could distinguish the cases of your activity being created for the first time and being restored from savedInstanceState.
This is done by overriding onSaveInstanceState and checking the parameter of onCreate.
2. You could lock the activity in one orientation by adding android:screenOrientation="portrait" (or "landscape") to <activity> in your manifest.
<activity android:screenOrientation="landscape">
3. You could tell the system that you meant to handle screen changes for yourself by specifying android:configChanges="screenOrientation" in the <activity> tag.