Skip to content

Instantly share code, notes, and snippets.

View justinrainbow's full-sized avatar

Justin Rainbow justinrainbow

View GitHub Profile
@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:2002574
Created March 8, 2012 18:38
Hipchat emoticon list
:-)
:)
:-)
:o
:$
:/
:(
:-*
:#
:'(
@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 / 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 / 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) {
#!/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
# test for the git ps1 script
declare -f __git_ps1 >/dev/null
if (( $? ))
then
PS1='[\[\033[34m\w\033[0m]\n[\t \u]\$ '
else
PS1='[\[\033[34m\w\033[0m$(__git_ps1 " (\033[0;32m%s\033[0m)")]\n[\t \u]\$ '
fi
@justinrainbow
justinrainbow / compl1.php
Created April 22, 2011 19:12 — forked from antirez/compl1.rb
Redis autocompletion - in php
<?php
# compl1.php - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
$redis = new Redis();
$redis->connect('127.0.0.1');
# Create the completion sorted set
if (!$redis->exists('compl')) {
@justinrainbow
justinrainbow / fix-smarty.php
Created April 8, 2011 19:48
Runs through a bunch of *.tpl files to update syntax from Smarty2 to Smarty3 -- no whitespace around tags
<?php
$dir = new RecursiveDirectoryIterator(dirname(__FILE__));
$iterator = new RecursiveIteratorIterator($dir);
$pattern = '~\{(.+?)\}~im';
$start_char = '{';
$end_char = '}';
@justinrainbow
justinrainbow / js_method.php
Created March 3, 2011 15:54
an effort to make using the ui js modules easier {$yui->onAvailable("#myselector")->plug("flashpanel", $cfg)}
<?php
class YuiMethod
{
protected $selector;
protected $helpers;
protected $code;
public function __construct($selector, $helper = null)
{