Skip to content

Instantly share code, notes, and snippets.

View DC3's full-sized avatar

Dee Cheung DC3

View GitHub Profile
@thsutton
thsutton / response-header.js
Created November 6, 2010 09:17
Get the value of an HTTP response header in JavaScript
/**
* Read the value of a header in the current document.
*
* This uses a [single] XMLHTTPRequest to do a HEAD of the current document
* and fetch HTTP response header values. Note that the implementation is
* rather stupid in that it spins waiting for the XMLHTTPRequest to complete
* if it hasn't been called yet.
*
* @param name string
@Gozala
Gozala / extend-array.js
Created November 7, 2010 17:10
Array subclass ES5
// No need to sub class Array if what you need is just an extended
// array. Example below illustrates the way to extend Array.
function SubArray() {
return Object.defineProperties(Array.prototype.slice.call(arguments), SubArrayDescriptor)
}
SubArray.prototype = Array.prototype
var SubArrayDescriptor =
{ constructor: { value: SubArray }
, last: { value: function last() {
@qbyt
qbyt / base64-conversion-coffeescript-compiled.js
Created January 12, 2011 15:46
A CoffeeScript port of the Javascript version by Nicholas C. Zakas(2009) - https://github.com/nzakas/computer-science-in-javascript
/*
Base 64 implementation in CoffeeScript (Compiled JS)
Converted from Base 64 implementation in JavaScript - Nicholas C. Zakas (2009)
(https://github.com/nzakas/computer-science-in-javascript)
*/
/*
Base64-encodes a string of text.
@param {String} text The text to encode.
@return {String} The base64-encoded string.
@xtian
xtian / html5boilerplate.jade
Last active December 23, 2023 15:05
HTML5 Boilerplate in jade
!!! 5
html(class='no-js')
head
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge')
title
meta(name='description', content='')
meta(name='viewport', content='width=device-width, initial-scale=1')
@scottjehl
scottjehl / hasInternets.js
Created April 28, 2011 19:16
quick check for online status with jQuery
//quick online/offline check
function hasInternets() {
var s = $.ajax({
type: "HEAD",
url: window.location.href.split("?")[0] + "?" + Math.random(),
async: false
}).status;
//thx http://www.louisremi.com/2011/04/22/navigator-online-alternative-serverreachable/
return s >= 200 && s < 300 || s === 304;
};
@eralston
eralston / DateFormat.js
Created May 12, 2011 15:52
Date Format 1.2.3 by Steven Levithan <stevenlevithan.com> - A date formatting library for JavaScript
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
@eklitzke
eklitzke / httpbench.py
Created June 15, 2011 20:16
simple tornado httpclient benchmark
import os
import optparse
import signal
import time
import tornado.httpserver
import tornado.httpclient
import tornado.simple_httpclient
import tornado.curl_httpclient
import tornado.ioloop
@nrabinowitz
nrabinowitz / quantize.js
Created July 25, 2011 17:19
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@Port3M5
Port3M5 / CoffeeUglify.sh
Created September 18, 2011 17:00
A bash script that compiles coffeescript and uglifies it. Requires node.js coffeescript and uglify-js
#!/bin/bash
function printHelp
{
echo "-h displays this page"
echo "-v displays the version information"
echo "-f compiles and minifies a single file"
echo "-d compiles and minifies all files in a directory"
echo "-i checks dependendancies and installs them if node is installed"
}
@paulirish
paulirish / data-markdown.user.js
Last active November 1, 2025 13:19
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.