Skip to content

Instantly share code, notes, and snippets.

View skinofstars's full-sized avatar

Kevin Carmody skinofstars

View GitHub Profile
@skinofstars
skinofstars / gist:5965234
Created July 10, 2013 10:27
source highlight
svn diff | source-highlight --out-format=esc --src-lang=diff
@skinofstars
skinofstars / watch.sh
Last active December 18, 2015 03:49
Watch files for changes and perform an action. Needs inotify-tools.
#!/bin/bash
# Watch files for changes and perform an action.
# Needs inotify-tools.
function doAction {
./copy-admin-templates.sh;
xdotool search --name chrome key --window %@ F5;
}
@skinofstars
skinofstars / couchdb_curl_tricks.md
Last active December 21, 2016 22:08
CouchDB notes
@skinofstars
skinofstars / gist:5060017
Last active December 14, 2015 08:48
WiRC CRC table
// example body
var buf = new Buffer(9);
// start of frame
buf[0] = '0xAA';
buf[1] = '0xBB';
// message to send - crc is based on this
var msg = ['0x01', '0x03', '0x00', '0x00', '0x01'];
@skinofstars
skinofstars / gist:5024842
Last active December 14, 2015 03:59
JS Patterns notes

cache array vars

for loops will calculate the comparison length every time, so...

for (var i = 0, max = foo.length; i < max; i++) {
  // do something
}

parseInt()

@skinofstars
skinofstars / gist:5012393
Last active December 14, 2015 02:19
Simulate Ubuntu RamDisk structure in Squeeze
mkdir -p /run/shm
sudo mount -t tmpfs -o size=1024M tmpfs /run/shm

or more permanently in /etc/fstab

tmpfs           /run/shm        tmpfs   size=1g         0       0
@skinofstars
skinofstars / gist:4654952
Created January 28, 2013 11:59
Just the a quick knock-up to add monolog to a class. You could just instantiate the logger in the function you're debugging, but this makes it easier to bounce around the class.
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
class foo extends bar
{
private $log = null;
public function __construct($swiftmailer, $service_container)
@skinofstars
skinofstars / gist:4228780
Created December 6, 2012 21:46
Yet more Mayan calendar fun
## known date of 1st jan 2000
# baktun = "13"
# katun = "20"
# tun = "7"
# uinal = "16"
# kin = "3"
## target date to find - should return 22 March 2001
baktun = "13"
katun = "20"
@skinofstars
skinofstars / gist:4217271
Created December 5, 2012 16:43
Count DOM injections
var insertCount = 0;
document.addEventListener("DOMNodeInserted", function( e ) {
insertCount++;
console.log(insertCount);
}, false);
@skinofstars
skinofstars / gist:4207221
Created December 4, 2012 18:29
Whitespace python for loop - for when you don't want to use split( )
entry = input("Enter a Mayan date: ")
i=0 # this is used to track our position in the string
output = "" # start with output set to nothing
while entry[i:]:
# if we hit a space, then we've got to the end of that number
# print it out and reset the output
if entry[i] == " ":
print (output)