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
fastboot -i 0x2A96 devices | |
fastboot -i 0x2A96 oem unlock | |
fastboot -i 0x2A96 flash boot boot.img | |
fastboot -i 0x2A96 flash aboot emmc_appsboot.mbn | |
fastboot -i 0x2A96 flash modem NON-HLOS.bin | |
fastboot -i 0x2A96 flash rpm rpm.mbn | |
fastboot -i 0x2A96 flash sbl1 sbl1.mbn | |
fastboot -i 0x2A96 flash tz tz.mbn | |
fastboot -i 0x2A96 flash hyp hyp.mbn | |
fastboot -i 0x2A96 flash splash splash.img |
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
try: | |
# For Python 3.0 and later | |
from urllib.request import urlopen | |
except ImportError: | |
# Fall back to Python 2's urllib2 | |
from urllib2 import urlopen | |
import json, argparse, os, sys, pyperclip | |
def get(lib): |
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
#!/usr/bin/python | |
import sys | |
from optparse import OptionParser | |
import json | |
import urllib | |
def calculate(searchfor): | |
query = urllib.urlencode({'q': searchfor}) | |
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=2.0&%s' % query | |
search_response = urllib.urlopen(url) |
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
''' | |
source: http://stackoverflow.com/a/1012089/1777024 | |
''' | |
from itertools import tee, islice, chain, izip # official documentation https://docs.python.org/2/library/itertools.html | |
def prev_and_next(my_iterable): | |
prevs, items, nexts = tee(my_iterable, 3) | |
prevs = chain([None], prevs) | |
nexts = chain(islice(nexts, 1, None), [None]) |
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
# to import data from csv to table | |
\copy <table_name> from '/path/to/csv/filename.csv' DELIMITERS ',' CSV; | |
# to increase the auto_increment after import | |
ALTER SEQUENCE tblName_id_seq RESTART WITH <number>; |
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
# Assumptions | |
######################### | |
# remote_host: example.com | |
# remote_user: johndoe | |
# db_user: mydbuser | |
# db_pass: mydbpass | |
# db_name: mydbname | |
# to dump mysql database in the remote system from local system | |
ssh [email protected] 'mysqldump -u mydbuser --password=mydbpass mydbname > /destination/path/dump_filename.sql' |
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
context_processors.py | |
def baseurl(request): | |
""" | |
Return a BASE_URL template context for the current request. | |
""" | |
if request.is_secure(): | |
scheme = 'https://' | |
else: | |
scheme = 'http://' |
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 class PasswordValidator { | |
// For character determinations | |
private static final int CHAR_LOWER_A = 'a'; | |
private static final int CHAR_LOWER_Z = 'z'; | |
private static final int CHAR_UPPER_A = 'A'; | |
private static final int CHAR_UPPER_Z = 'Z'; | |
private static final int CHAR_NUMERIC_ZERO = '0'; | |
private static final int CHAR_NUMERIC_NINE = '9'; |
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 byte[] copyOfRange(byte[] from, int start, int end){ | |
int length = end - start; | |
byte[] result = new byte[length]; | |
System.arraycopy(from, start, result, 0, length); | |
return result; | |
} |
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
/* | |
Input: STRING -- something like "myplainpassword" | |
Output: MD5 STRING -- something like "79054025255fb1a26e4bc422aef54eb4" | |
*/ | |
public static String convertToMd5(final String inputString) throws UnsupportedEncodingException { | |
StringBuffer sb = new StringBuffer(); | |
try { | |
final java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); | |
final byte[] array = md.digest(md5.getBytes("UTF-8")); | |
for (int i = 0; i < array.length; ++i) { |