Gzip a StringIO stream
https://gist.github.com/dgmt/e3c6cff28a76b698943a0d59c3345a3c
noise dept.
DEAR READER
Mike Driver

oozey mess
No title available
Aqua Utopia|海の底で記憶を紡ぐ
NASA

blake kathryn
styofa doing anything
No title available
Claire Keane

@theartofmadeline
RMH
Xuebing Du
Jules of Nature
Today's Document
Monterey Bay Aquarium

Janaina Medeiros
hello vonnie
ojovivo
seen from United States

seen from United States

seen from Netherlands

seen from Hong Kong SAR China
seen from Hungary

seen from Germany
seen from United States

seen from United States

seen from Türkiye

seen from United States

seen from Türkiye

seen from Singapore
seen from Italy
seen from United States

seen from Malaysia
seen from Sweden
seen from Netherlands

seen from United States
seen from United States

seen from United States
@shroudofturing-blog
Gzip a StringIO stream
https://gist.github.com/dgmt/e3c6cff28a76b698943a0d59c3345a3c
Human readable filesize
https://gist.github.com/vriznic/5623cbd4f6c0a2e3e859
Import libraries from local folder
from onionshare:
https://gist.github.com/vriznic/b2300f804ab86a475c17
tastypie.http.HttpBadRequest
Here
API search
Haystack stuff:
Search string: 127.0.0.1:8000/console/api/v1/premises/search/?=zeto&format=json
install elasticsearch,pyelasticsearch
Longest common substring
https://gist.github.com/dgmt/8022451
Icons are not my fav things...
This is an example text, i want its favicons!!!
>>> z='Thanks a lot. But you are right, when type attribute is missing, or different the expression will not work. What have to be changed, that the type attribute, or anything other between "shortcut icon" and href will be ingored? It should work with: <link rel="shortcut icon" type="image/x-icon" href="//icons/favicon.ico" /> <link rel="shortcut icon" href="//icons/favicon.ico" /> and also with: <link rel="shortcut icon" 12345678 href="//icons/favicon.ico" /> <link rel="shortcut icon" 12345678 href="http://site.yeah.com/favicon.ico" /> Thank you'
>>> a = re.findall(r'(?<=\<link rel=[",\']shortcut icon[",\'])[ ,\w]* href=[",\'][\w,\/,:,.]*.ico[",\']',z)
>>> neu=[] >>> for item in a: neu.extend(re.findall(r'(?<=href=[",\'])[\w,\/,:,.]*.ico(?=[",\'])',item)) >>> neu ['//icons/favicon.ico', '//icons/favicon.ico', 'http://site.yeah.com/favicon.ico'] >>> WIN!
mapmap
>>> a=['asd_bsd','xc_ax','xx'] >>> b=['__'] >>> c=['_s_'] >>> L = map(lambda x:x.replace('_','*'), a) >>> L ['asd*bsd', 'xc*ax', 'xx'] >>> N = map(lambda x:map(lambda x:x.replace('_','*'), x),[a,b,c]) >>> N [['asd*bsd', 'xc*ax', 'xx'], ['**'], ['*s*']]
Know me, Mongo
>>> auth='mongodb://username:[email protected]:27017' >>> con = Connection(auth)
Poison Pill Termination Pattern
Go through the keychain
>>> a={'a':1,'b':2} >>> a {'a': 1, 'b': 2} >>> a['c']={'x':4,'y':5} >>> a {'a': 1, 'c': {'y': 5, 'x': 4}, 'b': 2} >>> len(a['c']) 2 >>> keys=['c','y'] >>> for i in keys: a=a[i] print a {'y': 5, 'x': 4} 5 >>> a 5
Flatten the dictionary
tstRec2={ 'namesurname':{'name':'Vladimir','surname':'Mayakovski'}, 'drinksmoke':{'drink':'no','smoke':'yes'} } def dictator(record, parentKey=''): items=[] for key in record: nKey = parentKey + '_' + key if parentKey else key if (isinstance(record[key], collections.MutableMapping)): items.extend(dictator(record[key], nKey).items()) else: items.append((nKey,record[key])) return dict(items)
Hexed
>>> c=r'\xbd\xf9vq\xe2\x17\xf4' >>> a=c.replace('\\','*0') >>> splitted=a.split('*') >>> for i in splitted: try: print int(i,16) except: pass 189 226 23 244 >>>
Apache&WSGI
processes die on timeout??? research!!! F_YEAH SUPERVISORD!!!
File reader generator
def loadZips(): #returns a list with all the ZIPs with open("zips.txt") as f: for line in f: yield (line.rstrip()) zips=loadZips()
Then use zips as any other iterable
It runs in background, find it, kill it
nohup python script.py & ps aux | grep script kill -9 pid
Break from second loop, continue first
>>> a=['a','b','c','d','e'] >>> b=[1,2,3,4,5,6,7,8,9] >>> for l in a: for n in b: if (n==4): broke=True break else: print l print n if(broke==True): broke=False continue