Skip to content

Instantly share code, notes, and snippets.

View vinothbabu's full-sized avatar
🤘

Thalaivar vinothbabu

🤘
  • Chennai, TamilNadu
View GitHub Profile
@vinothbabu
vinothbabu / searchable and sortable data structure - Plugin NodeJS
Created August 10, 2012 13:37
searchable and sortable data structure - Using NodeJS
//sortable-2d-array.js
exports = module.exports = sortable2DArray;
function sortable2DArray(data) {
this.data = data;
}
sortable2DArray.prototype.sortBy = function (o) {
var fields = o.fields || [];
@vinothbabu
vinothbabu / Sorting JSON response based on type
Created August 10, 2012 13:49
Sorting JSON response based on type
<script type="text/javascript">
onerror = function (a, b, c) {
alert([a, b, c]);
};
</script>
<script type="text/javascript">
var x = {
"JsonResult": {
"List": [{
"Subject": "My book report on J. K. Rowling's <u>Harry Potter</u> series.",
@vinothbabu
vinothbabu / Puzzle
Created September 3, 2012 16:06
Puzzle Game - Titanium and JavaScript
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>15 Puzzle</title>
<style type="text/css">
body{color:black;background:white;font-family:Arial,Helvetica,sans-serif;font-size:20px;margin:0;}
table tr td{text-align:center;}
@vinothbabu
vinothbabu / HTTPClient
Last active October 10, 2015 01:27
Generic HTTPClient or Ajax Class which only creates a single instance.
var JSONCall = function(url,data, onLoad, onError){
this.url = url;
this.data = data;
this.onLoad = onLoad;
this.onError = onError;
};
JSONCall.prototype = {
call: function(){
if(typeof JsonClient==='undefined'){
JsonClient = Titanium.Network.createHTTPClient();
@vinothbabu
vinothbabu / gist:3610375
Created September 3, 2012 16:11
call a private function from a string in javascript
var valdiate = (function() {
var _p={};//toss all private members into a single object.
_p.list=[];
_p.init=function(){
_p.list=[];
};
var noDigits = function() {
@vinothbabu
vinothbabu / gist:3666340
Created September 7, 2012 13:40
Capture picture using Titanium
function capturePictureDialog(opts) {
var dialogCallback = (typeof opts.callback == "undefined") ? new Function("") : opts.callback;
function cropImageBlob(image, cropRect) {
var h = image.height;
var w = image.width;
var toH = cropRect.height;
if (toH > h) {
toH = h;
@vinothbabu
vinothbabu / gist:3691041
Created September 10, 2012 13:50
Capture picture and Scribbling using Titanium
function capturePictureDialog(opts)
{
var dialogCallback=(typeof opts.callback=="undefined")?new Function(""):opts.callback;
var scribblingEnabled=(typeof opts.scribbling=="undefined")?false:opts.scribbling;
if(scribblingEnabled)
{
Titanium.Paint = require('ti.paint');
Ti.Paint = Titanium.Paint;
@vinothbabu
vinothbabu / MeemoryClean.js
Created October 16, 2012 09:38
Memory Cleaning for Application developed using Appcelerator Titanium
var MemoryClean = function() {
var _window;
/*
Here we make our "auto-release" pool. It's simply a window.
We hide it upon creation so it won't interfere with our view hierarchy.
5/3/2011: It seems that the window does not need to be a subcontext, just a regular window will do.
*/
this.init = function() {
//_window = Ti.UI.createWindow();
@vinothbabu
vinothbabu / BinarySearchTree.js
Last active December 17, 2015 00:11
BinarySearchTree
function BinarySearchTree() {
this._root = null;
}
BinarySearchTree.prototype = {
constructor: BinarySearchTree,
add: function (value) {
@vinothbabu
vinothbabu / CreditCardValidator.js
Last active December 17, 2015 00:39
Luhn algorithm - JavaScript implementation
function CreditCardValidator() {
}
CreditCardValidator.prototype = {
isValid: function (identifier) {
var num,
sum = 0,
alt;
var myRegxp = /^([0-9]){13,19}$/;