start new:
tmux
start new with session name:
tmux new -s myname
| // 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]; | |
| 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 |
| -(void)disableReturnKey{ | |
| // Locate non-UIWindow. | |
| UIWindow *keyboardWindow = nil; | |
| for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { | |
| if (![[testWindow class] isEqual:[UIWindow class]]) { | |
| keyboardWindow = testWindow; | |
| break; | |
| } | |
| } | |
| after "deploy:stop", "clockwork:stop" | |
| after "deploy:start", "clockwork:start" | |
| after "deploy:restart", "clockwork:restart" | |
| namespace :clockwork do | |
| desc "Stop clockwork" | |
| task :stop, :roles => clockwork_roles, :on_error => :continue, :on_no_matching_servers => :continue do | |
| run "if [ -d #{current_path} ] && [ -f #{pid_file} ]; then cd #{current_path} && kill -INT `cat #{pid | |
| _file}` ; fi" | |
| end |
| // from: http://deusty.blogspot.com/2007/07/gzip-compressiondecompression.html | |
| - (NSData *)gzipInflate | |
| { | |
| if ([self length] == 0) return self; | |
| unsigned full_length = [self length]; | |
| unsigned half_length = [self length] / 2; | |
| NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; |
| NSURL *a = [NSURL URLWithString:@"http://google.com/oliver.html"]; | |
| NSURL *b = [NSURL URLWithString:@"oliver.html" relativeToURL:[NSURL URLWithString:@"http://google.com"]]; | |
| if([a isEqual:b]) { | |
| NSLog(@"Same"); // Not run | |
| } | |
| if([[a absoluteURL] isEqual:[b absoluteURL]]) { | |
| NSLog(@"Same"); // Still not run | |
| } |
| @interface HorizontallyPagingCollectionViewFlowLayout : UICollectionViewFlowLayout | |
| @end | |
| @implementation HorizontallyPagingCollectionViewFlowLayout | |
| - (CGSize) collectionViewContentSize | |
| { | |
| CGSize superSize = [super collectionViewContentSize]; | |
| CGSize frameSize = self.collectionView.frame.size; |
| #import "CustomTabBarViewController.h" | |
| @interface CustomTabBarViewController () | |
| @property (nonatomic, assign) BOOL buttonsExpanded; | |
| @end | |
| @implementation CustomTabBarViewController | |
| -(void) addCenterButtonWithImage:(UIImage*)buttonImage highlightImage:(UIImage*)highlightImage | |
| { |
| sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \; |