Skip to content

Instantly share code, notes, and snippets.

View doowb's full-sized avatar
:octocat:
Creating something awesome!

Brian Woodward doowb

:octocat:
Creating something awesome!
View GitHub Profile
@doowb
doowb / radius.js
Created May 30, 2014 19:09
Radius from Area
var radius = function (area) {
// make the area bigger so we get better values for small areas
area = area * 10000;
// a = PI*r^2 => a/PI = r^2 => sqrt(a/PI) = r
return Math.ceil(Math.sqrt(area/Math.PI));
};
var r = radius(21000);
var d = r*2;
@doowb
doowb / example.html
Created May 26, 2014 23:42
Calling a namespaced Handlebars helper with / in the name.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script type="text/x-handlebars" id="tmpl">
@doowb
doowb / Gruntfile.js
Created May 24, 2014 01:11
Loading page data from json files and dynamically building page objects to pass into Assemble options.
'use strict';
var _ = require('lodash');
var path = require('path');
module.exports = function(grunt) {
// load the recipe template from the desired path
var recipeTemplate = grunt.file.read('./src/templates/pages/recipe.hbs');
// expand the data files and loop over each filepath
@doowb
doowb / 01-build-site.js
Last active August 29, 2015 14:01
Assemble workflow
var Assemble = require('assemble');
var Permalinks = require('assemble-permalinks');
var siteConfig = {
options: {
assets: '_gh_pages/public/',
layout: 'default',
ext: '.html',
},
src: 'src/templates/pages/*.hbs',
@doowb
doowb / assemble.js
Last active August 29, 2015 14:01
Assemble context (config, options, data, front matter, pages, partials, layouts, etc...)
var normalize = require('normalize-config');
var plasma = require('plasma');
var _ = require('lodash');
function Assemble (config) {
// normalize the config object
this.config = normalize(config);
// store a reference to the config options on assemble
module.exports = function (assemble) {
var plugin = function (params, next) {
// do something
next();
};
plugin.options = {
event: 'page:before:render'
};
return {
@doowb
doowb / namespaced.js
Last active August 29, 2015 13:58
nested data
var data = [
{
'Sellside.foo': ['path/to/foo-data.json'],
'Sellside.bar': ['path/to/bar-data.json']
}
];
var results = {
Sellside: {
foo: { /* foo-data.json */ },
@doowb
doowb / keybase.md
Created March 28, 2014 17:37
keybase.md

Keybase proof

I hereby claim:

  • I am doowb on github.
  • I am doowb (https://keybase.io/doowb) on keybase.
  • I have a public key whose fingerprint is 6A11 A0F5 F69C A7E8 8FAE 178E 928A A2F2 AB9B EF4B

To claim this, I am signing this object:

@doowb
doowb / find.js
Created March 27, 2014 01:18
Finding the first valid file from a collection of files using findup-sync and koalas
const findup = require('findup-sync');
const koalas = require('koalas');
module.exports = function (search, paths) {
var find = function (path) {
return findup(search, {cwd: path, nocase: true});
};
return koalas.apply(null, paths).use(find).value();
};
@doowb
doowb / helpers.js
Created March 19, 2014 20:05
Example of setting up expected api from environments using helpers.
var expects = function(config, spec) {
for(var k in spec) {
if (config[k] === 'undefined') {
config[k] = spec[k];
}
}
};
var spec = {