Skip to content

Instantly share code, notes, and snippets.

View flipjs's full-sized avatar
:octocat:
hjkl

Felipe Apostol flipjs

:octocat:
hjkl
View GitHub Profile
@flipjs
flipjs / pojo.js
Created July 28, 2014 23:20
POJO
var pojo = function () {
var members = arguments
, ctr = 0
return function () {
var obj = {}
, i = 0
, len = members.length
ctr += 1
@flipjs
flipjs / switch-object.js
Last active August 29, 2015 14:04
Switch statement alternative using object
var classifyShape = function(shape) {
var isTriangle = function() {
console.log('A triangle is a polygon with 3 sides.')
}
var isQuadrangle = function() {
console.log('A quadrangle is a polygon with 4 sides.')
}
@flipjs
flipjs / metalsmith.js
Created July 28, 2014 22:58
Metalsmith config sample
var Metalsmith = require('metalsmith')
, markdown = require('metalsmith-markdown')
, templates = require('metalsmith-templates')
, Handlebars = require('handlebars')
, fs = require('fs')
, collections = require('metalsmith-collections')
, permalinks = require('metalsmith-permalinks')
Handlebars.registerPartial('header', fs.readFileSync(__dirname + '/templates/partials/header.hbt').toString())
Handlebars.registerPartial('footer', fs.readFileSync(__dirname + '/templates/partials/footer.hbt').toString())
@flipjs
flipjs / iife.js
Last active August 29, 2015 14:04
IIFE + Augmentation
/*
Sample IIFE + Augmentation
Here I created a module counter,
and augmented it (added reset function).
*/
var counter = (function() {
var count = 0
return {