Skip to content

Instantly share code, notes, and snippets.

View rtgibbons's full-sized avatar

Ryan Gibbons rtgibbons

View GitHub Profile
function makeCounter() {
// `i` is only accessible inside the closure created when the
// `makeCounter` function is invoked.
var i = 0;
return function() {
console.log( ++i );
};
}
@rtgibbons
rtgibbons / balisong-gem-backports.patch
Created March 10, 2011 05:37
Including backports gem for ruby_18 platforms
diff --git a/Gemfile b/Gemfile
index ec7a4ff..e86cc9d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -10,6 +10,8 @@ gem 'mime-types', :require => 'mime/types'
gem 'rdiscount'
gem 'RedCloth'
+gem 'backports', :platforms => 'ruby_18'
+
Validate('#new_user', {
'username' : {
'minimum' : 5,
'maximum' : 20,
'presence' : true
},
'password' : {
'minimum' : 8,
'maximum' : 32,
'presence' : true
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Twitter</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="jquery.tweet.js"></script>
<script type="text/javascript" src="jquery.li-scroller.js"></script>
<script>
@rtgibbons
rtgibbons / phparray.php
Created June 1, 2011 05:36
Simple assocaitive array
<?php
var $contactTimeOptions = array(
'morning' => 'morning',
'afternoon' => 'afternoon',
'evening' => 'evening'
);
?>
@rtgibbons
rtgibbons / paulify.php
Created June 3, 2011 02:25
download random image
<?php
$files = array();
$path = 'i/s/';
if ( $dir = opendir( $path ) ) {
while ( false !== ( $file = readdir( $dir ) ) ){
switch( mime_content_type( $path.$file ) ) {
case 'image/jpeg':
case 'image/jpg':
@rtgibbons
rtgibbons / paulify.href
Created June 3, 2011 03:12
pualify bookmarklet
javascript:(function(){var d=document,j=d.getElementById('__paulify_nodes'),k=null;var files=['https://github.com/rtgibbons/Paulify/raw/master/js/paulify.js','https://github.com/rtgibbons/Paulify/raw/master/js/paulify_run.js'];if(j){paulify_add();}else{k=d.createElement('div');k.id='__paulify_nodes';d.getElementsByTagName('body')[0].appendChild(k);for(var l=0;l<files.length;l++){j=d.createElement('script');j.src=files[l];k.appendChild(j);}}})();
@rtgibbons
rtgibbons / macvim.rb
Created September 17, 2011 01:44
Alloy's MacVim (File Browser)
require 'formula'
class Macvim < Formula
homepage 'http://code.google.com/p/macvim/'
version '7.3-61'
head 'https://github.com/alloy/macvim.git', :branch => 'split-browser'
def options
[
# Building custom icons fails for many users, so off by default.
@rtgibbons
rtgibbons / mms-agent.sh
Created November 23, 2011 19:24
Centos init.d for mms-agent from 10Gen
#!/bin/bash
#
# /etc/rc.d/init.d/mms-agent
#
# 10Gen Mongod montiroing service
# must edit the settings.py first and edit this file with the location of agent.py
#
# description: 10Gen monitoring service - need ot fix pid so we can shut it down
# chkconfig: - 90 10
@rtgibbons
rtgibbons / mvim
Created November 23, 2011 20:41
mvim for vim-coca
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).