This file contains 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 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 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 myusername@myhost.com ). Then simply run X11 programs. |
This file contains 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 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 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 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 apt-get install python-software-properties | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
Oracle JDK 6 | |
sudo apt-get install oracle-java6-installer | |
Oracle JDK 7 | |
sudo apt-get install oracle-java7-installer |
This file contains 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
tail -f /var/log/syslog | stdbuf -oL cut -d'|' -f2 | tee times.txt |
This file contains 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
Provider[] providers = Security.getProviders(); | |
for (Provider p : providers) { | |
System.out.printf("%s/%s/%f\n", p.getName(), p.getInfo(), | |
p.getVersion()); | |
Set<Service> services = p.getServices(); | |
for (Service s : services) { | |
System.out.printf("\t%s/%s/%s\n", s.getType(), | |
s.getAlgorithm(), s.getClassName()); |
This file contains 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 final int FILL_PARENT | |
Added in API level 1 | |
Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. This value is deprecated starting in API Level 8 and replaced by MATCH_PARENT. | |
Constant Value: -1 (0xffffffff) | |
public static final int MATCH_PARENT | |
Added in API level 8 |
OlderNewer