Skip to content

Instantly share code, notes, and snippets.

View justinrainbow's full-sized avatar

Justin Rainbow justinrainbow

View GitHub Profile
#!/usr/bin/perl
#
# Nathanial Hendler
# http://retards.org/
#
# 2001-06-26 v1.0
#
# This perl script parses a MySQL slow_queries log file
# ignoring all queries less than $min_time and prints
# out how many times a query was greater than $min_time
@justinrainbow
justinrainbow / model-router.js
Created November 18, 2011 18:55
Extension to add simple routing to a model
YUI.add('sk-gallery-model-router', function (Y) {
/* Any frequently used shortcuts, strings and constants */
var Lang = Y.Lang;
function ModelRouter(config) {
}
ModelRouter.prototype = {
getUrl: function (action) {
@justinrainbow
justinrainbow / build-yui-loader.js
Created January 23, 2012 19:03
Builds a YUI Loader config for all your custom YUI3 modules
var util = require('util'),
exec = require('child_process').exec,
modules = {},
// what to strip off the pathname (/my/dir/web becomes /web)
docroot = __dirname+'/webroot',
// where to search for YUI.add in files
path = __dirname+'/webroot/bundles',
file,
child;
@justinrainbow
justinrainbow / git-homepage
Created February 2, 2012 20:26
Add this to your path to add the 'git homepage' command to git. This will open the URL for the current git repo.
#!/usr/bin/env php
<?php
// This is incredibly ugly... but a quick script for fun
exec("git remote -v", $data);
$remotes = array();
foreach ($data as $line) {
if (preg_match('~^(\w+)\t(.+?(?:\.git)+)~', $line, $match)) {
@justinrainbow
justinrainbow / gist:2002574
Created March 8, 2012 18:38
Hipchat emoticon list
:-)
:)
:-)
:o
:$
:/
:(
:-*
:#
:'(
@justinrainbow
justinrainbow / watch.js
Created March 27, 2012 21:19
Auto building of YUI3 modules
var watch = require('watch'),
spawn = require('child_process').spawn,
queue = [],
proc;
function run(path) {
if (proc) {
return queue.push(path);
}
@justinrainbow
justinrainbow / gist:2294905
Created April 3, 2012 19:25
see all the gifs on bukk.it at once
var r=/gif$/,b=document.body,i="",h="innerHTML";b[h].replace(/href="([^"]*?)"/g,function(m,u){if(r.test(u))i+="<img src='"+u+"'>"});b[h]=i;
@justinrainbow
justinrainbow / parameters.php
Created April 4, 2012 16:38
Dynamically changing DIC parameters based on location
<?php
$ip = trim(`/usr/sbin/arp $(hostname) | awk -F'[()]' '{print $2}'`);
if (0 === strpos($ip, '192.168.100.')) {
$container->setParameter("mongodb_servers", "mongodb://mongo-home.local");
$container->setParameter("redis_dsn_primary", "redis://redis-home.local");
} else {
$container->setParameter("mongodb_servers", "mongodb://mongo-work.local");
$container->setParameter("redis_dsn_primary", "redis://redis-work.local");
YUI().use('connect-api', function (Y) {
var connect = Y.Connect.getInstance();
connect.set('baseUrl', 'http://jrainbow.dev.connect.sheknows.com');
connect.set('commands.favorites', {
url: '/me/favorites.json',
method: 'GET',
// cors: false, // disabled the CORS / Ajax requests
credentials: true, // needed for accessing User data