Skip to content

Instantly share code, notes, and snippets.

View paulcnichols's full-sized avatar

Paul C. Nichols paulcnichols

View GitHub Profile

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
/**
* requestAnimationFrame polyfill by Erik Möller & Paul Irish et. al.
* https://gist.github.com/1866474
*
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
**/
/*jshint asi: false, browser: true, curly: true, eqeqeq: true, forin: false, newcap: true, noempty: true, strict: true, undef: true */
@paulcnichols
paulcnichols / gist:8994575
Created February 14, 2014 02:04
Grammar file for pegjs to parse query expression in the form: strVar="asdf", numVar>=2314
// Generate the parser either by pasting this grammar into
// http://pegjs.majda.cz/online or using the node.js pegjs
// parser. Set the generated class to "aviParser".
//
{
function clearNode() {
this.node = null;
};
/**
* @overview
*
* @author Caesar Chi
* @blog clonn.blogspot.com
* @version 2012/02/27
@paulcnichols
paulcnichols / gist:8393280
Created January 13, 2014 01:35
A jquery plugin to create a flanel shirt looking background. Original I was using taupes as the color, but then I moved to more pastels. Hence, the name taupeify().
(function ($) {
var globalArgs = {
minWidth: 150,
minHeight: 150,
}
var colorIndex = 0;
var taupeifyRec = function (args) {
var x = .5*args.width, //(Math.random()*.50 + .25)*args.width,
y = .5*args.height, //(Math.random()*.50 + .25)*args.height,
c = ["#546172", "#87A581", "#C0BD86", "#D6C08F", "#DA6A44", "#324152", "#47535E", "#796466", "#C1836A", "#DEA677"];
@paulcnichols
paulcnichols / chmeow
Created October 31, 2012 20:01
chmeow - an alias for our .bashrc replace all stopwords with 'meow' in a text file or stdin
alias chmeow="perl -e 'my \$s=\"a,able,about,across,after,all,almost,also,am,among,an,and,any,are,as,at,be,because,been,but,by,can,cannot,could,dear,did,do,does,either,else,ever,every,for,from,get,got,had,has,have,he,her,hers,him,his,how,however,i,if,in,into,is,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off,often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,than,that,the,their,them,then,there,these,they,this,tis,to,too,twas,us,wants,was,we,were,what,when,where,which,while,who,whom,why,will,with,would,yet,you,your\"; \$s =~ s/,/|/g; my \$fh; if (\$ARGV[0]) { open \$fh, \$ARGV[0] or exit; } else { \$fh = *STDIN; } while (<\$fh>) { s/\s+(\$s)\s+/ meow /ig; print }'"
@paulcnichols
paulcnichols / gist:3778634
Created September 24, 2012 21:48
Sample python firehose client
import urllib2
import json
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, 'https://stream.twitter.com/1/statuses/sample.json', '<user>', '<password>')
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
try:
conn = opener.open('https://stream.twitter.com/1/statuses/sample.json')
except urllib2.HTTPError, exception:
@paulcnichols
paulcnichols / lda.py
Created September 24, 2012 17:58
LDA topic modeling using python's gensim.
from gensim import corpora, models, similarities, utils
import logging
import os
import re
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
class DirectoryCorpus(corpora.TextCorpus):
def get_texts(self):