Skip to content

Instantly share code, notes, and snippets.

View saxbophone's full-sized avatar
🏳️‍⚧️

saxbophone

🏳️‍⚧️
View GitHub Profile
@saxbophone
saxbophone / LondonUndergroundLimited.itermcolors
Created February 9, 2015 15:23
London Underground iTerm 2 Colour Scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.33725491169999999</real>
<key>Green Component</key>
<real>0.2941176593</real>
@saxbophone
saxbophone / gist:5c1bacc1960a8eda1b88
Created February 22, 2015 22:28
Python Recursive XOR
from operator import xor as _xor_
def xor(a, b):
try:
if len(a) is not 1 and len(b) is not 1:
result = []
for i in range(0,len(a)):
result.append(xor(a[i], b[i]))
return result
else:
@saxbophone
saxbophone / gist:69f29b2a5e359b5cdc15
Last active August 29, 2015 14:16
Train routing JSON idea sketch
{
"A": {
"B": ["A"]
},
"B": {
"A": ["C", "AA"],
"C": ["A"],
"AA": ["A"]
},
"C": {
@saxbophone
saxbophone / mia.sql
Last active August 29, 2015 14:16
Mia's Sandwich Shop SQL
CREATE TABLE Orders(
Order_Number INT NOT NULL PRIMARY KEY AUTOINCREMENT,
Date_of_Order DATE,
Paid BOOLEAN DEFAULT false,
Delivery_ID INT,
Sandwich_Code INT,
Quantity INT DEFAULT 0,
Subtotal NUMERIC(5,2)
FOREIGN KEY(Delivery_ID) REFERENCES Deliveries(Delivery_ID),
FOREIGN KEY(Sandwich_Code) REFERENCES Sandwiches(Sandwich_Code)
@saxbophone
saxbophone / Physics
Last active August 29, 2015 14:17
Hacky sim of acceleration over time, taking air resistance into effect until acceleration effectively becomes nil
#!/usr/bin/python
from time import sleep
mass = 303209.382 # Kg of a tube train roughly
force = 0.0 # Newtons, initially set to 0
accel = 0.0 # m/s^2, initially set to 0
power = 0.0 # Newtons, force being applied
drag = 0.0 # Newtons, air resistance
roll = 0.0 # Netwons, rolling resistance
velocity = 0.0 # m/s, speed
@saxbophone
saxbophone / gist:a12804679d0a9cfef6d2
Created March 23, 2015 11:16
Install latest working version of node and npm on raspberry pi
#!/bin/bash
#Make a new dir where you'll put the binary
sudo mkdir /opt/node
#Get it
wget http://nodejs.org/dist/v0.11.3/node-v0.11.3-linux-arm-pi.tar.gz
#unpack
tar xvzf node-v0.11.3-linux-arm-pi.tar.gz
def thresh(max=5000):
"""
Find the maximmum threshold of the paradoxical (i is 1000 = False) Phenomenon.
"""
p = 0
n = 0
n_break = False
p_break = False
for i in xrange(max):
if p is i:
create table authors(
id integer primary key,
first_name varchar(127),
last_name varchar(127)
);
create table books(
id integer primary key,
title varchar(255),
author integer,
@saxbophone
saxbophone / flatten_list.py
Last active August 29, 2015 14:18
Python Data Padding Template
def flatten_list(l, ignore_iterables=True):
"""
Flatten out nested lists and return a non-nested list.
By default, ignores other iterables.
"""
if ignore_iterables:
arr = []
if isinstance(l, list):
for item in l:
if isinstance(item, list):
@saxbophone
saxbophone / flatten_list.py
Created April 1, 2015 20:47
Python Flatten Nested Lists
def flatten_list(l, ignore_iterables=True):
"""
Flatten out nested lists and return a non-nested list.
By default, ignores other iterables.
"""
if ignore_iterables:
arr = []
if isinstance(l, list):
for item in l:
if isinstance(item, list):