Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
@alunny
alunny / client-side-xauth.js
Created June 21, 2010 22:39
accessing twitter xAuth through client-side JS
/*****
To authorize on Twitter API through xAuth, you need HMAC-SHA1
I'm using the following lib for that:
http://jssha.sourceforge.net
Make sure you have sha.js included!
<script src="http://jssha.sourceforge.net/sha.js"></script>
Also, you need to email api@twitter.com to get xAuth access
I cannot do that for you - see http://dev.twitter.com/pages/xauth
// by way of http://dmitry.baranovskiy.com/post/typeof-and-friends
function is(o, type) {
type = String(type).toLowerCase();
return (type == "null" && o === null) ||
(type == typeof o) ||
(type == "object" && o === Object(o)) ||
(type == "array" && Array.isArray && Array.isArray(o)) ||
Object.prototype.toString.call(o).slice(8, -1).toLowerCase() == type;
}
Object.defineProperty(Object.prototype, "extend", {value: function (obj) {
obj.__proto__ = this;
return obj;
}});
Object.defineProperty(Object.prototype, "new", {value: function () {
var obj = Object.create(this);
if (obj.initialize) obj.initialize.apply(obj, arguments);
return obj;
}});
@davejohnson
davejohnson / Android-plugin-java-example
Created September 3, 2010 22:21
phonegap-android-plugin-java-example
package com.example;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
function Cache() { }
Cache.prototype.getCachedPathForURI = function(uri, success, fail) {
return PhoneGap.execAsync(function(args) {
success(uri, args.file);
}, function(args) {
fail(uri, args.message);
}, 'com.example.URLCache', 'getCachedPathForURI', [uri, 'FOO']);
};

Module Constructor

This is a proposal for the inclusion of an additional primordial variable to all ECMAScript contexts.

  • There MUST be a primordial function Module(text, fileName, lineNo)
    • text MUST be parsed the body of a strict-mode Function
    • Module MAY throw a SyntaxError
    • fileName is an optional name for the text, for debuggers
  • lineNo defaults to 1, is coerced to Number internally, and represents the line
@3rd-Eden
3rd-Eden / server.js
Created December 12, 2010 22:36
Running HTTPS and HTTP over the same route using the EventEmitter
// Include required modules
var crypto = require( "crypto" )
, http = require( "http" )
, fs = require( "fs" );
// Build our default app, just like would normally do
var app = http.createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/plain" } );
res.end( "Double http server, over http and https\n" );
});
@aaronrussell
aaronrussell / jquery.mobile.event.js
Created December 16, 2010 13:36
Slightly modified version of jQuery Mobile's event handlers so can be used standalone without the rest of the framework
/*
* jQuery Mobile Framework : events
* Copyright (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function($, undefined ) {
$.extend( $.support, {
orientation: "orientation" in window,
@topfunky
topfunky / Cakefile
Created April 14, 2011 22:18
Watch both Sass and Coffee files and compile on change (for Node.js)
###
Modified from https://github.com/jashkenas/coffee-script/blob/master/Cakefile
Part of an upcoming PeepCode screencast. This snippet is MIT Licensed.
###
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args) ->
@pmuellr
pmuellr / ApacheCon-cities.txt
Created February 21, 2012 23:27
list of ApacheCon cities
ApacheCon NA 2011 - Vancouver
ApacheCon NA 2010 - Atlanta
ApacheCon US 2009 - Oakland
ApacheCon EU 2009 - Amsterdam
ApacheCon US 2008 - New Orleans
ApacheCon EU 2008 - Amsterdam
ApacheCon US 2007 - Atlanta
ApacheCon EU 2007 - Amsterdam
ApacheCon US 2006 - Austin
ApacheCon AP 2006 - Colombo, Sri Lanka