Skip to content

Instantly share code, notes, and snippets.

def foo
a = 3
{
b = something
hello(b)
}
{
c = something else
reloadRecords: function() {
SC.Request.getUrl('/yoururl').json()
.notify(this, '_didRetrieve')
.send();
},
_didRetrieve:function(response) {
if(!SC.ok(response)) {
console.log('Unable to retrieve record');
// In my appcontroller
var c = [[MainViewController alloc] init];
[[c view] setFrame:CGRectMake(0, 0, [contentView frame].size.width, [contentView frame].size.height)];
[contentView addSubview:[c view]];
// In my mainviewcontroller
SELECT *, coalesce(bool_or((select owner or write from privileges where (group_id = 2 or group_id in (select from_id from links where to_id = 2)) and target_type = 'Person' and target_id = people.id)), false) as writable FROM "people"
@kuon
kuon / test.rb
Created September 13, 2011 09:26
def get_id(m)
m.id
end
code(:super_id, :if => lambda {|m| get_id(m) == 453} ) do |m|
get_id(m)
end
has_many :medias, :dependent => :delete_all
has_one :template, :through => :medias
enumerator = self.dynamo_db_table.items.query(options)
# this enumerator returns some proxy objects and can be used like so
enumerator.each do |item|
# do something with item, convert it into real item
data = item.attributes.to_h
obj = self.new(:shard => table)
obj.send(:hydrate, id, data)
# Now do something with obj
create table nodes (int id, int parent_id);
insert into nodes (1, null);
insert into nodes (2, null);
insert into nodes (3, 1);
insert into nodes (4, 2);
insert into nodes (5, 4);
How can I do a query like this (on PostgreSQL 9.1):
┌─(~/Projects/GithubForks/cappuccino/Foundation)────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(2012-07-11 17:13:19)─(kuon@aiur)─
└─(node *)─> touch CPArray/*
┌─(~/Projects/GithubForks/cappuccino/Foundation)────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(2012-07-11 17:13:30)─(kuon@aiur)─
└─(node )─> time jake
[CPP] _CPJavaScriptArray.j
[OBJJC] _CPJavaScriptArray.j
[CPP] CPArray.j
[OBJJC] CPArray.j
[CPP] CPMutableArray.j
[OBJJC] CPMutableArray.j
@kuon
kuon / gist:3806377
Created September 30, 2012 10:01
Adding nested routes on the same controller
resources :users do
put 'parents/:parent_id', :action => 'add_parent', :as => 'parents'
delete 'parents/:parent_id', :action => 'remove_parent'
end