Skip to content

Instantly share code, notes, and snippets.

@masci
masci / gist:1d9fa450c72089a29c2e
Created September 25, 2014 09:23
git rewrite path
PREFIX=projectA #adjust this
TAB=$'\t'
git filter-branch --index-filter '
git ls-files -s |
sed "s,${TAB},&"$PREFIX"/," |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
' HEAD
@masci
masci / telnet and wait
Created September 30, 2014 20:35
using AppleScript to start a telnet console and wait for it to finish
#!/bin/sh
osascript <<EOF
tell application "Terminal"
activate
set _tab to do script "telnet 127.0.0.1 2001 ; exit"
delay 1
repeat while _tab exists
delay 1
end repeat
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
" Plugins begin
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
# subcommunities.py
import sys
sys.modules['__main__'].__dict__.update({
'PyCon': type('PyCon', (object,), {}),
'numpy': type('numpy', (object,), {'infty': 'foo'}),
'pythonistas': type('Foo', (object,), {'enjoy': lambda x: x, 'fun': 'foo'})
})
sys.modules['subcommunities'] = list()
sys.modules['numpy.nifty'] = 'foo'
@masci
masci / foo
Created April 22, 2015 20:22
Foo
import time
import random
# fill the input list
a = [random.randrange(0,130) for x in range(10**6)]
# std sort, keep a unsorted
t = time.time()
b = sorted(a)
print(time.time() - t)
@masci
masci / README.md
Last active August 29, 2015 14:28 — forked from haggen/README.md
boot2docker on nfs

Get boot2docker working with nfs instead of vboxsf.

Tested on:

- Boot2Docker-cli version: v1.6.0
  Git commit: 9894ae9
- Boot2Docker-cli version: v1.6.2
  Git commit: cb2c3bc
import boto.ses
from collections import defaultdict
REGION='us-east-1'
AWS_KEY='YOUR_KEY'
AWS_SECRET='YOUR_SECRET'
def main():
cses = boto.ses.connect_to_region(REGION, aws_access_key_id=AWS_KEY, aws_secret_access_key=AWS_SECRET)
send_statistics = cses.get_send_statistics()
@masci
masci / main.py
Created December 1, 2016 13:26
Encode/Decode Protobuf chained messages
import metric_pb2
from google.protobuf.internal.encoder import _VarintBytes
from google.protobuf.internal.decoder import _DecodeVarint32
import timeit
import random
from functools import partial
import io
N_RUNS = 10

Keybase proof

I hereby claim:

  • I am masci on github.
  • I am masci (https://keybase.io/masci) on keybase.
  • I have a public key whose fingerprint is B8C1 E476 1E53 86F2 BAA1 5E6E EEB6 F9A0 22AA 96CA

To claim this, I am signing this object:

name: datadog-agent
channels: !!python/tuple
- !!python/unicode
'defaults'
dependencies:
- enum34=1.1.6
- openssl=1.0.2j
- pip=8.1.2
- pycosat=0.6.1
- pycrypto=2.6.1