Skip to content

Instantly share code, notes, and snippets.

@stestagg
stestagg / colorshift.less
Created April 25, 2014 16:11
Better color shifting for less-css
// Less color functions are absolute, i.e. if you lighten a really light color by 50%, you'll probably just get pure-white,
// because lighten works relative to the full scale from black -> white
// These functions shift a color relative to it's current value, (if you have a 50% grey, and shift it by 50%, you should end up with a 75% grey)
// Because less doesn't support functions as well as I would like, the solution is quite hacky.
// To set a property to a shifted value, call .color_shift, passing it in.
// For example: .color_shift(background, blue, 70%); produces: background: #b3b3ff; (light-blue)
@stestagg
stestagg / script.py
Created September 24, 2014 09:43
Template for shell script boilerplate
#!/usr/bin/env python
import sys
import argparse
def parse_args(args=None):
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="count", default=0,
help="Increase verbosity", dest="verbosity")
@stestagg
stestagg / gist:19165152c7567538a07d
Created October 26, 2014 23:00
Install wpa_supplicant for raspberry pi/arch from x86 machine
mount /dev/sdX2 root
cd root
pacman -r . --config etc/pacman.conf --arch armv6h -S wpa_actiond wpa_supplicant
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
curl -L https://github.com/coreos/rocket/releases/download/v0.1.0/rocket-v0.1.0.tar.gz -o rocket-v0.1.0.tar.gz
$ rkt fetch https://github.com/coreos/etcd/releases/download/v0.5.0-alpha.4/etcd-v0.5.0-alpha.4-linux-amd64.aci
$ wget https://github.com/coreos/etcd/releases/download/v0.5.0-alpha.4/etcd-v0.5.0-alpha.4-linux-amd64.aci
$ rkt run https://github.com/coreos/etcd/releases/download/v0.5.0-alpha.4/etcd-v0.5.0-alpha.4-linux-amd64.aci
$ rkt run sha256-701c24b2d275f0e291b807a464ae2390bcd8d7c5b4f2d7e47e6fd917cd5e5588
$ rkt run -volume database:/tmp \
	https://github.com/coreos/rocket/releases/download/v0.1.0/ace-validator-main.aci \
	https://github.com/coreos/rocket/releases/download/v0.1.0/ace-validator-sidekick.aci
rkt run --volume bind:/opt/tenant1/database \
@stestagg
stestagg / IPs.py
Created February 18, 2013 15:37
Iterate over all IP addresses in a range..
def get_addr_range(start, end):
def to_int(ip):
return sum([int(p) << (24 - (8 * e)) for e, p in enumerate(ip.split("."))])
def to_ip(val):
return ".".join(str((val & (0xff << s)) >> s) for s in range(24, -1, -8))
for addr in xrange(to_int(start), to_int(end) + 1):
yield to_ip(addr)
@stestagg
stestagg / api.py
Last active December 15, 2015 05:59
import functools
import flask
import inspect
import sys
import traceback
def infer_args(func):
argspec = inspect.getargspec(func)
if argspec.defaults is None:
class A
def foo
puts "A"
end
def self.bar
puts "B"
end
end
#!/bin/bash
function error {
echo -e ">>>>>>>>>>>>>>>>>>>>>>\n$@\n<<<<<<<<<<<<<<<<<<<<<<"
}
set -e
if [ -e test ]; then
echo "'test/' already exists"
<snippet>
<content><![CDATA[
package ${TM_FILEPATH/(.*((?<pfx>com|net|uk|org)\/))?(?<dir>[^\/]+)\/([^\/]+$)?/$+{pfx}.$+{dir}/g};
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>package</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.java</scope>
<description>Automatically calculate package line from file path</description>
</snippet>