Skip to content

Instantly share code, notes, and snippets.

View wwalser's full-sized avatar

Wesley Walser wwalser

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<style type="text/css" media="screen">
.row {
display: flex;
border: 1px solid green;
}
.column {
border: 1px solid black;
@wwalser
wwalser / minified.js
Last active April 12, 2016 01:30
non-minified vs minified
var firstVar = 1;
var secondVar = "second";
var identityFunc = firstArg => firstArg;
@wwalser
wwalser / gist:8681997
Last active January 4, 2016 21:39
Protypical inheritance
//As with all inheritance patterns, this isn't encouraged. While worth knowing and understanding,
//delegation is preferred in nearly all cases.
function Person(name) {
this.name = name;
}
Person.prototype.sayName = function(){
console.log(this.name);
}
function Ninja(name) {
@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);
}
});
@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 / 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 / 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 / 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: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 / 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)