Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am joshcutler on github.
  • I am josh_cutler (https://keybase.io/josh_cutler) on keybase.
  • I have a public key ASCSrd4wWnjKO-7mDK2oifqvcHYZvYvnroCGAmbVZJ9G_Qo

To claim this, I am signing this object:

@joshcutler
joshcutler / Event Manager
Last active December 31, 2015 21:29
Event based JS on page load for rails App
if typeof(Object.create) != 'function'
Object.create = (o) ->
F = () -> { }
F.prototype = o
return new F()
fromPrototype = (prototype, object) ->
newObject = Object.create(prototype)
`for(prop in object)
{
@joshcutler
joshcutler / gist:6716983
Last active December 24, 2015 00:29
Filter out Political Theory emails
(subject:(Theory) arendt OR rawls -micro -microeconomic -to:cs-econ)
@joshcutler
joshcutler / linenumbers.css
Created November 1, 2012 01:37
CSS to add line numbers to embedded gists
.gist .highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist .highlight pre {
counter-reset: linenumbers;
}
.gist .highlight pre div:before {
@joshcutler
joshcutler / gist:3157465
Created July 21, 2012 22:43
create a user in postgres
sudo -u postgres createuser <username>
@joshcutler
joshcutler / git log alias
Created June 19, 2012 18:43
Prettier git logs
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@joshcutler
joshcutler / gist:2769323
Created May 22, 2012 14:11
Sample From a large file (by line)
perl -ne 'print if (rand() < .01)' large_input_file.txt > sampled_output.txt
@joshcutler
joshcutler / rookexample.R
Created December 30, 2011 20:22
Simple Rook Example
require('Rook')
library(Rook)
library(rjson)
rook = Rhttpd$new()
rook$add(
name ="summarize",
app = function(env) {
req = Rook::Request$new(env)
@joshcutler
joshcutler / rookonheroku.sh
Created December 19, 2011 23:15
Setup Rook on heroku
mkdir rookonheroku
cd rookonheroku
mkdir bin
echo "puts 'OK'" > config.ru
echo "source 'http://rubygems.org'\n gem 'rack'" &gt; Gemfile
bundle install
git init .
git add .
@joshcutler
joshcutler / gist:1363069
Created November 14, 2011 02:01
Use case of Classyfier
require 'classyfier'
@classyfier = Classyfier::NaiveBayes::NaiveBayesClassifier.new
@classyfier.train({:subject => 'Must read!', :text => 'Get Viagra cheap!'}, :spam)
@classyfier.train({:subject => 'Gotta see this', :text => 'Viagra. You can get it at cut rates'}, :spam)
@classyfier.train({:subject => 'Call me tomorrow', :text => 'We need to talk about scheduling. Call me.'}, :not_spam)
@classyfier.train({:subject => 'That was hilarious', :text => 'Just saw that link you sent me'}, :not_spam)
@classyfier.train({:subject => 'dinner at 7', :text => 'I got us a reservation tomorrow at 7'}, :not_spam)
@scores = @classyfier.classify({:subject => 'See it to believe it', :text => 'Best rates you\'ll see'})