Skip to content

Instantly share code, notes, and snippets.

@drewfish
drewfish / package.json
Created March 4, 2017 22:59
marko-js/marko named single-file component
{}
cd `dirname $0`
[[ ! -l .bashrc ]] && ln -s _bashrc ~/.bashrc
... etc ...
it('for intlMessage', function () {
var tmpl = '{@intl formats=intl.formats}{@intlMessage _msg=MSG product=PRODUCT price=PRICE deadline=DEADLINE timeZone=TZ/}{/intl}',
ctx = {
MSG: '{product} cost {price, usd} (or {price, eur}) if ordered by {deadline, date, medium}',
intl: {
formats: {
eur: function(val, locale, options) {
return new intl.NumberFormat(locale, {
style: 'cur
@drewfish
drewfish / memalign.ino
Created February 3, 2014 01:51
demonstrate memory alignment on the arduino
#include <Arduino.h>
#include <stddef.h>
#define PAD0
#define PAD1 char pad0;
#define PAD2 char pad0; char pad1;
#define PAD4 char pad0; char pad1; char pad2; char pad3;
#define PAD8 char pad0; char pad1; char pad2; char pad3; char pad4; char pad5; char pad6; char pad7;
@drewfish
drewfish / messageformatter.js
Created December 4, 2013 21:51
polyfill registration for Intl.MessageFormatter strawman
(function (root, factory) {
var MessageFormatter = factory();
// register in -all- the module systems (at once)
if (typeof define === 'function' && define.amd) {
defined('IntlMessageFormatter', MessageFormatter);
}
if (typeof exports === 'object') {
module.exports = MessageFormatter;
}
if (root) {
@drewfish
drewfish / perf.js
Created November 21, 2012 00:03
cost of conditional function call
var microtime = require('microtime'),
i, iterations = 1000000,
t0, t1, base,
runFoo,
whatever = 1000000000000000,
obj = {
foo: function () {
whatever += 1;
},
run: function () {
@drewfish
drewfish / git-moo
Created August 2, 2012 23:31
"git moo" (badly named) shows the relationships between branches that exist in multiple remotes
#!/usr/bin/env perl
# Show a nice table representing the differences between
# the local repo and remotes.
#
# It is assumed that there is a direct relationship between
# the local branch names and remote branch names.
#
# TODO
# * marker for current branch
# * marker if current branch is modified