Skip to content

Instantly share code, notes, and snippets.

@callistabee
callistabee / multiprogress.py
Last active February 5, 2019 04:28
it's multiprocessing.Pool.map, but with a progress bar widget.
import multiprocessing.pool as mp
import itertools
import ipywidgets
from IPython.display import display
class Pool(mp.Pool):
def map(self, func, iterable):
try:
@callistabee
callistabee / disass.py
Created February 2, 2019 19:36
disassemble a windows executable
import pefile
import sys
import distorm3
fn = sys.argv[1]
pe = pefile.PE(fn)
try:
text_section = (
@callistabee
callistabee / drive.py
Created January 23, 2019 22:00
super simple utility for interacting with google drive api
from google.oauth2 import service_account
from googleapiclient.discovery import build
import argparse
class Drive:
def __init__(self, cred_path):
credentials = (
@callistabee
callistabee / proxyup
Last active June 24, 2018 15:03
osx: launch and use socks proxy
#!/bin/bash
host=$1
port=$2
function usage() {
echo "usage: $(basename $0) host [port=2046]"
exit 1
}
@callistabee
callistabee / .block
Last active April 28, 2018 01:17
Staged Transition Groups in D3
license: apache-2.0
@callistabee
callistabee / rainbow.scm
Created January 12, 2016 21:46
cycle a layer through all possible hues and save frames (for making a gif!)
(define (rainbow img layer dirname)
(let ( (c 0)
(dup-layer 0)
(dup-img 0)
(to-save 0)
)
(set! c -180)
@callistabee
callistabee / curry.php
Created September 23, 2014 12:21
php function currying
<?php
function add($x,$y) {
return $x + $y;
}
function curry($fn) {
return function($x) use ($fn) {
@callistabee
callistabee / treeviz.lhs
Last active February 14, 2019 13:30
trees to DOT graphs
The binary tree datatype:
> data Tree = Leaf | Fork Tree Int Tree deriving Show
A simple insert function implementing a Binary Search Tree:
> insert :: Int -> Tree -> Tree
> insert n Leaf = Fork Leaf n Leaf
> insert n (Fork l m r) | (n <= m) = Fork (insert n l) m r
> | otherwise = Fork l m (insert n r)
@callistabee
callistabee / mergesort.lhs
Last active February 10, 2021 06:39
Haskell Implementation of Mergesort
- Haskell Mergesort
- Copyright (C) 2014 by Kendall Stewart
First we define a couple of helper functions that
will be useful in splitting the list in half:
> fsthalf :: [a] -> [a]
> fsthalf xs = take (length xs `div` 2) xs