Skip to content

Instantly share code, notes, and snippets.

View iest's full-sized avatar

Iestyn Williams iest

View GitHub Profile
@iest
iest / chrome.js
Created February 9, 2015 12:10
Copy all values from iamthefold.com with Chrome
// 1. Load iamthefold.com on Google Chrome
// 2. Open devtools (cmd-option-J on a mac)
// 3. Paste the code below into the console
copy(Array.prototype.slice.call(document.querySelectorAll('li')).map(function(elm){return elm.textContent}))
// 4. Now paste into your favourite text editor!
@iest
iest / gulpfile.js
Created April 28, 2015 11:27
Markdown loader failing with react-hot-loader?
gulp.task('hotreload', function() {
require('./hotLoadServer');
});
export function AnimateMixinFactory(stateName) {
var animateMixin = {
getInitialState() {
return {
[stateName]: {}
}
}
};
@iest
iest / README.md
Last active August 11, 2022 09:20
Setting up environment variables with various shells

What the hell are environment variables?

They're just variables you set on your system that various programs/processes can read. A fairly standard example in javascript circles would be setting your NODE_ENV variable to "production" or "development", altering how node code is executed on your system (for example showing more debug messaging when in development).

With most shells there's a way to set them for the current session, and a way to set them for all sessions. The following is meant to be a guide on how to set env vars in the various shells.

Bash (The default shell on OSX)

Setting for the session:

@iest
iest / CSS-on-beta-pact.md
Last active August 29, 2015 14:27
A draft of a post about topnotes' CSS

TODO:

  • Tools used
    • Webpack
    • CSS modules
    • postcss + plugins used
  • Why it's magic
    • No namespace issues
    • Composability
  • Component-specific styles
render() {
const isSmallScreen = window.matchMedia('(max-width: 30em)').matches;
return (
isSmallScreen ?
<p>This will only render if the window is smaller than 30em</p>
:
<p>This will only render if the window is 30em or more<p>
);
}
@iest
iest / HSBChtml2YNABCSV.js
Last active August 31, 2015 11:25
HSBC don't let customers download CSVs of transaction prior to 2 months ago. With a little node, we can do it
'use strict';
const moment = require('moment')
const jsdom = require('jsdom');
const fs = require('fs');
const FILE_NAME = process.argv[2] || './May-Jun.html';
jsdom.env(
fs.readFileSync(FILE_NAME).toString(),
@iest
iest / config.js
Last active November 25, 2015 10:43
Potential config...
import {canUseDOM} from 'exenv';
function getWhitelistedVars(global) {
return Object.keys(global).reduce((obj, key) => {
if (defaults.hasOwnProperty(key)) {
obj[key] = global[key];
}
return obj;
}, {});
}
'use strict';
require('babel/register'); // transform required modules
const fs = require('fs');
const path = require('path');
const jade = require('jade');
const React = require('react');
const debug = require('debug');
const Helmet = require('react-helmet');
const find = require('lodash/collection').find;
const Provider = require('react-redux').Provider;
@iest
iest / mToKm-test.js
Last active July 28, 2016 08:22
Tape
import test from 'tape';
import { mToKm } from '../distance-util';
test('mToKm', (assert) => {
assert.equal(typeof(mToKm(1000)), 'string', 'outputs a string');
assert.equal(mToKm(1000), '1.0', 'converts meters to kilometers');
assert.equal(mToKm(1200), '1.2', 'formatted to 1 decimal place');
assert.equal(mToKm(1299), '1.3', 'rounded up correctly');
assert.equal(mToKm(1240), '1.2', 'rounded down correctly');