Skip to content

Instantly share code, notes, and snippets.

View glenjamin's full-sized avatar

Glen Mailer glenjamin

View GitHub Profile
@glenjamin
glenjamin / notes.md
Last active September 20, 2015 09:50
Standalone npm

Standalone npm

When using tools like n or nvm it's often a bit annoying to have the npm version continually reset to whichever was bundled with the release being switched to.

Here's an alternative: having an npm installed separately.

This is especially useful if you want to try out npm@3 neatly.

sudo mkdir /opt/npm3
@glenjamin
glenjamin / server-hot-reload.js
Created July 15, 2015 16:23
Hack way to "hot reload" when server rendering via NodeJS
// assuming that the React app is inside /client/
// clear cached client modules so next server render uses new stuff
webpack.plugin('done', function() {
Object.keys(require.cache).forEach(id => {
if (/\/client\//.test(id)) {
delete require.cache[id];
}
});
});
@glenjamin
glenjamin / users.tf.rb
Last active September 4, 2015 17:54
Terrafiddle
users = %w(
abc
def
ghi
jkl
)
def autohash
Hash.new { |h, k| h[k] = autohash }
end
@glenjamin
glenjamin / cloudstack-acceptance.sh
Created September 6, 2015 22:30
Stuff to help with running cloudstack acceptance tests against https://github.com/bvbharatk/VagrantSimulator
# Testing one section
# TF_ACC=1 go test ./builtin/providers/cloudstack -v -timeout 90m -run TestAccCloudStackLoadBalancerRule 2>&1 | tee cloudstack-acceptance.txt
# Testing all sections
# TF_ACC=1 go test ./builtin/providers/cloudstack -v -timeout 90m | tee cloudstack-acceptance-full.txt
export \
CLOUDSTACK_API_URL=http://localhost:8081/client/api \
CLOUDSTACK_API_KEY=On9yoOplojrOMV1GK587hnSKP-f4K94FxkCgeAAtnGws7lEpRTvxz9UoQCylkRhcamoWlMznPuHGCBtCtCXD9g \
CLOUDSTACK_SECRET_KEY=kKOrZ0XeuMJ-YR4p4a_2pr8JdDSSTYjodQe1CoKT2MSP5libE0iyeLmSwHH4zeKI8r6M4Fu1PVVvwwqCr_3vDA \
@glenjamin
glenjamin / .kitchen.yml
Created September 28, 2015 20:48
Systemd in a container! Useful for testing services controlled by chef
---
driver:
name: docker
provision_command:
- yum -y swap -- remove systemd-container systemd-container-libs -- install systemd
- systemctl enable sshd.service
- curl -L https://www.opscode.com/chef/install.sh | bash
require_chef_omnibus: false
run_command: /usr/sbin/init
privileged: true
@glenjamin
glenjamin / example.js
Created January 15, 2016 17:29
Record Immutable is Map
var Immutable = require('immutable');
var FooRecord = Immutable.Record({ a: 1, b: 2 }, 'foo');
Immutable.is(new FooRecord(), new Immutable.Map({a: 1, b: 2}));
// => true
@glenjamin
glenjamin / github-pages.sh
Last active February 7, 2016 21:07
Script that automatically rebuilds a github pages branch
#!/bin/sh
set -e
# !!!!
echo "*** REPLACE this with the line which builds docs"
# !!!!
echo "*** Docs built ***"
tmpdir=`mktemp -d /tmp/gh-pages-build.XXXXXX`
@glenjamin
glenjamin / index.js
Last active February 19, 2016 16:09
Get Font Styles
var getComputedStyle = require('computed-style');
var fontStyles = ['font-family', 'font-size', 'font-weight', 'font-style'];
module.exports = function getFontStyles(domElement) {
return {
element: domElement,
styles: extractFontStyles(domElement)
}
}
@glenjamin
glenjamin / elm-native-wrapper.js
Created June 10, 2016 14:32
A sketch of an approach for making it slightly easier to share elm native modules.
(function ElmNativeWrapper(name, actualNativeModule) {
var initialised = false;
window[name] = {
init: function(appname) {
// Could use Object.keys(window) here to try and detect if the name is wrong
window[munge(appname) + "$Native_" + name] = actualNativeModule();
initialised = true;
}
}
@glenjamin
glenjamin / confident-ui-dev.md
Last active June 13, 2016 10:48
Confident UI development through better feedback

Confident UI development through better feedback

Abstract

When you make a change to user-interface code, how do you know if it does what you expect? How long do you have to wait between typing some code, hitting refresh, and then seeing the result?

There are popular tools to speed up this refresh cycle, but what about user interaction or multiple component states? Even with auto-refresh or hot code reloading you'll usually still have to click on a button to check if your animations are working correctly.

I'll show you how you can get an even better level of immediate feedback from changes. One that lets you see the variety of possible states and interactions your components have all at the same time. This can vastly improve our experiences when building interactive web applications.