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
#!/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."
@branning
branning / winswitch_01trillian.md
Last active October 31, 2016 17:05
Use Winswitch to run Trillian remotely on Ubuntu and view locally on MacOS

Use Winswitch to run Trillian remotely on Ubuntu 14.04 and view locally on MacOS

Winswitch is like 'screen for X11', in that it allows you to start an application on a remote host, connect to it remotely, disconnect, and re-connect later and everything will be as you left it. It decouples the viewing of a graphical application from the running of it.

You can achieve a similar effect with X11 forwarding in ssh, by using ssh -Y <hostname> <application>, but when you disconnect the application will quit.

The connection itself is made with Xpra, which is like VNC but allows more efficient video and audio compression.

Install Trillian on remote server

@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 \