Skip to content

Instantly share code, notes, and snippets.

Eran Rundstein eranrund

Block or report user

Report or block eranrund

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View osx-for-hackers.sh
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
View gist:5205142
Request:
{"name":"TODO test","account_number":"9900000002","routing_number":"021000021","type":"savings","system_timezone":2,"user_agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22","language":"en-US"}
Response:
{
"credits_uri": "/v1/bank_accounts/BA2nZoAiqx5UFsPrs7P6i5PO/credits",
"bank_name": "JPMORGAN CHASE BANK",
"bank_code": "021000021",
"account": null,
"meta": {},
View gist:3683438
...
import gc
print 'before collect'
gc.collect()
print 'after collect'
print 'done, calling lsof'
subprocess.call("lsof -p%d -a -iTCP" % (pid,), shell=True)
View x.py
import traceback
import os
orig_close = os.close
def patched_close(*args, **kwargs):
print '----------------------------'
print 'os.close!',args,kwargs
traceback.print_stack()
print
return orig_close(*args, **kwargs)
os.close = patched_close
@eranrund
eranrund / r.py
Created Sep 7, 2012
requests debugging
View r.py
import socket,traceback
orig_socket = socket.socket
class wrap_socket(orig_socket):
def __init__(self, *args, **kwargs):
orig_socket.__init__(self, *args, **kwargs)
#traceback.print_stack()
print '--> new sock', self.fileno()
print
View strace.out
execve("/usr/bin/python", ["python", "./3318253/gistfile1.txt"], [/* 22 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libutil.so.1", O_RDONLY|O_CLOEXEC) = 3
@eranrund
eranrund / gist:3313868
Created Aug 10, 2012
demonstrates python-requests socket leak
View gist:3313868
import requests
reqsess = requests.session()
try:
r = reqsess.get(r'http://www.mouser.com/Search/Refine.aspx?Keyword=test')
d = r.text
finally:
reqsess.close()
print 'done'
import time
You can’t perform that action at this time.