Jasdeep Khalsa jasdeepkhalsa

View checkType.js
1 2 3 4 5 6 7 8 9 10
function checkType(obj)
{
var type = Object.prototype.toString.call(obj);
switch(type)
{
case '[object Number]':
return 'number';
case '[object String]':
return 'string';
case '[object Boolean]':
View cleaning-up-special-characters.sql
1 2 3 4 5 6 7 8 9 10
update scriptures set search = replace(search,'॥','');
update scriptures set search = replace(search,'ਉ','ੳ');
update scriptures set search = replace(search,'ਊ','ੳ');
update scriptures set search = replace(search,'ਓ','ੳ');
update scriptures set search = replace(search,'ਔ','ਅ');
update scriptures set search = replace(search,'ਐ','ਅ');
update scriptures set search = replace(search,'ਆ','ਅ');
update scriptures set search = replace(search,'ਏ','ੲ');
update scriptures set search = replace(search,'ਈ','ੲ');
update scriptures set search = replace(search,'ਇ','ੲ');
View facade.js
1 2 3 4 5 6 7 8 9 10
var module = (function() {
 
var _private = {
i:5,
get : function() {
console.log( "current value:" + this.i);
},
set : function( val ) {
this.i = val;
},
View git-update.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
# Just change the FILES path below to the parent directory of where all your git repos reside
FILES=/dir/to/code/*
for f in $FILES
do
if [ -d $f ] && [ -d $f/.git ]
then
echo "Processing Git repository, $f"
cd $f
git --git-dir="$f/.git" pull -q
View split_testing.js
1 2 3 4 5 6 7 8 9
var rand = Math.floor((Math.random()*10)+1);
if(rand >= 3)
{
a_80();
}
else
{
b_20();
}
View exportjson.js
1 2 3 4 5 6 7 8 9
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
 
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
 
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
View tweet-counter-hourly.js
1 2 3 4 5 6 7 8 9 10
var today = new Date(); // By default brings backs tweets only in the last hour. Or just use new Date('Fri Jul 05 13:35:22 +0000 2013'), with a fixed cut off time, to have tweets within the specified time-frame only
// If you do not want the hourly window to change (otherwise "today" will become a moving target of tweets in the last hour each time tweet counter runs, then please put this line at the top of the file, inside the .ready function as follows:
// $(document).ready(function(){ var today = new Date(); })
// Making sure that the variable is defined outside of the var tweetCounter function
 
// Lets go through each tweet
for (obj in data.statuses) {
 
var tw_result = data.statuses[obj]; // This is the tweet
var tw_unique_id = tw_result.id_str; // This is the id of the tweet
View pre-commit
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/php
<?php
$projectName = basename(getcwd());
exec('phpunit', $output, $returnCode); // Assuming cwd here
if ($returnCode !== 0) {
$minimalTestSummary = array_pop($output);
printf("Test suite for %s failed: ", $projectName);
printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL);
return false; // exit(1);
}
View jquery.center.js
1 2 3 4 5 6 7 8 9 10
jQuery.fn.center = function() {
this.css({
'position': 'fixed',
'left': '50%',
'top': '50%'
});
this.css({
'margin-left': -this.outerWidth() / 2 + 'px',
'margin-top': -this.outerHeight() / 2 + 'px'
});
View eachAsync.js
1 2 3 4 5 6 7 8 9 10
function eachAsync(collection, iterator, callback) {
var iterate = function(i) {
setTimeout(function() {
iterator(collection[i]);
if (i < collection.length) {
iterate(i + 1);
} else {
callback();
}
}, 0);
Something went wrong with that request. Please try again.