Skip to content

Instantly share code, notes, and snippets.

View masci's full-sized avatar

Massimiliano Pippi masci

View GitHub Profile
@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)
# 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'
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'
@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
@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
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
if [ -f ${VENV}/bin/postactivate ]; then
. ${VENV}/bin/postactivate
@masci
masci / .zshrc
Created November 6, 2013 22:46
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="masci"
# Example aliases
[user]
name = Massimiliano Pippi
email = [email protected]
signingkey = 22AA96CA
[alias]
co = checkout
ci = commit
st = status
br = branch
@masci
masci / main.py
Created September 4, 2013 13:42
Simple Qt application embedding a PyMol instance.
#!/usr/bin/python
"""
PyMol Widget
Usage:
main.py [input_files]
Options:
-h, --help: print this screen
"""
function _virtualenv_prompt_info {
[[ -n $(whence virtualenv_prompt_info) ]] && virtualenv_prompt_info
}
function _git_prompt_info {
[[ -n $(whence git_prompt_info) ]] && git_prompt_info
}
function _python_ver {
[[ -n $(/usr/bin/env python --version) ]] && python_ver