Skip to content

Instantly share code, notes, and snippets.

View wwalser's full-sized avatar

Wesley Walser wwalser

View GitHub Profile
/**
* This is the simplest form of the use case. This fails because the first start()'s async bit kicks in before
* the second call to start() even though the semaphore is at 1 it will call process().
*/
test("test synchronous calls to stop", 2, function() {
stop();
setTimeout(function(){
ok(true, 'first');
start();
stop();
var genDelims = "[:\\/\\?#\\[\\]@]";
var subDelims = "[!\\$&'\\(\\)\\*\\+,;=]";
//do the \\s have to be there? I didn't think anything carried special meaning (had to be escaped) besides ]
var foo = /^.*?(((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)$/i
foo.test("studio-first" thinking in product teams. Incentive scheme needed and other stuff")
@wwalser
wwalser / modern.theme.bash
Created October 12, 2011 00:09
bashit diff
diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash
index 3efe9ff..a2e3577 100644
--- a/themes/modern/modern.theme.bash
+++ b/themes/modern/modern.theme.bash
@@ -41,10 +41,10 @@ prompt() {
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
- PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell)
+ PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\w${normal}][$(battery_charge)]$(is_vim_shell)
@wwalser
wwalser / gist:1998488
Created March 8, 2012 03:45
function scope closures implicit declaration
//these three are the same
function foo() {
var wes = 'wes';
var peter = 'peter';
}
function foo() {
var wes, peter;
wes = 'wes';
peter = 'peter';
@wwalser
wwalser / gist:2167931
Created March 23, 2012 07:24
Of ninjas and superheroes made mortal again.
console = {}
console.log = (what) ->
alert what
class Person
constructor : (@name) ->
sayName : ->
console.log this.name
getName: ->
this.name
@wwalser
wwalser / gist:2718412
Created May 17, 2012 11:58
Cross browser setImmediate speed tests
/**
* Minified https://github.com/NobleJS/setImmediate
*/
(function(a,h){function i(){if(!a.postMessage||a.importScripts)return!1;var b=!0,f=a.onmessage;a.onmessage=function(){b=!1};a.postMessage("","*");a.onmessage=f;return b}function j(b){b.setImmediate=a.msSetImmediate;b.clearImmediate=a.msClearImmediate}function k(b){b.setImmediate=function(){var b=c.addFromSetImmediateArguments(arguments),d=new a.MessageChannel;d.port1.onmessage=function(){c.runIfPresent(b)};d.port2.postMessage(null);return b}}function l(b){function f(b){b.source===a&&("string"===typeof b.data&& b.data.substring(0,d.length)===d)&&(b=b.data.substring(d.length),c.runIfPresent(b))}var d="com.bn.NobleJS.setImmediate"+Math.random();a.addEventListener?a.addEventListener("message",f,!1):a.attachEvent("onmessage",f);b.setImmediate=function(){var b=c.addFromSetImmediateArguments(arguments);a.postMessage(d+b,"*");return b}}function m(b){b.setImmediate=function(){var b=c.addFromSetImmediateArguments(arguments),a=document.createElement("script");a
@wwalser
wwalser / addNewLayout.js
Created August 16, 2012 07:00
Add New Page Layouts To Confluence
/**
* Hard coded! Nah, we put our smart pants on the day we wrote page layouts. We even gave
* external developers a way to create new layouts.
*
* Layouts are algorithmically generated based on a JSON string in the layout toolbar.
* On an edit page, use your Javascript foo to find #rte-button-pagelayout in the DOM
* then check out the hidden toolbar just below it and you'll find the JSON I'm
* talking about.
*
* We expose an editor command though which you can add new layouts and provide
@wwalser
wwalser / LA to NC.js
Created October 15, 2012 04:11
plane loops
//I wrote this on a plane from LA to NC because I had no internet connection and was bored
//It's not useful
if (typeof window === 'undefined') {
var window = global;
}
function each(array, fun){
var length = array.length,
i = 0;
for (; i < length; i++){
@wwalser
wwalser / gist:5537529
Created May 8, 2013 01:24
$ event system to custom namespace
/**
* Add jQuery event system to `customNamespace` namespace.
*/
(function(){
var eventBus = $({});
$.each(['bind', 'unbind', 'trigger'], function(i, current){
customNamespace[current] = function(){
return eventBus[current].apply(eventBus, arguments);
}
});