Skip to content

Instantly share code, notes, and snippets.

Avatar

Sugendran Ganess sugendran

View GitHub Profile
@sugendran
sugendran / mkgraphics.js
Last active Mar 28, 2017
For NativeScript - Process all images from a source folder and creates suitably sized images in the app's target folder
View mkgraphics.js
// based around the setup in https://www.npmjs.com/package/nativescript-media-generator
// all %s come from it
// npm install imagemagick async
// update the source and target paths
// then run node mkgraphics.js
// It should put correctly sized images in the right folders
var im = require('imagemagick');
var fs = require("fs");
var path = require("path");
@sugendran
sugendran / parse_apple_data.js
Created Dec 2, 2014
Node app to read apple financial data and combine them into a single tab separated file
View parse_apple_data.js
// 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) {
View 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:

View jsbin.pokij.css
/*
* 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 / binarysearch.js
Created Feb 1, 2014
Example code for plzxplain
View binarysearch.js
// 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
@sugendran
sugendran / index.js
Last active Aug 29, 2015
Help file for plzxplain.com
View index.js
// 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
View asciiwriter.js
(function (text) {
var canvas = document.createElement("canvas");
canvas.width = 600;
canvas.height = 100;
var ctx = canvas.getContext("2d");
ctx.font = "28px monospace";
ctx.textBaseline = "top";
ctx.textAlign = "start";
var w = Math.ceil(ctx.measureText(text).width) + 2;
var h = 45;
@sugendran
sugendran / gist:4974828
Created Feb 18, 2013
build and uplaod to test flight
View gist:4974828
#!/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
@sugendran
sugendran / gist:4773412
Created Feb 12, 2013
CREATE UUID in Objective-C with ARC
View gist:4773412
// 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:4739011
Created Feb 8, 2013
Create a git remote in your dropbox folder
View gist:4739011
cd ~/Dropbox
mkdir -p git/proj1
cd git/proj1
git init --bare