Skip to content

Instantly share code, notes, and snippets.

View andrewwakeling's full-sized avatar

Andrew Wakeling andrewwakeling

  • Australia
View GitHub Profile
@andrewwakeling
andrewwakeling / simple-proxy.js
Created December 4, 2018 23:14
Simple code to proxy localhost to a particular host
const http = require('http');
function onRequest(clientReq, clientRes) {
console.log(`serve: ${clientReq.url}`);
const options = {
hostname: 'foo.ngrok.io',
port: 80,
path: clientReq.url,
method: 'GET',
@andrewwakeling
andrewwakeling / iwc.html
Last active August 29, 2015 14:27
Testing locking with slimjack/IWC
<!DOCTYPE html>
<html>
<head>
<script src="iwc-all.js"></script>
<script>
// The amount of time the async function is likely to take in (in milliseconds).
var ASYNC_DURATION_MIN = 10;
var ASYNC_DURATION_MAX = 5000;
// The amount of time before we attempt to send again (in milliseconds).
@andrewwakeling
andrewwakeling / gist:972049948b05cfd3d78d
Created March 3, 2015 02:19
node-scheduler not firing at the start of every minute reliably
Tue Mar 03 2015 11:01:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:02:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:04:17 GMT+1100 (AEDT)
Tue Mar 03 2015 11:04:17 GMT+1100 (AEDT)
Tue Mar 03 2015 11:05:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:06:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:07:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:08:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:09:00 GMT+1100 (AEDT)
Tue Mar 03 2015 11:10:00 GMT+1100 (AEDT)
<!doctype html>
<html>
<head>
<script src="jquery-1.11.1.min.js"></script>
<script src="jquery.gdb.js"></script>
<script src="main.js"></script>
</head>
<body>
<div data-bindto="data.lastUpdated"></div>
</body>
{
"name": "simpleapp",
"description": "simple application",
"version": "0.0.1",
"author": {
"name": "Tim Douglas"
},
"dependencies": {
"express": "3.4.8",
"moment": "2.5.1"
@andrewwakeling
andrewwakeling / bluebird-foo.js
Last active January 2, 2016 10:49
Comparing error reporting with Promise libraries
var foo = function () {
var promise = new Promise(function (resolve, reject, notify) {
setTimeout(function () {
resolve();
}, 100);
});
return promise;
};
@andrewwakeling
andrewwakeling / problem.html
Last active December 30, 2015 00:19
globalVars causing undesirable caching behaviour with Local Storage.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet/less" type="text/css" href="problem.less">
<script>
less = {
env: 'production'
};
var useGlobalVars = true;
if (useGlobalVars) {
@andrewwakeling
andrewwakeling / gist:7094918
Created October 22, 2013 03:47
A simple example showing how to use async to parallelize several invocations to asynchronous functions and wait for the result.
// A simple example showing how to use async to parallelize several invocations to asynchronous functions and wait for the result.
var async = require('async');
/**
* A very simple asynchronous function which takes in a number and invokes the callback with that number incremented by 1.
* @param number
* @param cb(err, result)
*/
function addOne(number, cb) {
process.nextTick(function() {