Skip to content

Instantly share code, notes, and snippets.

View leepro's full-sized avatar
🏠
Working from home

DW Lee leepro

🏠
Working from home
View GitHub Profile
@leepro
leepro / tracer.py
Created June 19, 2014 18:36
tracer
def trace_calls(frame, event, arg):
if event != 'call':
return
co = frame.f_code
func_name = co.co_name
if func_name == 'write':
# Ignore write() calls from print statements
return
func_line_no = frame.f_lineno
func_filename = co.co_filename
@leepro
leepro / add_link.js
Created June 26, 2014 20:04
Hooking links
/**
* Implementation example of writable response bodies.
* Based on the draft of the Streams API (19 March 2014)
* https://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm
* Design document for response body reading/writing:
* https://docs.google.com/document/d/1iE6M-YSmPtMOsec7pR-ILWveQie8JQQXTm15JKEcUT8
*/
/* globals chrome, ByteStream, URL, XMLHttpRequest */
'use strict';
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@leepro
leepro / bitcounting.py
Last active August 29, 2015 14:03
Counting bits (4bytes integer)
# coding: utf-8
# In[196]:
import timeit
# In[197]:
@leepro
leepro / openport.py
Created July 31, 2014 23:18
find a open port
def get_open_port():
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 0))
s.listen(1)
port = s.getsockname()[1]
s.close()
return port
from IPython.core.display import Image as image
from PIL import Image
def save_and_display(arr, fname):
pilimg = Image.fromarray(arr)
pilimg.save(fname)
return image(filename=fname, width=600)
tail -f /tmp/tty.LightBlue-Bean | gawk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'
@leepro
leepro / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/sh
#
# Author: D. Lee
#
#
# Assume the input file has a format as follows:
# XXXXX ID URL YYYYY
#