Skip to content

Instantly share code, notes, and snippets.

View skw's full-sized avatar

Shaun Wong skw

  • GitHub Staff
  • Calgary, AB
View GitHub Profile
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 21, 2024 01:20
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
var
camera,
scene,
renderer;
function initialize() {
var
grass,
meshCanvas,
plane,
@ded
ded / app.html
Created June 29, 2011 04:09
ender CLI example
<script src="ender.min.js"></script>
<script>
$.require('/js/core.min.js', 'core')
$.ready('core', function () {
$(document).ready(function () {
$('<p>hello world</p>').appendTo('body')
.bind('click', function (e) {
$.require('/js/ajax.min.js', function () {
@robflaherty
robflaherty / gist:1129871
Created August 6, 2011 23:14
CoffeeScript and Stylus watch/build cakefile
# CoffeeScript and Stylus watch/build cakefile
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args...) ->
proc = spawn name, args
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.stdout.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) -> process.exit(1) if status isnt 0
@zenlor
zenlor / Backbone.reqwest.js
Created September 21, 2011 14:39
Backbone.js Sync method for reqwest.js and Ender.js
(function (reqwest, Backbone) {
var methodMap, getUrl;
methodMap = {
'create': 'POST',
'update': 'PUT',
'delete': 'DELETE',
'read' : 'GET'
};
getUrl = function(object) {
@berzniz
berzniz / gist:2900905
Created June 9, 2012 13:01
handlebars3
Handlebars.getTemplate = function(name) {
if (Handlebars.templates === undefined || Handlebars.templates[name] === undefined) {
$.ajax({
url : 'templatesfolder/' + name + '.handlebars',
success : function(data) {
if (Handlebars.templates === undefined) {
Handlebars.templates = {};
}
Handlebars.templates[name] = Handlebars.compile(data);
},
@clux
clux / jeesh.js
Created December 4, 2012 08:25
jeesh commonjs wrapper
var domready = require('domready')
, bean = require('bean') // events
, bonzo = require('bonzo') // DOM wrapper/manipulation
, request = require('superagent/superagent')
, qwery = require('qwery') // css selectors
, slice = Array.prototype.slice;
// Attach events API to the prototype of DOM wrapper:
var aug = {};
['on', 'off', 'one', 'add', 'fire', 'clone'].forEach(function (k) {
@tj
tj / git aliases.sh
Last active January 14, 2024 10:37
Some helpful git aliases
alias gd="git diff"
alias gc="git clone"
alias ga="git add"
alias gbd="git branch -D"
alias gst="git status"
alias gca="git commit -a -m"
alias gpt="git push --tags"
alias gp="git push"
alias gpr="git pull-request"
alias grh="git reset --hard"
var express = require('express');
var app = express();
var port = process.env.PORT || 5000;
var request = require('request');
var zlib = require('zlib');