Skip to content

Instantly share code, notes, and snippets.

function f() {}
f.prototype.a = 1
// f.prototype.a is 1
x = Object.create(f)
// x.prototype.a is 1
x.prototype.a = 2
// both x.prototype.a and f.prototype.a are 2
# == Schema Information
# Schema version: 20101109221104
#
# Table name: users
#
# id :integer not null, primary key
# first_name :string(255)
# last_name :string(255)
# email :string(255)
# poker_site :string(255)
class Followship < ActiveRecord::Base
attr_accessible :followed_id
belongs_to :follower, :class_name => "User"
belongs_to :followed, :class_name => "User"
validates :follower_id, :presence => true
validates :followed_id, :presence => true
end
@evanrmurphy
evanrmurphy / firsttime.arc
Created December 6, 2010 05:01
One of akkartik's favorite macros (see http://arclanguage.org/item?id=12889)
(mac firsttime(place . body)
`(unless ,place
,@body
(set ,place)))
(def foo ()
(prn "hello world!"))
(function () {
alert("hello world!");
}();
@evanrmurphy
evanrmurphy / gist:735729
Created December 10, 2010 03:40
Access the Chip Chirp API with JSONP
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>
$(function(){
$.getJSON("http://chipchirp.heroku.com/chirps/?callback=?",
function(data) {
console.log(data);
});
@evanrmurphy
evanrmurphy / gist:750448
Created December 21, 2010 19:40
Simple HTML/jQuery snippet to query the chirps feed using JSONP
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>
$(function(){
$.getJSON(
"http://chipchirp.heroku.com/chirps.json?callback=?",
function(data) {
console.log(data);
$.getJSON("http://chipchirp.heroku.com/chirps.json?callback=?&user_id[]=1",
function(data){
for(i=0;i<2;i++)
console.log(data[i].chirp.content);
});
@evanrmurphy
evanrmurphy / person.js
Created December 28, 2010 09:23
somewhat more readable than the compiled output
personUpdateSternness = (function() {
return ((this.laughter==0) ? this.sternness=true
: (this.laughter>5) ? this.sternness=null
: null),
this.sternness;
}),
personUpdateLaughter = (function() {
return (!this.sternness ? (this.laughter += 10)
: (--this.laughter,