Skip to content

Instantly share code, notes, and snippets.

View eranrund's full-sized avatar

Eran Rundstein eranrund

View GitHub Profile
@eranrund
eranrund / gist:3313868
Created August 10, 2012 12:20
demonstrates python-requests socket leak
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
@eranrund
eranrund / strace.out
Created August 16, 2012 08:10
strace output
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 / r.py
Created September 7, 2012 12:08
requests debugging
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
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
...
import gc
print 'before collect'
gc.collect()
print 'after collect'
print 'done, calling lsof'
subprocess.call("lsof -p%d -a -iTCP" % (pid,), shell=True)
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": {},
#!/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'
@eranrund
eranrund / Electrodacus-1588544897786.json
Created May 3, 2020 22:29
electrodacus grafana json
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@eranrund
eranrund / metrics-local
Created November 20, 2023 20:05
Metrics data for PR #3701
.GetPrometheusMetrics | jq -r .metrics
# HELP fog_test_client Counters for fog_test_client
# TYPE fog_test_client counter
fog_test_client{op="tx_success_count"} 124
# HELP fog_test_client_gauge Gauges for fog_test_client
# TYPE fog_test_client_gauge gauge
fog_test_client_gauge{op="last_polling_successful"} 1
# HELP fog_test_client_tx_build_time Time for source client to build a transaction, including fog interactions
# TYPE fog_test_client_tx_build_time histogram
fog_test_client_tx_build_time_bucket{le="0.2"} 0