Skip to content

Instantly share code, notes, and snippets.

View skinofstars's full-sized avatar

Kevin Carmody skinofstars

View GitHub Profile
@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: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: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: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: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 / couchdb_curl_tricks.md
Last active December 21, 2016 22:08
CouchDB notes
@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 / gist:5965234
Created July 10, 2013 10:27
source highlight
svn diff | source-highlight --out-format=esc --src-lang=diff
@skinofstars
skinofstars / sub-domains
Created September 18, 2013 15:02
sub domains in apache VirtualHost
<VirtualHost *:80>
ServerName foo.kevin.dev
ServerAlias foo.local.dev
ServerAlias foo.local.test
DocumentRoot /home/kevin/projects/foo/web/
<Directory /home/kevin/projects/foo/web/>
Options Indexes FollowSymLinks MultiViews
# pcw AllowOverride None
AllowOverride All
@skinofstars
skinofstars / gist:6714637
Last active December 24, 2015 00:09
deploy cold override for db migrations
namespace :deploy do
desc "Override deploy:cold to include database setup"
task :cold do
before :run_migrations do
capifony_pretty_print "--> Creating database"
run "#{release_path}/app/console mygreatdbcommand:database:create-once"
capifony_puts_ok
end