Skip to content

Instantly share code, notes, and snippets.

View sandeep45's full-sized avatar

Sandeep Arneja sandeep45

View GitHub Profile
@sandeep45
sandeep45 / TestPage3.html
Created October 20, 2014 13:40
For Jay to experiment
<!DOCTYPE html>
<html>
<head>
<title>a</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
(function() {
var fks = document.createElement('script');
fks.type = 'text/javascript';
fks.async = true;
class MessageDetail
include ActiveModel::Validations
attr_accessor :body, :length
validates :body, presence: true, length: { minimum: 1 }
validates :length, presence: true, :numericality => {:greater_than => 0}
def initialize(body,length)
@sandeep45
sandeep45 / firefoxShowIssue.html
Created August 12, 2013 14:23
Firefox Issue with not honoring show() on an element inside an iframe when the iframe itself hidden
<html>
<head>
<style>
#bla{
display: none
}
</style>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(function(){
@sandeep45
sandeep45 / weighted_average.html
Created August 2, 2013 17:47
create random number with weighted average
<html>
<head>
<script>
// give number between 1 and 100
function getRandomNumber(){
return Math.floor(Math.random()*100)+1
}
// ** config starts **//
@sandeep45
sandeep45 / stepExample.js
Created June 24, 2012 18:49
Me Playing with step.js
var step = require("step");
var color = require("colors");
/*
* A fake task which prints the message sent.
* It take upto 2 seconds to do the print.
* After printing it will call the callback.
*/
var task = function(msg,cb){
console.info(("starting task - " + msg).green);
@sandeep45
sandeep45 / mongoose1.js
Created June 23, 2012 18:57
error while accessing object retrieved from mongodb using mongoose
// mongoose1.js
// Store a json object with a schema less property
// then retrieve them
var mongoose = require('/Users/sarneja/projects/node/node_modules/mongoose/index.js');
var colors = require("/Users/sarneja/projects/node/node_modules/colors/colors");
console.info("mongoose loaded: " + mongoose);
@sandeep45
sandeep45 / dog.js
Created June 19, 2012 17:25
example of inheriting EventEmitter in node
var emitter = require('events').EventEmitter;
var util = require('util');
var dog = function(){};
dog.prototype = {
name: "i am a dog",
};
// 1st way of inheriting
//dog.prototype.__proto__ = new emitter();
@sandeep45
sandeep45 / NumberPhrase.rb
Created March 30, 2012 04:01
highlight phrase in phone number
def make_phone_number_fancy(number='6615133257', str='DEALs')
puts " in TwilioHelper. got " + number.to_s
number.include? "+1"
number.gsub! "+1", ""
str.downcase!
kp = {}
kp["a"]="2"