Skip to content

Instantly share code, notes, and snippets.

View sandeepjain's full-sized avatar

Sandeep sandeepjain

View GitHub Profile
// 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 November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* 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");
@sasha-id
sasha-id / README
Created March 23, 2012 15:03
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:
@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
@p01
p01 / LICENSE.txt
Last active March 9, 2024 13:40 — forked from 140bytes/LICENSE.txt
Sudoku Solver in 140bytes
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
@exupero
exupero / README.md
Last active March 29, 2024 21:10
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 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. pfctl seems to work.)

@prime31
prime31 / gist:5675017
Last active April 2, 2024 03:55
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
<?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