Skip to content

Instantly share code, notes, and snippets.

🥑
ArangoDB

Alan Plum pluma

🥑
ArangoDB
Block or report user

Report or block pluma

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pluma
pluma / knockout.tasty.js
Created Jul 10, 2012
Knockout->Tastypie Resource classes
View knockout.tasty.js
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) {
@pluma
pluma / vagrant_aliases.sh
Last active Dec 16, 2015
Bash functions I found useful when working with multiple vagrant projects.
View vagrant_aliases.sh
_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
View xmldicts.py
from lxml import etree
def node_from_dict(tag, data=None):
node = etree.Element(tag)
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, list):
for v in value:
node.append(node_from_dict(key, v))
@pluma
pluma / golem.js
Last active Dec 26, 2015
ES-harmony multiple inheritance.
View golem.js
require('harmony-reflect');
var uniq = require('uniq');
var arrp = Array.prototype;
function merge(obj, src) {
Object.keys(src).forEach(function(name) {
var value = src[name];
if (obj.hasOwnProperty(name)) {
merge(obj[name], value);
} else {
@pluma
pluma / delegating.js
Last active Dec 26, 2015
Slate-like object property delegation. With appologies to Sorella on FreeNode ##javascript.
View delegating.js
require('harmony-reflect');
var uniq = require('uniq');
var arrp = Array.prototype;
function ext(obj) {
var sources = arrp.slice.call(arguments, 1);
sources.forEach(function(src) {
src && Object.keys(src).forEach(function(name) {
obj[name] = src[name];
});
@pluma
pluma / node-stability.md
Last active Jan 4, 2016
Node stability index badges using buckler.repl.ca
View node-stability.md
[![stability 0 - deprecated](http://b.repl.ca/v1/stability-0_--_deprecated-red.png)
](http://nodejs.org/api/documentation.html#documentation_stability_index)

stability 0 - deprecated

View bl-explained.js
var DuplexStream = require('readable-stream').Duplex,
// A duplex stream is a combination of a read stream and a write stream
// For more on streams see http://nodeschool.io/#stream-adventure
util = require('util')
// The "util" module contains several node core utilities.
// In this case we're just using its inheritance helpers.
// See http://nodejs.org/api/util.html for API docs.
function BufferList(callback) {
// In JavaScript it is common to indicate that a function is a constructor by
@pluma
pluma / smart-transform.js
Created Sep 30, 2014
Smarter version of `omit` and `pick` that can handle prop paths including wildcards and escaping (with backslash).
View smart-transform.js
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;
@pluma
pluma / webapp
Created Oct 15, 2014
Node init.d script with naught.
View webapp
#!/bin/bash
NAME=webapp
IPC=/var/run/naught/$NAME.ipc
DESC="my application server"
WORKERS=2
set -e
case "$1" in
start)
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Tree</title>
<style id="jsbin-css">
.tree {
width: 400px;
margin: 15px 0;
}
You can’t perform that action at this time.