start new:
tmux
start new with session name:
tmux new -s myname
-(void)disableReturnKey{ | |
// Locate non-UIWindow. | |
UIWindow *keyboardWindow = nil; | |
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { | |
if (![[testWindow class] isEqual:[UIWindow class]]) { | |
keyboardWindow = testWindow; | |
break; | |
} | |
} | |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
def facebook | |
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user) | |
if @user.persisted? | |
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" | |
sign_in_and_redirect @user, :event => :authentication | |
else | |
session["devise.facebook_data"] = request.env["omniauth.auth"] | |
redirect_to new_user_registration_url |
// I had a need to replace the use of RegexKitLite's arrayOfCaptureComponentsMatchedByRegex with | |
// the built-in NSRegularExpression in iOS 5+, and didn't find an existing example, so I wrote one: | |
- (NSArray *) arrayOfCaptureComponentsOfString:(NSString *)data matchedByRegex:(NSString *)regex | |
{ | |
NSError *error = NULL; | |
NSRegularExpression *regExpression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionCaseInsensitive error:&error]; | |
NSMutableArray *test = [NSMutableArray array]; | |
// 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]; |
// | |
// 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[]) |
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: |
# 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() |
- (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]; |