Skip to content

Instantly share code, notes, and snippets.

@abhiomkar
abhiomkar / youtube-downloadr-oneliner.py
Created May 12, 2010 13:50
One-liner to download youtube video in Python
# Author: Abhinay Omkar
# Title: One-liner to download youtube video in Python
from urllib import urlopen, unquote; from urlparse import parse_qs, urlparse; youtube_watchurl="http://www.youtube.com/watch?v=NeSuirvA6UE&playnext_from=TL&videos=MS3Hq4oBj08"; video_id = parse_qs(urlparse(youtube_watchurl).query)['v'][0]; open(video_id+'.mp4', 'wb').write(urlopen("http://www.youtube.com/get_video?video_id=%s&t=%s&fmt=18"%(video_id, parse_qs(unquote(urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read().decode('utf-8')))['token'][0])).read())
@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')
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@alexeckermann
alexeckermann / MyViewController_excerpt.m
Created August 19, 2011 05:48
How to access the previous UIViewController from a pushed UIViewController your about to close
- (void)closeThisViewController {
// Lets retain an instance of the current navigation controller
UINavigationController *navController = [self.navigationController retain];
// When this is called self.navigationController is no longer available
[self.navigationController popViewControllerAnimated: YES];
// To talk to that previous VC here's what you do
[[navController topViewController] doSomethingHere:YES];
# Author: Abhinay Omkar
# Youtube Downloader
import sys
from urllib import urlopen, unquote
from urlparse import parse_qs, urlparse
youtube_watchurl = sys.argv[1]
url_query = urlparse(youtube_watchurl).query
video_id = parse_qs(url_query)['v'][0]
url_data = urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read()
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
@terhechte
terhechte / slow_kvo_dictionary_example1.m
Created December 7, 2011 20:17
Example 1 of slow and fast NSDictionary access
//
// slow_kvo_dictionary_example.m
//
// Created by Benedikt Terhechte on 07.12.11.
// appventure.me
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
@zeedark
zeedark / gist:1639124
Created January 19, 2012 09:55
Resize a UIButton according to its title's length.
// Resize a UIButton according to its title's length.
CGSize stringSize = [self.myButton.titleLabel.text sizeWithFont:self.myButton.titleLabel.font];
CGRect frame = self.myButton.frame;
frame.size.width = stringSize.width;
[self.myButton setFrame:frame];