Skip to content

Instantly share code, notes, and snippets.

View robskillington's full-sized avatar
⌨️

Rob Skillington robskillington

⌨️
View GitHub Profile
@robskillington
robskillington / callAsync.js
Created November 4, 2011 10:01
callAsync playground
// Anonymize
(function () {
Function.prototype.callAsync = function () {
var self = this, args = arguments, result = {returned:false};
setTimeout(function () { result.returnVal = self.apply(self, args); result.returned = true; }, 0);
return result;
}
})();
@robskillington
robskillington / gist:7282087
Created November 2, 2013 18:38
Fix for mysql2 gem fails to compile with MySQL 5.6.12 on OS X with Homebrew
Blatantly borrowed from StackOverflow
Uninstall MySQL 5.6.12:
brew unlink mysql
brew uninstall mysql
Go to the homebrew directory:
cd /usr/local
Go to version 5.6.10 (you can find a list of versions by running brew versions mysql:
@robskillington
robskillington / gist:e310ba0627293e2df91e
Created June 3, 2014 15:16
Swift synchronous request
class Request : NSObject {
func send(url: String, f: (String)-> ()) {
var request = NSURLRequest(URL: NSURL(string: url))
var response: NSURLResponse?
var error: NSErrorPointer = nil
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: error)
var reply = NSString(data: data, encoding: NSUTF8StringEncoding)
f(reply)
}
@robskillington
robskillington / classify.py
Created July 8, 2014 14:52
Document language classifier
#!/usr/bin/env python
'''docclass.py: Language classifier'''
__author__ = "Rob Skillington"
from math import sqrt, log
import re, os, sys, getopt
DEFAULTS = {
@robskillington
robskillington / harlemshake.js
Created September 18, 2014 19:42
harlemshake.js - shamelessly ripped for fun re-use
(function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
@robskillington
robskillington / numstatall.coffee
Created September 19, 2014 16:16
numstatall - pipe the output of `git diff --numstat <commit-ish>` to get total add and deletions
#!/usr/bin/env coffee
readline = require 'readline'
rl = readline.createInterface
input: process.stdin
terminal: false
stat = {add: 0, del: 0}
@robskillington
robskillington / DictionaryExtensions
Created September 30, 2014 23:02
valueForKey for simple value or nil operation
extension Dictionary {
func valueForKey<T>(key: Key) -> T? {
if let value = self[key] as? T {
return value
} else {
return nil
}
}
}
#!/usr/bin/env ruby
#vim:syntax=ruby
# Most of this borrowed from:
# https://github.com/ripienaar/monitoring-scripts/blob/master/puppet/check_puppet.rb
# A simple nagios check that should be run as root
# perhaps under the mcollective NRPE plugin and
# can check when the last run was done of puppet.
# It can also check fail counts and skip machines
# that are not enabled
@robskillington
robskillington / gist:a674ef1069ff3f8964e4
Created October 24, 2015 17:14
Run code with Ctrl + Enter in HackerRank CodePair
javascript:(function(){ window.addEventListener('keydown', function(e) {if (e.ctrlKey && e.keyCode == 13) { $('#compilerun').click(); }}); }())
@robskillington
robskillington / options.go
Last active April 25, 2016 13:13
options.go
package main
import (
"fmt"
)
type Options struct {
foo int
bar string
}