Skip to content

Instantly share code, notes, and snippets.

View callumacrae's full-sized avatar

Callum Macrae callumacrae

View GitHub Profile
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach(async ({ page }) => {
await page.goto('https://demo.playwright.dev/todomvc');
});
const TODO_ITEMS = [
'buy some cheese',
'feed the cat',
@callumacrae
callumacrae / bot.js
Created May 28, 2011 12:19
Node.js IRC bot
var net = require('net'),
irc = {}, config;
config = {
user: {
nick: '',
user: '',
real: '',
pass: ''
},
#!/bin/sh
# Compile a list of changed files
FILES=`git diff --name-only HEAD^`
# Attempt to fix whitespace issues
for FILE in `egrep -l '(\s$| {1,3}\t)' $FILES`
do
# Remove trailing whitespace
(sed -i 's/[ ]*$//' $FILE > /dev/null 2>&1 || sed -i '' -E 's/[ ]*$//' $FILE)
var storage = {};
if (window.localStorage)
{
storage.get = function(name)
{
if (window.localStorage[name] === undefined)
{
return undefined;
}
return JSON.parse(window.localStorage[name]);
@callumacrae
callumacrae / .block
Last active April 13, 2018 13:30 — forked from mbostock/.block
World Map
license: gpl-3.0
import { keymap } from './keypress-promise';
// import CrapEventEmitter from './crap-event-emitter';
const page = {
id: 'page',
speech: 'voiceover-demo, web content',
children: [
{
id: 'main-heading',
speech: 'heading level 1, Example page',
@callumacrae
callumacrae / .block
Last active March 8, 2017 11:46 — forked from mbostock/.block
Threshold Choropleth
license: gpl-3.0
@callumacrae
callumacrae / .block
Last active March 8, 2017 11:40 — forked from mbostock/.block
Area Choropleth
license: gpl-3.0
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config.js');
gulp.task('js:build', function (done) {
webpack(webpackConfig('js:build'), function (err, stats) {
if (err) {
throw err;