Skip to content

Instantly share code, notes, and snippets.

View philippbayer's full-sized avatar

Philipp Bayer philippbayer

View GitHub Profile
@philippbayer
philippbayer / allParser.py
Created January 17, 2012 13:34
openSNP-parser for all files in Python 3
#!/usr/bin/python3
# This Script parses a couple of genotyping-files downloaded from openSNP.
# It supports deCODEme, FamilyTreeDNA and 23andme-files.
# If you don't like the Object Oriented Magic just comment out the lines with allSnps.append
# and do your own magic.
# Example-Useage is name of the script followed by as many filenames as you like.
# ./megaparser.py 200.23andme.12 92.decodeme.1 [...]
# or:
@philippbayer
philippbayer / juliapython.jlpy
Created April 2, 2012 04:27
Julia vs. Python 2.7 Parsing
$ python2.7 parse.py
0.797344923019
$ julia parse.jl
16789.66212272644
o.O
Tested against a 91mb big tab-delimited input-file.
With a 800mb big file:
@philippbayer
philippbayer / pyvsruby.rb
Created April 10, 2012 04:31
Python vs Ruby
min = 1000000000
5.times do
t = Time.now
File.open("./backParsedTapidorContigs.csv").each do |r|
r.split("\t")
end
finish = (Time.now - t)
if finish < min
min = finish
end
@philippbayer
philippbayer / mass.cpp
Created April 10, 2012 10:04
All languages.
-------------------------------------------------------
C++:
#include <iostream>
#include <string>
#include <fstream>
#include <boost/tokenizer.hpp>
#include <vector>
#include <iterator>
#include <sys/time.h>
@philippbayer
philippbayer / dictin.py
Created April 17, 2012 02:19
Dictionary with in
return_dict = {}
for line in file_handle:
line_list = line.split()
if line_list[0] in return_dict.keys():
return_dict[line_list[0]].append(line_list)
else:
return_dict[line_list[0]] = [line_list]
@philippbayer
philippbayer / pythontry.py
Created April 17, 2012 02:20
Python dictionary with try/except
return_dict = {}
for line in file_handle:
line_list = line.split()
try:
return_dict[line_list[0]].append(line_list)
except KeyError:
return_dict[line_list[0]] = [line_list]
@philippbayer
philippbayer / defaultdict.py
Created April 17, 2012 23:53
Python dictionary with defaultdict
from collections import defaultdict
d = defaultdict(list)
for line in file_handle:
line_list = line.split
d[line_list[0]].append(line_list)
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
f, err := os.Open("./example")
@philippbayer
philippbayer / gist:5334931
Created April 8, 2013 07:36
Tiny comparison float() vs. +0.0
>>python -m timeit "100 + 0.0"
10000000 loops, best of 3: 0.0217 usec per loop
>>python -m timeit "float(100)"
10000000 loops, best of 3: 0.17 usec per loop
@philippbayer
philippbayer / gist:5559683
Created May 11, 2013 11:17
Brütal Legend with primusrun
PRIMUS_VERBOSE=2 primusrun ./Buddha.bin.x86
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
[S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.dll.
primus: profiling: display: 45.6 fps, 24.3% wait, 20.0% upload, 55.7% draw+swap
primus: profiling: readback: 45.9 fps, 28.0% app, 18.6% map, 53.4% wait
primus: profiling: display: 59.9 fps, 0.7% wait, 27.1% upload, 72.2% draw+swap
primus: profiling: readback: 59.8 fps, 5.1% app, 20.8% map, 74.1% wait
primus: profiling: display: 51.3 fps, 15.4% wait, 23.5% upload, 61.1% draw+swap
primus: profiling: readback: 51.3 fps, 16.6% app, 19.2% map, 64.2% wait
primus: profiling: display: 59.9 fps, 0.7% wait, 26.8% upload, 72.5% draw+swap