This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get version | |
python -c "import django; print(django.get_version())" | |
#create a project | |
django-admin.py startproject mysite | |
#run development server | |
python manage.py runserver OR python manage.py runserver 8080 OR python manage.py runserver 0.0.0.0:8000 | |
#create databse tables from INSTALLED_APPS models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo vi /etc/init.d/cjp | |
sudo chmod +x /etc/init.d/cjp | |
#if you want it to run at startup | |
sudo update-rc.d cjp defaults | |
#to remove | |
sudo update-rc.d -f cjp remove | |
#start and stop at will |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os | |
from OpenSSL import crypto, SSL | |
from socket import gethostname | |
from pprint import pprint | |
from time import gmtime, mktime | |
from os.path import exists, join | |
CERT_FILE = "apache.crt" | |
KEY_FILE = "apache.key" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On SSH server make sure the sshd config file contains "X11Forwarding yes" (/etc/ssh/sshd_config). | |
On the client add -X flag to ssh command ( ssh -X [email protected] ). Then simply run X11 programs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.os.Process.myPid() | |
android.os.Process.killProcess(android.os.Process.myPid()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adb shell content delete --uri content://settings/settings/pointer_speed | |
adb shell content query --uri content://settings/settings | |
adb shell content insert --uri content://settings/secure --bind name:s:my_number --bind value:i:24 | |
See "package com.android.commands.content;" in /frameworks/base/cmds/content/ | |
Usese "final class ContentProviderProxy implements IContentProvider" in ContentProviderProxy.java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void registerConnectivityChange() { | |
BroadcastReceiver connectionReceiver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
// When just using the ConnectivityManager you can get identical intents | |
// twice within one second. So we need to use the WifiManager & ConnectivityManager | |
// to determine true state | |
if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { | |
NetworkInfo networkInfo = intent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.pm.PackageManager; | |
import android.os.Binder; | |
import android.content.Intent; | |
class { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Log.v(TAG, context.getPackageManager().getNameForUid(Binder.getCallingUid())); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void registerTimezoneListener() { | |
IntentFilter timezoneFilter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED); | |
BroadcastReceiver timezoneReceiver = new BroadcastReceiver(){ | |
@Override | |
public void onReceive(Context context, Intent intent){ | |
Log.d(TAG, "TIMEZONE CHANGED!"); | |
} | |
}; | |
Context.registerReceiver(timezoneReceiver, timezoneFilter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cpiekarski.helloworld; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.io.IOException; | |
/** | |
* javac -d . HelloWorldApp.java | |
* java -cp . com.cpiekarski.helloworld.HelloWorldApp |