Skip to content

Instantly share code, notes, and snippets.


Sandeep Jain sandeepjain

View GitHub Profile
jonbretman / type.js
Last active Jul 31, 2018
Simple type checking in JavaScript.
View type.js
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
// handle DOM elements
prime31 / gist:5675017
Last active Feb 24, 2021
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
View gist:5675017
// API access key from Google API's Console
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
exupero /
Last active Dec 18, 2020
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure

alex-klepa / README
Created Mar 23, 2012
MongoDB multiple instance upstart scripts: mongodb, mongod --configsvr and mongos
MongoDB upstart scripts for Ubuntu.
Run following commands after installing upstart scripts:
ln -s /lib/init/upstart-job /etc/init.d/mongoconf
ln -s /lib/init/upstart-job /etc/init.d/mongodb
ln -s /lib/init/upstart-job /etc/init.d/mongos
To start services use:
p01 / LICENSE.txt
Last active Feb 1, 2021 — forked from 140bytes/LICENSE.txt
Sudoku Solver in 140bytes
View LICENSE.txt
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri -
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
OzzyCzech / FtpSync.php
Created Aug 21, 2011
Sync local files with FTP
View FtpSync.php
require_once realpath(__DIR__) . '/RecursiveFilter.php';
// can be replace with
* Copyright (c) 2011 Roman Ožana (
* @author Roman Ožana <>
* @link
View github.jquery.js
jQuery.githubUser = function(username, callback) {
jQuery.getJSON("" + username + "?callback=?", callback);
jQuery.fn.loadRepositores = function(username) {
this.html("<span>Querying GitHub for repositories...</span>");
var target = this;
fcalderan / inception-javascript.js
Created Nov 2, 2010
inception explained as a 4 nested javascript closures
View inception-javascript.js
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
* Activate javascript console =)
<script>"inception movie");