Skip to content

Instantly share code, notes, and snippets.

View zhuzhuaicoding's full-sized avatar

zhuzhu_coder zhuzhuaicoding

View GitHub Profile
@zhuzhuaicoding
zhuzhuaicoding / gist:1433092
Created December 5, 2011 10:04 — forked from elijahmanor/gist:589968
Use === and !==
// Use === and !==
// It is often better to use the === and !== operators
// rather than == and != operators. The reason for this
// is that === and !== (also known as the identity operators)
// check for the type as well as the value when being compared
// whereas the == and != will try to coerce the two values
// into the same type before the comparison is made, which
// may lead to some very unexpected results.
@zhuzhuaicoding
zhuzhuaicoding / gist:1433097
Created December 5, 2011 10:07 — forked from elijahmanor/gist:590041
Prevent Default Behavior
// Prevent Default Behavior
// 'return false' stops the default behavior of the event
// and prevents it from bubbling up DOM, which kills
// event delegation and may not be what you indented.
// You might consider using e.preventDefault() or
// e.stopPropagation() instead
//event.preventDefault()
//Event Delegation Friendly
@zhuzhuaicoding
zhuzhuaicoding / jquery.ba-tinypubsub.js
Created March 2, 2012 23:15 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@zhuzhuaicoding
zhuzhuaicoding / feedback.md
Created March 26, 2012 10:19
Feedback to "Async Javascript"

HI Trevor Burnham:

I'm a reader of your Async JavaScript book, I bought it on 23rd March and finished it on 26rd March, it is really a treasure to me, probably the best book about async programming in JavaScript I have ever read.

After finished this book, I found there are a few problems, as well as a set of my questions, exists, so I wrote this mail to you, expecting you could give a brief look.

Since I'm not a native English speaker, my English is really poor, so if there is any ambiguousness, please feedback to me so I could have a change to state it more clearly.

Fist of all, I would like to list 9 problems I found in this book, most of which are produced by the difference between our perspectives, so feel free is you don't think they are problems.

@zhuzhuaicoding
zhuzhuaicoding / LICENSE.txt
Created August 28, 2012 01:55 — forked from jed/LICENSE.txt
use anchor tags to parse URLs into components
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@zhuzhuaicoding
zhuzhuaicoding / position-fixed.css
Created October 27, 2012 01:18 — forked from subtleGradient/position-fixed.css
Make position:fixed work in IE6
/*Make position:fixed work in IE6!*/
.fixed-top /* position fixed Top */{position:fixed;bottom:auto;top:0;}
.fixed-bottom /* position fixed Bottom */{position:fixed;bottom:0;top:auto;}
.fixed-left /* position fixed Left */{position:fixed;right:auto;left:0;}
.fixed-right /* position fixed right */{position:fixed;right:0;left:auto;}
* html,* html body /* IE6 Fixed Position Jitter Fix */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-top /* IE6 position fixed Top */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}
* html .fixed-right /* IE6 position fixed right */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));}
@zhuzhuaicoding
zhuzhuaicoding / semaphore.js
Created October 30, 2012 14:43 — forked from ricardobeat/semaphore.js
simple semaphore for parallel async execution, with error handling.
function queue(name){
queue.q[name]++ || (queue.q[name] = 1);
return function(err){
if (err && queue.e[name]) queue.e[name](err);
else if (err) throw err;
process.nextTick(function(){
queue.q[name]--;
queue.check(name);
});
}
<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<title>Test fullscreen</title>
<style>
html, body {
margin: 0;
padding: 0;
function getGroupCallBackGenerator(timeOut,finalCallback){
var waitingStatus={};
var resultObject={};
var started=false;
var timedOut=false;
var timer=setTimeout(function(){
timedOut=true;
if(typeof(finalCallback)=="function"){
finalCallback(resultObject);
}
(function(window,undefined){
// Prepare our Variables
var
document = window.document,
$ = window.jQuery;
// Wait for Document
$(window).bind(function(){
// Prepare Variables