Skip to content

Instantly share code, notes, and snippets.

View samuell's full-sized avatar
💻
Hacking away

Samuel Lampa samuell

💻
Hacking away
View GitHub Profile
@samuell
samuell / .vimrc
Created September 5, 2012 16:38
Vim RC settings for Python Dev
syntax on
set showmatch
set ignorecase
set showmode
set ts=4
set sw=4
set autoindent
set smartindent
" Enable file type plugins
@samuell
samuell / pyhelp
Created September 26, 2012 09:16
usr/bin/pyhelp script (To enable quick python help from e.g. vim)
#!/bin/bash
/usr/bin/python -c "help(\"$1\")"
@samuell
samuell / cythonize.sh
Created September 26, 2012 10:33
Cythonize python scripts (bash function to be placed in .bashrc)
cythonize() {
cython --embed $1.py
gcc -I/usr/include/python2.7 -o $1 $1.c -lpython2.7
}
@samuell
samuell / mediawiki-subfolder-cleanurls
Created October 29, 2012 08:50
vhost and php config for clean URLs for mediawiki in a subfolder
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)$ /subfolder/w/index.php?title=$1 [L,QSA]
RewriteRule ^$/subfolder/wiki/ [L,QSA]
<?php
$wgScriptPath = "/subfolder/w";
@samuell
samuell / scde_example.json
Created November 5, 2012 13:51
SCDE example data
{
"_id": {
"$oid": "4f5e631e69adda9f62821f90"
},
"category": "c2",
"description": "Genes up-regulated in pancreatic cancer cells grown in orthotopic xenograft tumors compared to those grown in vitro.",
"human-ensembl": [
"ENSG00000142789",
"ENSG00000133110",
"ENSG00000112664",
@samuell
samuell / galaxy_manual_restart.sh
Created November 16, 2012 15:38
Restart a manually started Galaxy instance
#!/bin/bash
galaxypid=$(ps -efw|grep paster|awk '{ print $2 }'|head -n 1);kill $galaxypid;
sh run.sh &
@samuell
samuell / tsv_to_dicts.py
Created February 1, 2013 18:41
Read a tab separated file, with headers, into a "list" (or a generator object returning items, but behaves similar), where each dict uses the headers in the first line as keys.
'''
Read a tab separated file, with headers, into a "list" (or better,
a generator object returning items, but behaves similar), where
each dict uses the headers in the first line as keys.
Author: Samuel Lampa 2013 - samuel.lampa@gmail.com
'''
# Open file
infile = open(some_filename)
@samuell
samuell / gc_python.py
Created May 10, 2013 16:49
My code, with improvents Thomas Koch, and lelledumbo.
import re
import string
def main():
file = open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r")
a = 0
t = 0
g = 0
c = 0
for line in file:
@samuell
samuell / gc_cython.pyx
Created May 10, 2013 16:53
Same as #5555675. bit with static typing of the ints, for cython.
import re
import string
def main():
file = open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r")
cdef int a, t, c, g
a = 0
t = 0
g = 0
c = 0
program gc;
{$mode objfpc} // Do not forget this ever
uses
Sysutils;
var
FastaFile: TextFile;
CurrentLine: String;
GCCount: Integer;