Skip to content

Instantly share code, notes, and snippets.

View sugendran's full-sized avatar

Sugendran Ganess sugendran

View GitHub Profile
@sugendran
sugendran / gist:2004939
Created March 9, 2012 03:57
get a remote server to add the github hash to the knownhosts
ssh #MACHINE NAME HERE# "ssh -oStrictHostKeyChecking=no -T git@github.com"
@sugendran
sugendran / gist:2822025
Created May 29, 2012 01:18
dump the last million rows from the db table
mysqldump -uroot -p 1_default data --single-transaction --where='id > (select max(id)-1000000 from data)' > 1_default_data.sql
@sugendran
sugendran / underscore.bfind.js
Created May 29, 2012 23:47
Add a binary find to underscorejs
// Binary find in a sorted array
// val can either be a value or a function that returns
// 1 == found, -1 for obj is less than val, 1 for obj is greater than val
_.bfind = function(array, val) {
if (!array.length) {
return null;
}
var iterator = _.isFunction(val) ? val : function(obj) {
return obj == val ? 0 : (obj < val ? -1 : 1);
};
@sugendran
sugendran / gist:3291911
Created August 8, 2012 03:52
TableView Shortcut - ARC
#pragma mark UITableViewDelegate
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark -
#pragma mark UITableViewDataSource
@sugendran
sugendran / thesong.sh
Created August 29, 2012 07:09
Awesome song
yes "this is the song that doesn't end it goes on and on my friend, some people started singing and they continue singing just because"
@sugendran
sugendran / gist:4056604
Created November 11, 2012 22:51
Fade between view controllers in the UINavigationController
// will use a fade transition for the next push or pop on the view controllers stack
-(void) setNavigationTransition
{
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
}
@sugendran
sugendran / gist:4634031
Created January 25, 2013 12:21
sugendran.net
[0,7,5,10,4,15,2,13,4,16,4,10,1].map(function(a){return this[a];},typeof("")+typeof(0)+NaN+"d.").join("")
@sugendran
sugendran / gist:4739011
Created February 8, 2013 13:20
Create a git remote in your dropbox folder
cd ~/Dropbox
mkdir -p git/proj1
cd git/proj1
git init --bare
@sugendran
sugendran / gist:4773412
Created February 12, 2013 21:08
CREATE UUID in Objective-C with ARC
// CREATE UUID in Objective-C with ARC
NSString* createUUID()
{
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidStr = CFUUIDCreateString(kCFAllocatorDefault, uuid);
NSString *result = [NSString stringWithString:(__bridge NSString*)uuidStr];
CFRelease(uuid);
CFRelease(uuidStr);
return result;
@sugendran
sugendran / gist:4974828
Created February 18, 2013 02:42
build and uplaod to test flight
#!/bin/sh
# A script to build your iOS app and send it to test flight
# Distributed on an as is and I accept no responsiblity for what it does licence
# For more info: http://www.abandonedexpression.com/2011/06/continuous-integration-with-xcode.html
# I'm assuming that your project is in the src directory of your repository
PROJECT_DIRECTORY="${PWD}/src"
# The target we're building
TARGET_NAME="My Project"
# The name for the .app and .ipa files that get created