Skip to content

Instantly share code, notes, and snippets.

View wilsonpage's full-sized avatar

Wilson Page wilsonpage

View GitHub Profile
.icon-foo:before {
font-family: 'icons';
content: 'foo'
}
<span class="icon-foo"></span>
@wilsonpage
wilsonpage / umd-module.js
Last active August 19, 2016 13:18
UMD (amd, common.js, window)
;(function(define){define(function(require,exports,module){
//...
});})(typeof define=='function'&&define.amd?define
:(function(n,w){'use strict';return typeof module=='object'?function(c){
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
return w[n];},m.exports,m);w[n]=m.exports;};})('module-name',this));
@wilsonpage
wilsonpage / gist:7359744
Created November 7, 2013 18:43
Autocomplete in Git
http://ihswebdesign.com/knowledge-base/bash-completion-git-branch-in-your-prompt-yes/
@wilsonpage
wilsonpage / .profile
Last active December 27, 2015 15:19
Shell prompt with current Git branch. Add this code to a `.profile` file in your home directory for a more useful terminal prompt. You must have bash-completion installed: `$ brew install bash-completion`
function prom {
local GREEN="\[\033[0;32m\]"
local WHITE="\[\033[0m\]"
PS1="\w$GREEN\$(__git_ps1)$WHITE \$ "
}
prom
'use strict';
/**
* Module Dependencies
*/
var raf = require('../device/raf');
/**
* Locals
View.prototype.fire = function(name) {
var args = [].slice.call(arguments, 1);
var parent = this.parent;
var propagate;
var event;
if (typeof name === 'object') {
name = name.name;
event = name.event;
}
@wilsonpage
wilsonpage / parents.js
Created April 4, 2013 17:50
Loops up the parent chain until a class match is found.
function parents(el, cl) {
while ((el = el.parentNode) && !~el.className.indexOf(cl));
return el;
}
@wilsonpage
wilsonpage / failing.js
Created January 17, 2013 14:05
The first fails to add the new file to the styles file list. The second one succeeds. I believe it to be related to the component.json being retrieved more than once.
var Builder = require('component-builder');
var path = require('path');
var fs = require('fs');
var async = require('async');
var builder = new Builder(__dirname + '/../client/item-view');
builder.use(compileSass);
builder.build(function(err, res){
.module-x {
background-color: red;
}
/**
* Exposed API
*/
@mixin module-x-blue {
background-color: blue;
@wilsonpage
wilsonpage / manual-populate.js
Created May 4, 2012 08:01
How to populate model ref property after instantiation?
var commentsSchema = new Schema({
content: { type: String },
_user: { type: Schema.ObjectId, ref: 'users' },
});
//...
// Get a comment without populating