Skip to content

Instantly share code, notes, and snippets.

View devdiva's full-sized avatar

Hari Khalsa devdiva

View GitHub Profile
@kureta
kureta / CMakeLists.txt
Last active October 2, 2015 15:27
openFrameworks CLion OS X CMake files
cmake_minimum_required(VERSION 2.8.4)
cmake_policy(SET CMP0042 NEW)
project(emptyExample)
set(APP_NAME emptyExample)
set(BUNDLE_NAME "emptyExample")
# ===================== oF Directory =====================
set(OF_DIRECTORY "!!!!!!!!!!! ENTER YOUT OPENFRAMEWORKS DIRECTORY !!!!!!!!!!!")
# ========================================================
@kentbrew
kentbrew / motion.html
Last active December 15, 2015 16:38
Motion demo for HTML5DevConf 2013
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Drifting Things</title>
<style>
body {
text-align: center;
@kentbrew
kentbrew / index.html
Last active December 15, 2015 15:39
Sound demo for HTMLDevConf 2013
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Sound Player</title>
<style>
body {
text-align: center;
}
@myronmarston
myronmarston / crazy_ruby_bug.md
Last active December 14, 2015 17:38
The craziest ruby bug I've ever seen. I don't understand it. At all.

I've discovered a crazy bug that's really confusing me. I'm curious to hear if anyone can explain it.

Here's some code in foo.rb:

class Superclass
  unless ENV['NORMAL_METHOD_DEF']
    define_method :regex do
      /^(\d)$/
    end
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@gka
gka / contr-comm.r
Created February 13, 2012 11:25
plots all contributions by authorized committees over time, colored by party
# you need to run https://gist.github.com/1816161 first
comm = subset(contr, form_tp=="SA18")
plot(comm$date, comm$contb_receipt_amt, log='y', col=comm$color, axes=F, xlab="", ylab="", main="Contributions by Authorized Committees (log scale)", cex=.65)
axis.POSIXct(1, las=2, at=seq(min(comm$date), as.POSIXct("2012/01/02"), by="month"), cex=0.65, cex.axis=0.65, format="%b")
options(scipen=10)
@gka
gka / contr-all.r
Created February 13, 2012 11:23
plots all contributions over time, colored by party
# load csv
contr <- read.csv("fec-contr.csv")
# convert date column to R date type
contr$date <- strptime(as.character(contr$contb_receipt_dt), "%Y-%m-%dT%H:%M:%SZ")
plot(date,contb_receipt_amt,axes=F,col=color,cex=.7,ylab="",xlab="",main="Contributions in 2011")
# add time axis
axis(2, las=2, cex.axis=0.65)
axis.POSIXct(1, las=2, at=seq(as.Date("2011/1/1"), as.Date("2012/01/01"), by="month"), cex=0.65, cex.axis=0.65, format="%b")
@gka
gka / contributions_per_candidate.r
Created February 8, 2012 13:59
Contributions per Candidate
# read csv file
ds <- read.csv('2012-Presidential-Campaign-Finance-Contributors.tsv', sep='\t')
# aggregate by candidate
res <- aggregate(ds$contb_receipt_amt, by=list(ds$cand_nm), FUN=sum, na.rm=TRUE)
X = data.frame(name=res$Group.1, amount=res$x)
# make data columns callable without typing X$ everytime
attach(X)
@nrabinowitz
nrabinowitz / quantize.js
Created July 25, 2011 17:19
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@petedickson
petedickson / sessions_controller.rb
Created March 9, 2011 15:21
Authenticate users via Infusionsoft
class SessionsController < ApplicationController
include ApiInfusionsoft
def new
end
def numeric?(object)
true if Float(object) rescue false
end