Skip to content

Instantly share code, notes, and snippets.

Avatar

Sandeep Jain sandeepjain

View GitHub Profile
@jonbretman
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
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
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@exupero
exupero / README.md
Last active Dec 18, 2020
Alias a domain to a local port (Mac)
View README.md

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 127.0.0.1 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
alex-klepa / README
Created Mar 23, 2012
MongoDB multiple instance upstart scripts: mongodb, mongod --configsvr and mongos
View README
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
p01 / LICENSE.txt
Last active Feb 1, 2021 — forked from 140bytes/LICENSE.txt
Sudoku Solver in 140bytes
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri - http://www.p01.org/releases/
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.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@OzzyCzech
OzzyCzech / FtpSync.php
Created Aug 21, 2011
Sync local files with FTP
View FtpSync.php
<?php
require_once realpath(__DIR__) . '/RecursiveFilter.php';
// can be replace with http://www.php.net/manual/en/class.recursivecallbackfilteriterator.php
// https://github.com/nette/nette/tree/master/Nette/Iterators
/**
* Copyright (c) 2011 Roman Ožana (http://omdesign.cz).
*
* @author Roman Ožana <ozana@omdesign.cz>
* @link http://omdesign.cz
View github.jquery.js
// http://aboutcode.net/2010/11/11/list-github-projects-using-javascript.html
jQuery.githubUser = function(username, callback) {
jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback);
}
jQuery.fn.loadRepositores = function(username) {
this.html("<span>Querying GitHub for repositories...</span>");
var target = this;
@fcalderan
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>
console.group("inception movie");