Skip to content

Instantly share code, notes, and snippets.

# open https://docs.google.com/spreadsheets/d/1k77hjQolIU3Lw6mq-d1GgbKQQpTPU6obExG5CsfI4E0
# highlight whole column, Ctrl+C
import json
src = '''
0.1833333333
0.4333333333
0.45
0.45
@branning
branning / binary_trees.py
Created June 10, 2015 00:06
Binary tree algorithms
#!/usr/bin/env python
from itertools import cycle
class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def preorder(self, shape=False):
@branning
branning / environment.yml
Created June 10, 2015 18:33
kind of like perl -pe, but less fun
name: channeltest
dependencies:
- pip=7.0.3=py27_0
- python=2.7.10=0
- scandir=1.1=py27_0
- setuptools=17.0=py27_0
@branning
branning / Dockerfile
Created June 18, 2015 23:56
bootstrap a new Rails app in Docker from boot2docker
FROM rails:onbuild
@branning
branning / environment.yml
Created December 14, 2015 15:32
Installing Scipy in Virtualenv, SO 34255582
name: scipy
dependencies:
- numpy=1.10.1=py27_0
- openssl=1.0.2d=0
- pip=7.1.2=py27_0
- python=2.7.11=0
- readline=6.2=2
- scipy=0.16.0=np110py27_1
- setuptools=18.5=py27_0
- sqlite=3.8.4.1=1
@branning
branning / matplotlib_jupyterlite_loop.ipynb
Last active October 22, 2023 23:25
Matplotlib nbagg example that updates in a loop
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@branning
branning / install_debian_jupyter_2_and_3.sh
Last active October 27, 2017 15:09
Run Python 2 & 3 in Jupyter on Fedora Linux
#!/bin/bash
#
# Install Jupyter Notebook with Python 2 and Python 3 kernels on Debian
# from http://stackoverflow.com/a/34421527/347567
set -o errexit
# As root, install `pip` and `jupyter` from apt, and the development packages, too.
apt-get update
apt-get install -y \
#!/usr/bin/env bats
#
# Bash Automated Testing System (BATS)
# https://github.com/sstephenson/bats
#
# Test curltail, both sourced and executed
@test "Missing argument, sourced" {
. curltail.sh
run curltail
#!/bin/bash
#
# alias for npm that only uses git over https
set -o errexit # exit on any error
real_npm=`which npm`
npm_install()
{
@branning
branning / live_hosts.sh
Created August 29, 2016 00:19
Find live hosts on local network with nmap
#!/bin/bash
#
# Find live hosts on local network with nmap
quiet() { $@ >/dev/null 2>&1; }
error() { echo 2>&1 "$@"; }
if ! quiet command -v nmap
then
error "You must install nmap."