Skip to content

Instantly share code, notes, and snippets.

View pluma's full-sized avatar
👋
Looking for projects

Alan Plum pluma

👋
Looking for projects
View GitHub Profile
@pluma
pluma / vagrant_aliases.sh
Last active December 16, 2015 22:59
Bash functions I found useful when working with multiple vagrant projects.
_vagrant_dirnames() {
if [[ $COMP_CWORD > 1 ]]; then
COMPREPLY=()
return 1
fi
local cur="${COMP_WORDS[COMP_CWORD]}"
pushd ~/vagrant/ > /dev/null
local opts=( $cur*/ )
popd > /dev/null
if [[ "$opts" == "$cur*/" ]]; then
@pluma
pluma / react-routing-dreamcode.js
Last active November 30, 2015 19:38
Dreamcode for a nested universal/isomorphic router with support for async prefetching and name-based URL generation
import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import {createHistory} from 'history';
import {Router} from '?';
import {Home, UserList, UserDetail, Admin, AdminDashboard} from './views';
import {ErrorView, NotFound, Forbidden, Login} from './views/error';
import {createStore} from './store';
// routes are defined as plain old objects
const range1 = n => Array.from(Array(n).keys());
const range2 = (off, n) => Array.from(Array(n - off).keys()).map(i => i + off);
const range3 = (off, step, n) => Array.from(Array(Math.ceil((n - off) / step)).keys()).map(i => i * step + off);
const range = (...args) => args.length === 1 ? range1(...args) : args.length === 2 ? range2(...args) : range3(...args);
const repeat = (x, n) => Array.from(Array(n)).map(() => x);
{
"swagger": "2.0",
"info": {
"description": "Enterprise Value Architect",
"version": "0.0.1",
"title": "EVA",
"license": {
"name": "inspired.org"
}
},
@pluma
pluma / knockout.tasty.js
Created July 10, 2012 07:41
Knockout->Tastypie Resource classes
define(['ko', 'q-reqwest', 'q-tils', 'aug'], function(ko, qr, qt, aug) {
"use strict";
function propertyGetter(name) {
return function(obj) {
var prop = obj[name];
return (typeof prop === 'function' ? prop.call(obj) : prop);
}
}
function propertyFilter(name, value) {

Keybase proof

I hereby claim:

  • I am pluma on github.
  • I am pluma (https://keybase.io/pluma) on keybase.
  • I have a public key whose fingerprint is 640F 5033 8989 39FE 8DEE 8619 D35D 69A8 5AB4 6833

To claim this, I am signing this object:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Tree</title>
<style id="jsbin-css">
.tree {
width: 400px;
margin: 15px 0;
}
@pluma
pluma / webapp
Created October 15, 2014 15:47
Node init.d script with naught.
#!/bin/bash
NAME=webapp
IPC=/var/run/naught/$NAME.ipc
DESC="my application server"
WORKERS=2
set -e
case "$1" in
start)
@pluma
pluma / smart-transform.js
Created September 30, 2014 18:26
Smarter version of `omit` and `pick` that can handle prop paths including wildcards and escaping (with backslash).
var wildcard = typeof Symbol === 'undefined' ? true : Symbol.for('wildcard');
function _tokenize(key) {
var tokens = [];
for (var i = 0; i < key.length; i++) {
var token = '';
if (key[i] === '*' && (i + 1 >= key.length || key[i + 1] === '.')) {
tokens.push(wildcard);
i++;
continue;