Skip to content

Instantly share code, notes, and snippets.

View johnloy's full-sized avatar

John Loy johnloy

View GitHub Profile
@fatihacet
fatihacet / pubsub-simple.js
Created October 15, 2011 22:02
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@ttscoff
ttscoff / Quix commands for domain navigation
Created February 9, 2011 01:46
Bookmarklets for moving up or skipping to top levels of a domain, in [Quix format](http://quixapp.com/help/syntax/)
> See <http://quixapp.com/help/syntax/> for more info on Quix syntax and usage
up javascript:(function(){window.location=document.location.href.replace(/\/$/,'').split('/').slice(0,-1).join('/')+"/";})(); Move up one level in the sites directory structure
top javascript:(function(){window.location=document.location.protocol+"//"+document.location.host;})(); Jump to top level of the current site
@millenomi
millenomi / gourl.sh
Created January 14, 2011 16:23
This is a wrapper around the 'curl' command-line tool that adds a few useful features.
#!/bin/bash
if [ "$#" == "0" ]; then
echo "usage: $0 [CURL FLAGS|--json FILE|--https|--dry-run]* URL" >&2
echo "You can set the BASE_URL environment variable; if you do, all relative URLs will be have the BASE_URL appended in front of them. (Note that this appends blindly the two strings together, doing no resolution work.)" >&2
exit 1
fi
args=("$@")
verbatim_args=()