Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View m-allanson's full-sized avatar
💭
I may be slow to respond.

Mike Allanson m-allanson

💭
I may be slow to respond.
View GitHub Profile
@m-allanson
m-allanson / gist:3084527
Created July 10, 2012 16:37
The right way to check if a variable is undefined in javascript
if (typeof someVar === 'undefined') {
// it's not defined
}
@m-allanson
m-allanson / gist:4235225
Created December 7, 2012 18:20
Broken noise-box casperJS script
var casper = require('casper').create();
var casper2 = require('casper').create();
var roomName = 'caspersroom';
var audiofile = '';
casper.start('http://localhost:7001/', function() {
this.test.assertTitle('NoiseBox', 'NoiseBox title is ok');
this.test.assertExists('form[action="/host/"]', 'The form to create a new host exists');
this.fill('form[action="/host/"]', {
id: roomName
@m-allanson
m-allanson / gist:4637797
Last active December 11, 2015 17:58
Spawn a background process from grunt
grunt.registerTask('spawn', 'Start app in the background', function () {
var fs = require('fs'),
spawn = require('child_process').spawn,
out = fs.openSync('./out.log', 'a'),
err = fs.openSync('./out.log', 'a'),
env = process.env;
env.NODE_ENV = 'testing';
env.PORT = 7002;
@m-allanson
m-allanson / gist:6317903
Last active December 21, 2015 14:09
Paste into the console of a modern web browser.
var content = '@-webkit-keyframes rotate { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(359deg); } } @keyframes rotate { from { -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-transform: rotate(0deg); -o-transform: rotate(0deg); transform: rotate(0deg); } to { -webkit-transform: rotate(359deg); -moz-transform: rotate(359deg); -ms-transform: rotate(359deg); -o-transform: rotate(359deg); transform: rotate(359deg); } } .dizzy { -webkit-animation-name: rotate; -moz-animation-name: rotate; -ms-animation-name: rotate; -o-animation-name: rotate; animation-name: rotate; -webkit-animation-duration: 0.8s; -moz-animation-duration: 0.8s; -ms-animation-duration: 0.8s; -o-animation-duration: 0.8s; animation-duration: 0.8s; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; -o-animation-iteration-count: infinite; animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-anima
@m-allanson
m-allanson / gist:c1b3d031f3833bbf1a86f1ffcc0cc495
Created December 1, 2016 13:33
Regex find & replace to convert ES6 imports to CommonJS requires
// matches:
// import foo from "../foo"
(import )((\w)+)( from )"((.|\/)*\w)"
// replaces with:
// const foo = require("../foo")
const $2 = require("$5")
@m-allanson
m-allanson / output.md
Created September 29, 2017 23:49
Gatsby output
cd dev/projects/
∴ projects
git clone git@github.com:ahmedelgabri/gabri.me.git
Cloning into 'gabri.me'...
remote: Counting objects: 2273, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 2273 (delta 0), reused 1 (delta 0), pack-reused 2268
Receiving objects: 100% (2273/2273), 27.23 MiB | 5.49 MiB/s, done.
Resolving deltas: 100% (1165/1165), done.
@m-allanson
m-allanson / fileMock.js
Created November 16, 2017 14:42
Using Jest with Gatsby
// in __mocks__/
// Jest file stub
module.exports = "test-file-stub";

Keybase proof

I hereby claim:

  • I am m-allanson on github.
  • I am mallanson (https://keybase.io/mallanson) on keybase.
  • I have a public key ASCW_f57zz8JNYQcE16pb5wwS2HM_Klo3b996YK529xEtwo

To claim this, I am signing this object:

@m-allanson
m-allanson / report.md
Created August 1, 2018 18:24
Gatsby report 2018-08-01

Hey folks,

Here's what's been going on with Gatbsy this week:

@m-allanson
m-allanson / report-2018-08-08.md
Last active August 8, 2018 22:21
Gatsby report 2018-08-08

Hey folks,

Here's what's happening in Gatsby, starting with a hat-trick of event updates: