Skip to content

Instantly share code, notes, and snippets.

View csquared's full-sized avatar

Chris Continanza csquared

  • ex-stripe, ex-coinbase, ex-heroku
  • Brooklyn, NY
View GitHub Profile
@csquared
csquared / dataAttr.jquery.js
Created January 7, 2011 17:29
Getting javascript objects back from a #to_json call
jQuery.fn.dataAttr = function(data_attr_name) {
var data = eval('(' + this.attr("data-" + data_attr_name) + ')')
return data || {}
}
@csquared
csquared / test.clj
Created September 14, 2011 07:46
This isn't really clojure
(if-i-had-this-method
(and-this-one)
(i would-pass in data))
@csquared
csquared / test.js
Created September 15, 2011 07:21
Node.js sample
/* This is some sample Javascript */
function hello_world(event){
event.stopPropagation();
}
@csquared
csquared / hello_world.java
Created September 15, 2011 07:24
Java is fun
/* JAVAAAA */
class HelloWorld {
public static void main(String[] args){
System.out.println("Hello, world!");
}
}
@csquared
csquared / Gemfile
Created September 23, 2011 21:57
please do this when you require ruby-debug in your Gemfile
group :development do
gem 'ruby-debug', :platform => :mri_18
gem 'ruby-debug19', :platform => :mri_19
end
@csquared
csquared / building-an-addon.md
Created October 4, 2011 09:10
Austin.rb Talk Overview

Building An Addon - Top Down/Bottom up

In this talk we'll take a look at how to build a Heroku Add-On from the top down and bottom up. We'll start by going over the general design and strategy of how an add-on works. We will then see how the the kensa gem allows you to test a local add-on you can develop in any language, like Ruby. Bring your laptop and you'll walk away with a working prototype in Sinatra.

Chris is a current member of the Heroku Add-ons team and loves a good pull request.

@csquared
csquared / inject_vs_readability.rb
Created December 16, 2011 08:34 — forked from bbwharris/inject_vs_readability.rb
Inject vs. Readability
# inject is cool and elegant. I use it when I want to be cool. However, I tend to robotically begin the procedural
# way and end up at inject when I realize I am in that situation. See this simple example:
include ActionView::Helpers
class Link < Struct.new(:title, :url); end
a = Link.new("Google", "http://www.google.com")
b = Link.new("Hacker News", "http://news.ycombinator.com")
array_of_links = [a, b]
@csquared
csquared / serializes_json.rb
Created February 2, 2012 20:27
Serializes JSON
# serialize :field, Hash
# got you down?
# serializes_json :field
# to the rescue!
class ActiveRecord::Base
def self.serializes_json *args
args.each do |field_name|
eval <<-RUBY
def #{field_name}=(other)
@csquared
csquared / build-psql.sh
Created September 21, 2012 01:14
Anvil Build Recipe for psql 9.2.0
#!/bin/sh
root=$(pwd)
cd $root/postgresql-*
./configure --prefix=/app/vendor --with-openssl
make && make install
rm -rf $root/*
mv /app/vendor/* $root/
# Here's the script I use from my local machine to build the psql binary and libpq
@csquared
csquared / test.coffee
Created September 21, 2012 02:05
Simple Coffeescript Bootstrap test with vows and api-easy
APIEasy = require('api-easy')
assert = require('assert')
process.env.NODE_DEBUG = true
process.env.NODE_ENV = 'test'
process.env.PORT = 8080
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL
app = require('../app')
suite = APIEasy.describe("api")