Skip to content

Instantly share code, notes, and snippets.

@twalker
twalker / set-on-fire.js
Created May 13, 2016 02:37
set-on-fire.js
#!/usr/bin/env node
'use strict';
if (process.argv.length <= 2) {
process.stdout.write(`Usage: node ./emojize.js <outputPath>\n`);
process.exit(-1);
}
const path = require('path');
const inPath = path.resolve(process.argv[2]);
@twalker
twalker / cli-intl-example.js
Created April 13, 2016 04:45
cli-intl-example.js
// global.Intl = require('intl');
// global.Intl.__applyLocaleSensitivePrototypes();
// Intl.NumberFormat = IntlPolyfill.NumberFormat;
// Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
// IntlPolyfill.__applyLocaleSensitivePrototypes();
var IntlPolyfill = require('intl');
Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
@twalker
twalker / intl-node-protoype-example.js
Last active April 13, 2016 03:08
Repro example for needing to Polyfill Date/Number prototypes in node.
var express = require('express');
var app = express();
if (global.Intl) {
// `Intl` exists, but it doesn't have the data we need, so load the
// polyfill and patch the constructors we need with the polyfill's.
var IntlPolyfill = require('intl');
Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
@twalker
twalker / config.js
Created October 15, 2015 17:20
a fetch abstraction for RESTful calls to a single api
/**
* minimal configuration object.
*/
import assign from 'object-assign'
// default configuration is based on the hostname.
const cfg = {
'localhost': {
// mocks
baseApiUrl: '//localhost:3001/api/'
@twalker
twalker / minimal-env-config.js
Created June 14, 2015 22:34
minimal-env-config.js
export default {
'localhost': {
baseApiUrl: 'http://localhost:3001/api/'
},
'mytestserver.com': {
baseApiUrl: 'http://mytestapi.com/'
},
'myprod.com': {
baseApiUrl: 'http://myprod.api/'
}
@twalker
twalker / cp.js
Created April 4, 2015 22:19
cp.js
#!/usr/bin/env node
/*
An OS-agnostic file/dir copy (cp).
// copy a single file to a new location
./cp.js foo/existing.txt foo/newname.txt
// copy contents of a directory into another
./cp.js foo/ bar/
*/
@twalker
twalker / count-by-filetype.sh
Created February 12, 2015 03:19
count-by-filetype.sh
find . -type f | sed 's/.*\.//' | sort | uniq -c
@twalker
twalker / read-template
Last active August 29, 2015 14:14
read-template
// using stringify
// import foo from './foo.html'
// using brfs:
// var foo = require('fs').readFileSync('foo.html', 'utf8')
import fs from 'fs'
export default function read(path){
return fs.readFileSync(path, 'utf8')
}
@twalker
twalker / post-deploy-replace-urls.sh
Created January 23, 2015 01:07
post-deploy-replace-urls.sh
#!/bin/sh
# tbe source directory
# i.e. dev -- //sta-vs-wfmedia1/media/tbe/
SRC_DIR="$HOME/projects/Wordfly/Website/tms/nodeapp/test/file-fixtures/tbe"
# tbe destination parent directory
# i.e. staging/prod -- NEED PATH
DEST_DIR="$HOME/tmp"
echo "Copying tbe directory into destination"
@twalker
twalker / kuatos-hack.md
Last active August 29, 2015 14:13
A hack to toggle the visibility of different email content in different email clients.

Kuato's hack

The purpose of Kuato's hack is to show either :~) email content, or :~( email content, depending on the email client. MS Outlook 2007, 2010, 2013, and Outlook.com are targeted to see the :~( content. All other email clients see the :~) content.

The following email client quirks are strategically composed:

  • MS Outlook 2007, 2010, 2013 parse and adhere to mso conditional comments.