Skip to content

Instantly share code, notes, and snippets.

# http://flask.pocoo.org/snippets/88/
import os, sqlite3
from cPickle import loads, dumps
from time import sleep
try:
from thread import get_ident
except ImportError:
from dummy_thread import get_ident
@indraniel
indraniel / style_guide.md
Created September 10, 2021 15:45 — forked from scottfrazer/style_guide.md
WDL Best Practices / Style Guide

"My First WDL" Template

task name {
  String in
  command {
    echo '${in}'
  }
  output {
 String out = read_string(stdout())

This page is a curated collection of Jupyter/IPython notebooks that are notable for some reason. Feel free to add new content here, but please try to only include links to notebooks that include interesting visual or technical content; this should not simply be a dump of a Google search on every ipynb file out there.

Important contribution instructions: If you add new content, please ensure that for any notebook you link to, the link is to the rendered version using nbviewer, rather than the raw file. Simply paste the notebook URL in the nbviewer box and copy the resulting URL of the rendered version. This will make it much easier for visitors to be able to immediately access the new content.

Note that Matt Davis has conveniently written a set of bookmarklets and extensions to make it a one-click affair to load a Notebook URL into your browser of choice, directly opening into nbviewer.

@indraniel
indraniel / gh-pages.md
Created December 17, 2019 13:50 — forked from ramnathv/gh-pages.md
Creating a clean gh-pages branch

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
@indraniel
indraniel / gnuplot-py-example.py
Created April 22, 2019 16:36 — forked from drmalex07/gnuplot-py-example.py
A simple example for Gnuplot.py. #python #gnuplot
import numpy
import Gnuplot
def rainfall_intensity_t10(t):
return 11.23 * (t**(-0.713))
def rainfall_intensity_t50(t):
return 18.06 * (t**(-0.713))
g = Gnuplot.Gnuplot()
@indraniel
indraniel / 00_destructuring.md
Created January 26, 2019 22:01 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@indraniel
indraniel / colors.nim
Created January 25, 2019 16:36 — forked from jabbalaci/colors.nim
A small program to make using 256 colors in Nim less painful.
import strformat
import tables
# A small program to make using 256 colors in Nim less painful.
# Original ZSH version from:
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
# Nim rewrite by Laszlo Szathmary <jabba.laci@gmail.com>
# thanks to narimiran and kickeroo for making the code more idiomatic Nim code
@indraniel
indraniel / gist:9d3955f87c6b564492e688fb9c32090b
Created January 1, 2019 23:40 — forked from drorata/gist:b05bfd59c45eec0470f6
Nice output of pandas.DataFrame in org-mode
import pandas as pd
import numpy as np
from tabulate import tabulate

df = pd.DataFrame(np.random.random((4,3)), columns=['A','B','C'])
print("foo")
return(tabulate(df, headers="keys", tablefmt="orgtbl"))
@indraniel
indraniel / GitHub curl.sh
Created December 4, 2018 20:50 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)
# Grab stdout line by line as it becomes available. This will loop until
# p terminates.
while p.poll() is None:
l = p.stdout.readline() # This blocks until it receives a newline.
print l
# When the subprocess terminates there might be unconsumed output
# that still needs to be processed.
print p.stdout.read()