Skip to content

Instantly share code, notes, and snippets.

@samyakbhuta
samyakbhuta / games.js
Created May 27, 2011 16:25
Looking for a implementation solution for a pattern, whose name I don't know yet !!!
----------------- Formation of a game----------------------
db.games.save({
"_id" : ObjectId("4ddf595fb57f547120000002")
"pi" : "3831F237040C4BC083420EE4EC5FAE85",
"di" : "76280583D2DA4903A0336C85AA3B3DE8468E21F8",
"np" : 92,
"p1" : "n",
});
----------------- Formation of a game ends-----------------
/*
* Returns a random element in a function.
*/
var randomInArray = function (anArray){
//TODO : Check if anArray is really an array.
var randomIndex=Math.floor(Math.random()*anArray.length)
return anArray[randomIndex];
}
/*
* Returns the next element in a function.
* Automatically rotates the index to the first element, if value matched the last element.
* If no match found for value returns the first element.
*/
var nextInArray = function (value,anArray){
//TODO : Check if anArray is really an array.
var index = anArray.indexOf(value);
if ( index == anArray.length-1 || index == -1 ) {
@samyakbhuta
samyakbhuta / userUtil.js
Created May 10, 2011 17:20
_id is nor set neither returned in .save function of Model
var mongoose = require('mongoose');
var myUserModel = require("./players").playerModel;
var util = require("util");
exports.insertUser = function (pn,di,ti){
var aUserInstance = new myUserModel();
aUserInstance.pn = pn;
aUserInstance.di = di;
aUserInstance.ti = ti;
aUserInstance.ls = +new Date();
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
var a = "123";
var b = function(){};
@samyakbhuta
samyakbhuta / markdownSample.md
Created April 21, 2011 18:39
Mark down sample

Abc

Abc

###Abc### ##Abc## #Abc#

@samyakbhuta
samyakbhuta / gist:933863
Created April 21, 2011 06:34
First attempt for rap lyrics
Chorus : N P M , N P M, Everyboody say N P M,
Chorus : Pack it, Pack it, Just pack it !!
Solo : It handles dependencies,and we say it is divine !!
Solo : If you got no clue wh't hell it is, it's just fine !!
Chorus : N P M , N P M, Everyboody say N P M,
Chorus : Pack it, Pack it, Just pack it !!
-----
N P M is cool, for things it does for you !!
Noddy can't go without't, except the loo !!