Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Playing catch up!

Mahmoud Hashemi mahmoud

🏡
Playing catch up!
View GitHub Profile
View jit_toposort.py
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:
View gist:8798791
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 Feb 22, 2014
style.css off weeklypedia labs instance
View gist:9160135
body {
margin: 5em 0;
background-color: rgb(237, 224, 206);
}
article, header {
background-color: #fff;
color: #222222;
margin: auto;
padding: 1.5em;
width: 600px;
View gist:9267664
>>> __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 Aug 29, 2015
mark's favorites
View markfaves.md

Words

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

Code

@mahmoud
mahmoud / uncaught.py
Last active Aug 29, 2015
exploring the behavior reraising (unexpectedly includes function calls after original raise)
View uncaught.py
def raise_it():
raise
def do_it():
try:
dumb()
except:
raise_it()
View gist:4729a272daa2cda678d0
markdown input.md | tidy -i -w 1024 -q | xclip -selection "clipboard"
@mahmoud
mahmoud / ffmpeg_crop.sh
Created Feb 1, 2015
a codification of a particular method of using ffmpeg to clean up certain FLVs.
View ffmpeg_crop.sh
# 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 Feb 8, 2015
PDW: xrange has its limits, thanks to being implemented in C. somewhat defeats the purpose of xrange.
View xrange_blergh.py
$ 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>
View throwaway.q
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