Skip to content

Instantly share code, notes, and snippets.

View descovi's full-sized avatar
🐈
Programming with cat

Alessandro Descovi descovi

🐈
Programming with cat
View GitHub Profile
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
// extends http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/
// give you a button that toggles between two images
// uses cocos2d 0.9, so all the classes are called CCMenuItem instead of MenuItem.
// other than that it should work with older versions of cocos2d
+ (id)buttonWithImage:(NSString*)file
andImage:(NSString *)otherFile
atPosition:(CGPoint)position
target:(id)target
selector:(SEL)selector
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ecpplus
ecpplus / gist:713124
Created November 24, 2010 04:42
Cocos2d(0.99.4) - CCRepeatForever having interval.
id delaying = [CCDelayTime actionWithDuration:1.5f]; // duration is second, not millsecond.
id sequence = [CCSequence actions:someAction, delaying, nil];
CCRepeatForever *repeatAction = [CCRepeatForever actionWithAction:sequence];
[aSprite runAction:repeatAction];
@ecpplus
ecpplus / gist:713131
Created November 24, 2010 04:51
Cocos2d(0.99.4) create animation by CCSpriteSheet
CCSpriteSheet *animationSheet = [CCSpriteSheet spriteSheetWithFile:@"animation_sheet.png"];
[self addChild:animationSheet];
CCSprite *animationSprite = [CCSprite spriteWithTexture:animationSheet.texture
rect:CGRectMake(0, 0, 256, 290)];
animationSprite.position = ccp(self.contentSize.width / 2, self.contentSize.height / 2);
[animationSheet addChild:animationSprite];
CCAnimation *animation = [CCAnimation animationWithName:@"an_animation" delay:0.04f];
@fnhipster
fnhipster / html5.haml
Created April 9, 2011 01:19
HTML5 HAML Template
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
@ericsaboia
ericsaboia / gist:994614
Created May 27, 2011 03:58
Changelog ActiveRecord:Base Rails 3.1
# ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed to closer match normal Ruby dup and clone semantics.
# Calling ActiveRecord::Base#clone will result in a shallow copy of the record, including copying the frozen state. No callbacks will be called.
# Calling ActiveRecord::Base#dup will duplicate the record, including calling after initialize hooks. Frozen state will not be copied, and all associations will be cleared. A duped record will return true for new_record?, have a nil id field, and is saveable.
@jcasimir
jcasimir / friendly_urls.markdown
Created September 11, 2011 15:48
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@bjhess
bjhess / st_cheat.txt
Created January 11, 2012 21:39
Sublime Text Cheatsheet
Navigation:
cmd-p Goto Anything ('@' for functions, ':' for line number)
cmd-r Function finder
ctl-g Goto line number
cmd-sft-p Command palette
cmd-sft-f Find in Files
cmd-opt-r Toggle regex when finding
cmd-opt-# Columns
ctr-# Switch columns
@vasilisvg
vasilisvg / more.md
Last active December 4, 2020 04:48
This is my backup script which syncs my server to my dropbox every day.

The script below is triggered every day from my Mac. I use Hazel to move the tar.gz to an external hard disk once it's finished. This happens every day without me noticing. You can exclude folders if you want to. You probably want to exclude giant cache folders.

You should have a similar script.