Skip to content

Instantly share code, notes, and snippets.


Philip Roberts latentflip

View GitHub Profile
View index.html
<!-- this will run -->
<style nonce='1234'>
.a {
color: red;
<!-- this won't run -->

Keybase proof

I hereby claim:

  • I am latentflip on github.
  • I am latentflip ( on keybase.
  • I have a public key ASBI6Z-jWtGaqeuOQNOJzfjfMbDQQVl26r7h8JHSTm3_2wo

To claim this, I am signing this object:

  1. Install windows somehow. If you have a 16gb usb stick, you can do it with bootcamp assistant and an iso from:
    • I think I chose pro but shouldn't really matter
  2. Get visual studio installing cos it takes forever, use the community edition here:
  3. The easiest way to get going with git on windows seems to be that sets up keys etc for you
  4. Install node and npm:

Philip, I recently watched your youtube video on the event loop and found it to be very informative. In one of your examples it has a setTimout(...,0) and is followed by two console logs. Being that the setTimeout is a web API it is sent to the callback queue and finally to the call stack (once it has been cleared of the two console.logs). My confusion lies with the fact that console is a web API as show here( in the MDN. If console is a web API then doesn't it go to the task/callback queue just like setTimeout?

Thank you,

So the confusion is probably just because I glossed over the difference between an asynchronous web api, and a synchronous one.

The distinction between calling a "normal" JavaScript function (say Math.floor(5.5)) and one provided by a web api (like console.log('foo') or setTimeout(..., 0)) isn't solely about whether it's async (and so appears on the callback queue) or not.

Really the difference is whether it's a part of th

View gist:c476ddee24d09405a6e9
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
const update = path => {
if (path.node.expression) {
const body = j.blockStatement([j.expressionStatement(path.node.body)]);
return j.functionExpression(, path.node.params, body, true, false)
return j.functionExpression(, path.node.params, path.node.body, true, false)
View babel-plugin-npm-autoinstall.js
'use strict';
const util = require('util');
const execSync = require('child_process').execSync;
const ignoreModules = [

Run-time Debugger

This week I've been hacking around with some ideas about a runtime debugger for node (and probably browser JS too). These build upon some of the ideas loupe.

Run-time debugger is probably the wrong phrase, but I can't yet think of a better one - essentially what I mean is that all the code for building instrumenting/visualisating/debugging would be written in "userland" JS, rather than embedded in the JS engine itself.

This would obviously not be as powerful as a native engine debugger, with full access to the internals of v8 (or whichever engine), but I think the potential for hackability, and building things on top of it, is kinda interesting.


View 1-source.js
setTimeout(function () {
}, 1000);
var x = 10;
var y = 100;
function foo(y) {
latentflip / index.js
Created Oct 27, 2015
requirebin sketch
View index.js
'use strict';
var State = require('ampersand-state');
var ChildState = State.extend({
props: {
name: 'string'
var ParentState = State.extend({
View find-webpack-unrequired.js
var exec = require('child_process').exec;
var config = require('./src/browser.webpack.config.js');
var compiler = require('webpack')(config);
var path = require('path'); (err, stats) {
if (err) {
throw err
You can’t perform that action at this time.