Skip to content

Instantly share code, notes, and snippets.

View swinton's full-sized avatar
:bowtie:

Steve Winton swinton

:bowtie:
View GitHub Profile
def linregress(X, Y):
"""
Summary
Linear regression of y = ax + b
Usage
real, real, real = linreg(list, list)
Returns coefficients to the regression line "y=ax+b" from x[] and y[], and R^2 Value
"""
if len(X) != len(Y):
raise ValueError('unequal length')
#!/usr/bin/env python
"""
Slugify input from STDIN to STDOUT.
Usage:
$ slugify.py
one two three four five
ctrl+D
#!/usr/bin/env python
"""
Example of gevent.with_timeout. Half the go_get calls will timeout.
"""
from gevent import monkey
monkey.patch_all()
@swinton
swinton / AESCipher.py
Last active November 8, 2024 18:31
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
javascript: (function(){window.docCookies={getItem:function(a){return decodeURIComponent(document.cookie.replace(RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null},setItem:function(a,b,c,e,f,g){if(!a||/^(?:expires|max\-age|path|domain|secure)$/i.test(a))return!1;var d="";if(c)switch(c.constructor){case Number:d=Infinity===c?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+c;break;case String:d="; expires="+c;break;case Date:d="; expires="+c.toUTCString()}document.cookie=encodeURIComponent(a)+"="+encodeURIComponent(b)+d+(f?"; domain="+f:"")+(e?"; path="+e:"")+(g?"; secure":"");return!0},removeItem:function(a,b,c){if(!a||!this.hasItem(a))return!1;document.cookie=encodeURIComponent(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(c?"; domain="+c:"")+(b?"; path="+b:"");return!0},hasItem:function(a){return RegExp("(?:^|;\\s*)"+encodeURIComponent(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},keys:function(){for(var a=do
  1. Connect to the VPN
  2. Start an SSH tunnel through battlezone.int
ssh -ND 9999 battlezone.int
  1. Update your proxy settings to connect through this tunnel, like so:

Three ingredients for a happy life

1. Work on something that is good for the world.

2. Be in a community where you experience deep love.

3. Redeem the events of your past.

🌈 🎈 🎉

🌈 🎈 🎉

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from random import shuffle
def picktop2(*args):
x, y = None, None
for i in args:
if i > x and i > y:
y = x
x = i
elif i > x:
@swinton
swinton / serve.sh
Created July 8, 2014 16:19
Shell script to run a simple HTTP server from the current working directory.
#!/bin/bash
# Default port to serve on is 8800, to serve on another port, e.g. 3319:
# serve.sh 3319
port=${1-8800}
python -m SimpleHTTPServer $port