This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var db = document.body, //shortcut to document.body | |
r = 100, //initial radius of the circle | |
x = (db.clientWidth - r) / 2, //horizontal center | |
y = (window.pageYOffset || (db.parentNode || db).scrollTop) + ((window.innerHeight+r)/2), //offset from page top | |
o = 0.0, //angle offset | |
w = 0, //width of square | |
dl = 150, //number of divs | |
ai=Math.PI / dl, //pie slice width | |
divs=Array.prototype.map.call(new Int8Array(dl),function(){ //div array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Loader = function () { } | |
Loader.prototype = { | |
require: function (scripts, callback) { | |
this.loadCount = 0; | |
this.totalRequired = scripts.length; | |
this.callback = callback; | |
for (var i = 0; i < scripts.length; i++) { | |
this.writeScript(scripts[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colorizer = require('colorizer').create('Colorizer'); | |
var casper = require('casper').create(); | |
var totalTests=3; | |
casper.start('http://jqueryui.com/resources/demos/tabs/ajax.html', function(){ | |
casper.viewport(1024, 768); | |
this.test.assertHttpStatus(200, "The page has loaded."); | |
this.test.assertSelectorExists('#tabs', "We got tabs."); | |
this.test.assertVisible('#tabs-1', "Content 1 is visible."); | |
this.capture('ui-id-1.png'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://code.google.com/p/go/issues/detail?id=4509 | |
package main | |
import ( | |
"fmt" | |
"time" | |
"math/rand" | |
) | |
var out = make(chan string, 3) | |
var done = make(chan bool) | |
func f(c chan<- string) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env phantomjs --web-security=false | |
var system = require('system') | |
, page = require('webpage').create(); | |
var address=system.args[1]; | |
if(address===undefined){ | |
console.warn("USAGE: phantomjs --web-security=false cssCheck.js <http://your-site.com/index.html>") | |
phantom.exit(); | |
} | |
page.onConsoleMessage = function (msg) {console.log(msg);}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Doubly Linked List implementation in JavaScript | |
* Copyright (c) 2009 Nicholas C. Zakas | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Array | |
([].indexOf)||(Array.prototype.indexOf=[].indexOf||function(a,b,c,r){for(c=this,b=b|0,r=-1;b++<c.length&&!~r;r=c[b]===a?b:r);return r}); | |
([].map)||(Array.prototype.map=function(a){for(var b=this,c=b.length,d=[],e=0,f;e<b;)d[e]=e in b?a.call(arguments[1],b[e],e++,b):f;return d}); | |
([].filter)||(Array.prototype.filter=[].filter||function(a,b,c,d,e){for(b=this,d=0,c=[];d<b.length;d++)if(a.call(b,e=b[d]))c.push(e);return c}); | |
([].isArray)||(Array.isArray||(Array.isArray=function(a){return{}.toString.call(a)=='[object Array]'})); | |
([].every)||(Array.prototype.every=[].every||function(a,b,c,d){for(c=0,d=this;c<d.length;c++)if(!a.call(b,d[c],c,d))return!1;return!0}); | |
([].some)||(Array.prototype.some=[].some||function(a,b,c,d){for(c=0,d=this;c<d.length;c++)if(a.call(b,d[c],c,d))return!0;return!1}); | |
([].unique)||(Array.prototype.unique=function(a){return function(){return this.filter(a)}}(function(a,b,c){return c.indexOf(a,b+1)<0})); | |
//Function | |
Function.prototype.bind=(function(){}).bind||function(a,b){b=this;re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.debounce = function (threshold, execAsap) { | |
var func = this,timeout; | |
return function debounced () { | |
var obj = this, args = arguments; | |
function delayed () { | |
if (!execAsap) func.apply(obj, args); | |
timeout = null; | |
}; | |
if (timeout) clearTimeout(timeout); | |
else if (execAsap) func.apply(obj, args); // execute now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iframe = document.getElementById('bannerContent_ifr') | |
function replaceQuotes(text){ | |
return text.replace(/(.)/g,function($1){ | |
var c=$1.charCodeAt(0), n=$1; | |
switch(c){ | |
case 8220: case 8221: | |
n='"'; | |
break; | |
case 8216: case 8217: | |
n="'"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Minimalist browser name/version parsing based on data from | |
//https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent | |
function createBrowserRegex(browser){ | |
return new RegExp('\\b('+browser+')\\/([^\\s]+)'); | |
} | |
function createBrowserTest(userAgent, positive, negatives){ | |
var matches = BROWSER_REGEX[positive].exec(userAgent); | |
negatives=negatives||[]; | |
if(matches && matches.length && !negatives.some(function(negative){return BROWSER_REGEX[negative].exec(userAgent)})){ | |
return matches.slice(1,3); |
OlderNewer