Skip to content

Instantly share code, notes, and snippets.

@bikestra
bikestra / hashtag_crawl.py
Created September 6, 2014 05:50
Hashtag Visualization
import re
import matplotlib.pyplot as plt
import networkx as nx
from_id = None
G = nx.DiGraph()
for line_num, line in enumerate(open("baton.txt", "r")):
# find a line with only one id
@bikestra
bikestra / add_installer.py
Created August 28, 2013 16:33
Example of creating your own plug-in on starcluster
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
class AdditionalPackages(ClusterSetup):
def __init__(self):
pass
def run(self, nodes, master, user, user_shell, volumes):
log.info('install gcc-4.7 on master')
@bikestra
bikestra / gist:6290692
Created August 21, 2013 05:39
getting mean and RMSE of a specific column
awk '{sum += $3} END {print sum/NR}' filename.txt
awk '{sum += ($3-7.2589)^2} END {print sqrt(sum/NR)}' filename.txt
shuffle() {
awk 'BEGIN{srand();} {printf "%06d %s\n", rand()*1000000, $0;}' | sort -n -T./ | cut -c8-
}
@bikestra
bikestra / gist:5930813
Last active December 19, 2015 09:09
decltype extravaganza
row_assign_ = nomad_allocator<std::remove_pointer<decltype(row_assign_)>::type>().allocate(num_rows_);
// is this really better than
row_assign_ = my_allocator<int>().allocate(num_rows_);
// ...?
@bikestra
bikestra / tex_var_num_args.tex
Created September 3, 2012 03:56
Variable number of arguments in TeX macro using xparse
\usepackage{xparse}
\NewDocumentCommand\word{m+m+g}{%
\IfNoValueTF{#3}
{\item { {\bf #1}}: #2}
{\item { {\bf #1}}: #2\\ {\em #3}}%
}