Skip to content

Instantly share code, notes, and snippets.

View azalea's full-sized avatar
😂
Enjoy life

Z azalea

😂
Enjoy life
View GitHub Profile
@azalea
azalea / keepunique.sh
Created July 2, 2013 23:16
Remove multi-mappers and keep uniquely mapped reads in an alignment file. Now support .sam, .bed, and other tab-delimited files.
#!/bin/bash
column= type= infile= outfile=
while getopts c:i:o: opt; do
case $opt in
c)
column=$OPTARG
;;
i)
infile=$OPTARG
@azalea
azalea / buggy_defaultdict.py
Created August 7, 2012 23:04
Bug of defaultdict?
import collections
def dfs(G, s, path=[]):
global explored
explored.add(s)
path.append(s)
for v in G[s]:
if v not in path:
path = dfs(G, v, path)
return path
@azalea
azalea / sieveEratosthenes.py
Created January 8, 2012 08:59
Sieve of Eratosthenes
def sieveEratosthenes(limit):
'''Return all primes below the limit'''
numbers = range(3,limit,2)
primes = [2]
while True:
prime = numbers.pop(0)
primes.append(prime)
for n in range(prime**2, limit, 2*prime):
try:
numbers.remove(n)
@azalea
azalea / wineTasting.py
Created December 17, 2011 04:13
Facebook Hacker Cup 2011 Round 1A - Wine Tasting
#!/usr/bin/python
import sys
def fac(n):
'''n!'''
if n==0 or n==1:
return 1
else:
return n*fac(n-1)
@azalea
azalea / resplit.py
Created November 29, 2011 07:38
re split
import re
txt = 'abc-def, -g!8hij'
words = re.compile('[^A-z^a-z]+').split(txt)
# Or
words = re.split('[^A-z^a-z]+',txt)
# References:
# http://docs.python.org/library/re.html#re.split
@azalea
azalea / gist:1223667
Created September 17, 2011 05:50 — forked from imathis/gist:1104557
FIX for Lion's posix_spawn_ext.bundle: [BUG] Segmentation fault

The segfault problem with posix_spawn is indeed caused by Lion's compiler being LLVM and not GCC by default. However, when I installed RVM, the notes suggested that on Lion you need to add export CC=/usr/bin/gcc-4.2 to your shell startup file (.bashrc or .zshrc as appropriate). I did that, but it seems that's what caused problems: while ruby 1.9.2 needs you to use GCC to install it, using the same compiler for the gems apparently causes breakage.

First, you need to install XCode 4.x, which is now a free (though hefty!) download from the Mac App Store. Without that, you have no gcc, so you won't get anywhere ;-)

Next, what you need to do is clear out your rvm ruby and the associated gems (make sure you are cd'd into your octopress repository then do:

rvm remove ruby-1.9.2 --gems --archive

which will clear everything out so that you can start from scratch. Obviously, if you have other stuff you've installed for other purposes using RVM, be careful with this. If you previously had the export CC li