Skip to content

Instantly share code, notes, and snippets.

View sugendran's full-sized avatar

Sugendran Ganess sugendran

View GitHub Profile
@sugendran
sugendran / index.js
Last active August 29, 2015 13:55
Help file for plzxplain.com
// Welcome to plzxplain.com
// ------------------------
//
// Sometimes when you're learning JavaScript things can get
// a little confusing. This website hopes to help fix that.
// Just paste in the JavaScript that is confusing you and
// we'll convert it into a flowchart so that you can try and
// work out what's actually happening.
//
// Oh and you can load a gist using plzxplain.com/?gist=gistId
@sugendran
sugendran / binarysearch.js
Created February 1, 2014 15:09
Example code for plzxplain
// binary search function taken from http://rosettacode.org/wiki/Binary_search
function binary_search_recursive(a, value, lo, hi) {
if (hi < lo)
return null;
var mid = Math.floor((lo+hi)/2);
if (a[mid] > value)
return binary_search_recursive(a, value, lo, mid-1);
else if (a[mid] < value)
return binary_search_recursive(a, value, mid+1, hi);
else
/*
* Yes this CSS is ugly, but it's a demo
* about canvas and not styling html+css.
*/
html, body {
background: black;
color: white;
font-family: monospace;
margin: 0;
@sugendran
sugendran / keybase.md
Created October 15, 2014 15:48
keybase.md

Keybase proof

I hereby claim:

  • I am sugendran on github.
  • I am sugendran (https://keybase.io/sugendran) on keybase.
  • I have a public key whose fingerprint is D3B1 FA86 D98B 978E 463C 7FD8 822B F48E AD45 57C9

To claim this, I am signing this object:

@sugendran
sugendran / parse_apple_data.js
Created December 2, 2014 08:41
Node app to read apple financial data and combine them into a single tab separated file
// Assumes all apple data is tab seperated and in the current directory
var fs = require('fs');
var path = require('path');
var cwd = process.cwd();
var contents = fs.readdirSync(cwd);
var _headers = [];
var _data = [];
function parseHeaders (cols) {
@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"