Skip to content

Instantly share code, notes, and snippets.

View mahmoud's full-sized avatar
Back on the grid!

Mahmoud Hashemi mahmoud

Back on the grid!
View GitHub Profile
def jit_toposort(dep_map):
"expects a dict of {item: set([deps])}"
ret, orig_dep_map, dep_map = [], dep_map, dict(dep_map)
if not dep_map:
return []
extras = set.union(*dep_map.values()) - set(dep_map)
dep_map.update([(k, set()) for k in extras])
remaining = dict(dep_map)
ready = set()
while remaining:
Traceback (most recent call last):
File "prefork.py", line 306, in <module>
pidfile=args.pidfile).run(args.daemonize)
File "prefork.py", line 222, in run
self.handle_signals(os.read(r, 4096))
File "prefork.py", line 193, in handle_signals
handler_meth(signo, None)
File "prefork.py", line 242, in SIGCLD_handler
self.remove_worker(self.pid_to_workers[pid])
KeyError: 26600
@mahmoud
mahmoud / gist:9160135
Created February 22, 2014 19:00
style.css off weeklypedia labs instance
body {
margin: 5em 0;
background-color: rgb(237, 224, 206);
}
article, header {
background-color: #fff;
color: #222222;
margin: auto;
padding: 1.5em;
width: 600px;
>>> __builtins__ = {'file': __builtins__.file}
>>> file('/dev/null')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: file() constructor not accessible in restricted mode
@mahmoud
mahmoud / markfaves.md
Last active August 29, 2015 14:06
mark's favorites

Words

  • Thunk
  • Trap
  • Trampoline
  • Restart
  • Transports/Protocols

Code

@mahmoud
mahmoud / uncaught.py
Last active August 29, 2015 14:07
exploring the behavior reraising (unexpectedly includes function calls after original raise)
def raise_it():
raise
def do_it():
try:
dumb()
except:
raise_it()
markdown input.md | tidy -i -w 1024 -q | xclip -selection "clipboard"
@mahmoud
mahmoud / ffmpeg_crop.sh
Created February 1, 2015 18:19
a codification of a particular method of using ffmpeg to clean up certain FLVs.
# cropping mp4 video in ffmpeg.
#
# this does require a re-encode but the following process created video
# half the size with no perceptible change in quality. audio is unaffected.
# detect area to crop
ffplay -i show.mp4 -vf "cropdetect=24:16:0"
# crop to 944x720, x-offset=170, y-offset=0 (removing vertical black bars)
ffmpeg -i show.mp4 -vf "crop=944:720:170:0" show_cropped.mp4
@mahmoud
mahmoud / xrange_blergh.py
Created February 8, 2015 07:05
PDW: xrange has its limits, thanks to being implemented in C. somewhat defeats the purpose of xrange.
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
9223372036854775807
>>> xrange(0, 2 ** 64 - 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
catsym:{`$sv[x]each string flip y}
accttypes:("SSSS";enlist",")0:hsym`$"..\\..\\..\\accttypes.csv"
accttypes:`accttype xkey select from accttypes where fi=`interracu.com
lcsv: {("****SDSFS**SSS";enlist",")0:hsym`$x} /load csv from filename
chkopens:{[f]
/f:first fs
end:"D"$ssr[;".csv";""] f;
begin:`date$`month$end;
t:update `accttypes$account_code,route:catsym["";(zip5;crrt)] from lcsv f;
during:select opens:count i by route from t where account_code.serv=`Checking,account_open_date within (begin,end); /checking accounts opened during (begin,end) month period