Skip to content

Instantly share code, notes, and snippets.

View lox's full-sized avatar

Lachlan Donald lox

View GitHub Profile
@lox
lox / gulp-sass-changed.js
Created February 5, 2014 07:34
A Gulp Plugin that filters out sass files that haven't changed based on their import graph
'use strict';
var fs = require('fs');
var path = require('path');
var gutil = require('gulp-util');
var through = require('through2');
var glob = require('glob');
module.exports = function (dest, loadPaths) {
Array.prototype.unique = function() {
var o = {}, a = [], i, e;
@lox
lox / keybase.md
Created February 28, 2014 03:45
Verification of my public key for keybase.io

Keybase proof

I hereby claim:

  • I am lox on github.
  • I am lox (https://keybase.io/lox) on keybase.
  • I have a public key whose fingerprint is BCAC 4ADE 7630 91A2 DB33 8D3F 5051 ACE0 B528 9A75

To claim this, I am signing this object:

@lox
lox / docker.sh
Last active August 29, 2015 13:57
A ssh wrapper for docker
#!/bin/bash
# translate the path to the docker vm equiv
projects=/Users/$(whoami)/Projects/99designs
# if we are within the projects directory
if [[ "$PWD" =~ ^$projects ]]; then
dockercwd=${PWD//$projects/\/projects}
fi
@lox
lox / time_is_broken_abandon_hope.sh
Created March 31, 2014 05:22
Checks absolute times elapsed in a VM against currentmillis.com
#!/bin/bash
SAMPLES=5
OVERHEAD=600 # about 600ms of overhead from AU for the service below
function remote_millis() {
curl --silent http://currentmillis.com/api/millis-since-unix-epoch.php
}
for i in {1..10} ; do
@lox
lox / plan.md
Created April 26, 2014 21:24
go-vendor

Vendoring go libraries with go-vendor

Commands

go-vendor list
go-vendor update <package>
go-vendor save <package>
go-vendor local 
@lox
lox / unsplash.php
Created April 27, 2014 02:05
Creates a list of images to download from unsplash.com
<?php
$domain = "http://unsplash.com/";
$STDERR = fopen('php://stderr', 'w+');
function resolve_short_url($url) {
$ch = curl_init("$url");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@lox
lox / README.md
Last active August 29, 2015 14:00
Creates a list of images to download from unsplash.com

First, create a txt file with all of the files on unsplash.com:

curl -s https://gist.githubusercontent.com/lox/11336025/raw/unsplash.php | php > unsplash.txt

Next, download files in parallel:

cat unsplash.txt | xargs -n 1 -P 8 -t wget -N -q
@lox
lox / Dockerfile
Last active August 29, 2015 14:01
FROM ubuntu:14.04
# apt configuration
ENV DEBIAN_FRONTEND noninteractive
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/99dev
RUN apt-get update
RUN apt-get install mysql-server-5.6
# MySQL TCP port
@lox
lox / version.sh
Last active August 29, 2015 14:01
Using RubyGems Requirements in a shell script to compare semantic version numbers
#!/bin/bash
# set -x
set -e
version_compare() {
IFS=',' ;for v in $@ ; do
ruby -e "exit Gem::Dependency.new('', '$v').match?('', '$2')" || return 1
done
}
@lox
lox / docker-init.sh
Last active August 29, 2015 14:02
Experimenting with using bash to spawn child processes for Docker and clean up zombie children
#!/bin/bash
set -o monitor
checkpids() {
for pid in $(jobs -p); do
if ! kill -0 $pid 2>/dev/null && ! wait $pid ; then
wait $pid
echo $?
echo Pid $pid exited with non-zero exit status >&2
return 1