Skip to content

Instantly share code, notes, and snippets.

Shubham Jain shubhamjain

Block or report user

Report or block shubhamjain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shubhamjain
shubhamjain / formula.js
Created Apr 12, 2019
Google Sheets custom formula to check for primality
View formula.js
/**
* @customfunction
*/
function ISPRIME(number) {
for (var i = 2; i <= Math.sqrt (number); i++) {
if(number % i === 0) {
return false;
}
}
@shubhamjain
shubhamjain / social.js
Created May 18, 2016
Social Share Tracking With GA
View social.js
// Track Facebook Likes
var fbCallback = function() {
FB.Event.subscribe('edge.create', function(targetUrl) {
ga('send', 'social', 'facebook', 'like', targetUrl);
});
}
if( window.fbAsyncInit ) {
fbCallback();
} else {
window.fbAsyncInit = fbCallback;
@shubhamjain
shubhamjain / SMQT.js
Created Jul 2, 2014
Successive Mean Quantization Transform
View SMQT.js
function addUp(a, b, c)
{
catArr = b.concat(c);
for(i = 0; i < catArr.length ; i++)
a[i] += catArr[i];
return a;
}
@shubhamjain
shubhamjain / IndianCities.json
Created Jun 30, 2014
Indian States and their Cities
View IndianCities.json
{
"AP":[
"Adilabad",
"Anantapur",
"Chittoor",
"Kakinada",
"Guntur",
"Hyderabad",
"Karimnagar",
"Khammam",
@shubhamjain
shubhamjain / IndianStates.json
Created Jun 30, 2014
Indian States and Union Territories in JSON format
View IndianStates.json
{
"AP":"Andhra Pradesh",
"AR":"Arunachal Pradesh",
"AS":"Assam",
"BR":"Bihar",
"CG":"Chhattisgarh",
"Chandigarh":"Chandigarh",
"DN":"Dadra and Nagar Haveli",
"DD":"Daman and Diu",
"DL":"Delhi",
@shubhamjain
shubhamjain / vlc_http
Created Mar 27, 2014
Library to use VLC HTTP interface in python
View vlc_http
"""Module to use VLC HTTP interface
@author Shubham Jain <shubham.jain.1@gmail.com>
@license MIT License
VLC provides an HTTP interface (by default disabled) at 127.0.0.1:8080.
I have written some basic functions to work on the interface.
Example:
@shubhamjain
shubhamjain / Human readable time format in Javascript.
Last active Aug 29, 2015
This function takes milliseconds as input and converts it into human readable form. Useful in showing time elapsed or ETA.
View Human readable time format in Javascript.
/**
* This function takes milliseconds as input and converts it into "D H M S ms" format.
*
* @author Shubham Jain <shubham.jain.1@gmail.com>
* @license MIT License
*/
function timeFormat( miliseconds )
{
formatArr = {
"d": 24 * 60 * 60 * 1000,
View gist:5993531

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@shubhamjain
shubhamjain / Binary File reader in PHP
Last active Apr 15, 2017
This class is a better replacement for PHP unpack(). Unlike unpack, which creates a very large associative array, this class reads data in blocks defined by a map. Additionally blocks of Dynamic size can also be used with special constants.
View Binary File reader in PHP
<?php
/**
* A simple class to read variable byte length binary data.
* This is basically is a better replacement for unpack() function
* which creates a very large associative array.
*
* @author Shubham Jain <shubham.jain.1@gmail.com>
* @example https://github.com/shubhamjain/PHP-ID3
* @license MIT License
You can’t perform that action at this time.