Skip to content

Instantly share code, notes, and snippets.

@zackd
zackd / yui-trim.js
Created November 30, 2011 18:20
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
if (!String.prototype.trim) {
String.prototype.trim = function () {
try {
return this.replace(/^\s+|\s+$/g, "");
} catch(e) {
return this;
}
};
}
@zackd
zackd / test_number-expected.html
Created January 31, 2011 13:22
test proves IE array.sort unreliable
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
</head>
<body>
<!-- source: http://www.zachleat.com/web/2010/02/24/array-sort/ -->
<!-- The Fix: Don’t reuse the argument variables inside of an Array sort function:
/* Changing the above example
@zackd
zackd / jslint-config-for-qunit.js
Created January 25, 2011 14:44
jslint config for QUnit tests
/** JSLINT CONFIG */
/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true */
/*global window: false, document: false, $: false, log: false, bleep: false,
// QUnit vars
QUnit: false,
test: false,
asyncTest: false,
expect: false,
module: false,
ok: false,
@zackd
zackd / nodeserver4.js
Created January 8, 2011 12:53
simple twitter stream [working!]
/*
* simple static fileserver + twitter feed
*/
var sys = require("sys"),
http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
events = require("events"),
/**
* @fileOverview some javascript boilerplate to provide enhancements to old browsers
* @author zack @ m-og.eu
*/
/**
* JSLINT CONFIG
*/
/*jslint white: false, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true */
/*global window: false, document: false, log: false */
<html>
<head>
<!--
just download PURE and drop this file the 'tutorial' directory
- http://beebole.com/pure/
-->
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
@zackd
zackd / ol_zoom_slider2.html
Created May 12, 2010 10:07
improved: custom zoom control panel for openLayers (no pan controls)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>openLayers</title>
<style>
html,body {
height: 99%;
width: 99%;
}
@zackd
zackd / ol_zoom_slider.html
Created May 11, 2010 18:01
custom zoom control panel for openLayers (no pan controls)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>openLayers</title>
<style>
html,body {
height: 99%;
width: 99%;
}
// cross-browser width and height functions
function f_clientWidth() {
return f_filterResults (
window.innerWidth ? window.innerWidth : 0,
document.documentElement ? document.documentElement.clientWidth : 0,
document.body ? document.body.clientWidth : 0
);
}
function f_clientHeight() {
return f_filterResults (
@zackd
zackd / galleria.onimage.click.js
Created March 9, 2010 19:21
galleria - handle just one image
// is a fix for this bug : http://code.google.com/p/galleria/issues/detail?id=62
onImage : function(image,caption,thumb) {
// fetch the thumbnail container
var _li = thumb.parents('li');
// count items
var n = parseInt(_li.siblings().length);
if (typeof n == 'undefined' || n == 0) {