Skip to content

Instantly share code, notes, and snippets.

"""
flat convolution of width n on an array x in O(n) time
padded out to maintain shape
"""
def do_convolve(X, n):
csum = np.cumsum(X)
conv = np.r_[np.repeat(csum[n-1],n), csum[n:]-csum[:-n]]
return conv
"""
get position of adjactent 1st in a vector
"""
def getNonZeroRanges( A, zeroDefVal=0 ):
dA=np.diff(A)
N=A.shape[0]
nzdA,=np.nonzero(dA)
liRangesAll=np.c_[ np.r_[0,nzdA+1],
np.r_[nzdA,N-1] +1]
iiR = A.take(liRangesAll[:,0]) != zeroDefVal
@psudmant
psudmant / flat_convolution
Last active August 29, 2015 14:01
flat convolution
"""
flat convolution of width n on an array x in O(n) time
padded out to maintain shape
"""
def do_convolve(X, n):
csum = np.cumsum(X)
conv = np.r_[np.repeat(csum[n-1],n), csum[n:]-csum[:-n]]
return conv
@psudmant
psudmant / index.html
Created May 13, 2014 03:29
Test Sankey Diagram: Obama schedule
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://timelyportfolio.github.io/rCharts_d3_sankey/css/sankey.css'>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://timelyportfolio.github.io/rCharts_d3_sankey/js/sankey.js' type='text/javascript'></script>
<style>
@psudmant
psudmant / index.html
Created May 13, 2014 03:28
Test Sankey Diagram
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://timelyportfolio.github.io/rCharts_d3_sankey/css/sankey.css'>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://timelyportfolio.github.io/rCharts_d3_sankey/js/sankey.js' type='text/javascript'></script>
<style>
#!/bin/bash
# Get and install openblas
mkdir -p ~/bin/openblas
cd ~/bin/openblas
wget https://github.com/xianyi/OpenBLAS/archive/v0.2.9.rc1.zip
unzip v0.2.9.rc1
cd OpenBLAS-0.2.9.rc1/
make
#!/bin/sh
#rule: {job}
#input: {job.input}
#output: {job.output}
#threads: {job.threads}
{self.workflow.snakemakepath} --snakefile {self.workflow.snakefile} \
--force -j{self.cores} \
--directory {workdir} --nocolor --notemp --quiet --nolock {job.output} \
> /dev/null && touch "{jobfinished}" || touch "{jobfailed}"
exit 0
#!/bin/sh
#
# Adopts and submit a snakemake cluster job script to SGE queue
#
# by Hyeshik Chang
#
JOBSCRIPT_SNAKEMAKE=$1
JOBSCRIPT_SGE="`dirname $1`/sge`basename $1`"
# set this to your head node hostname (run hostname)
HEAD_NODE_NAME=master
if [ `hostname` = $HEAD_NODE_NAME ]; then
NODES=`qconf -sel | grep -v $HEAD_NODE_NAME`
for NODE in $NODES; do
SCRIPT_PATH=$(dirname `which $0`)
qsub -l h=$NODE $SCRIPT_PATH
done
Improve the log (https://coderwall.com/p/euwpig?i=3&p=1&t=git)
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
Enable color in git:
git config --global --add color.ui true
Make git push only push the current branch
git config --global push.default current