Skip to content

Instantly share code, notes, and snippets.

View leggetter's full-sized avatar

Phil Leggetter leggetter

View GitHub Profile

Keybase proof

I hereby claim:

  • I am leggetter on github.
  • I am leggetter (https://keybase.io/leggetter) on keybase.
  • I have a public key ASBKejKymaKZqsk278jz5L22rzoH4blY3ihyRFErUtdwaQo

To claim this, I am signing this object:

@leggetter
leggetter / nexmo-call-with-retry.js
Created March 21, 2017 10:45
An example of making calls and handling retries when 429 responses are detected in Node.JS
var Nexmo = require('../lib/Nexmo');
var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET,
applicationId: config.APP_ID,
privateKey: config.PRIVATE_KEY
},
{debug: config.DEBUG}
);
@leggetter
leggetter / inbound-sms-headers.txt
Created August 14, 2016 10:15
Nexmo Inbound SMS Webhook
Accept */*
Content-Length 145
Content-Type application/x-www-form-urlencoded; charset=UTF-8
User-Agent Nexmo/MessagingHUB/v1.0
X-Forwarded-For 174.36.197.202
X-Forwarded-Proto https
@leggetter
leggetter / client.html
Created June 13, 2015 11:38
How easy it is to integrate Pusher
<script src="//js.pusher.com/2.2/pusher.min.js"></script>
<script>
var pusher = new Pusher('YOUR_APP_KEY');
var channel = pusher.subscribe('test_channel');
channel.bind('my_event', function(data) {
// do something awesome with data
// e.g. showNotification(data.msg)
});
</script>
@leggetter
leggetter / pusher.js
Created January 15, 2015 01:04
pusher-js 2.2.3 but with a returnExportsGlobal UMD header which means it should work in browsers by Pusher being available as a global and with Browserify with CommonJS style require syntax. AMD has not been tested.
/*!
* Pusher JavaScript Library v2.2.3-umd
* http://pusher.com/
*
* Copyright 2014, Pusher
* Released under the MIT licence.
*/
// Uses Node, AMD or browser globals to create a module. This example creates
// a global even when AMD is used. This is useful if you have some scripts
@leggetter
leggetter / pusher-channel-regexp.js
Created November 9, 2014 18:07
Pusher Valid Channel Name Regexp
var pusherChannelRegexp = /[\w_\-\=@,\.;]+/;
var result = pusherChannelRegexp.test( 'foo-bar_1234@=,.;' );
console.log( result );
@leggetter
leggetter / replay-api-messages.js
Created November 3, 2014 21:02
Add "Replay" button to API Messages in Pusher Debug Console
// ==UserScript==
// @name Pusher Debug Console Enhancements
// @namespace http://www.leggetter.co.uk
// @version 0.1
// @description Add a button to the Pusher JavaScript console that lets you replay API Messages
// @author Phil @leggetter
// @match https://app.pusher.com/apps/*/console
// @grant none
// ==/UserScript==
@leggetter
leggetter / stickerify.html
Created October 1, 2014 09:59
Grokking Promises
<!doctype html>
<html>
<head>
<title>Stickerify</title>
</head>
<body>
<ul id="stickers">
</ul>
@leggetter
leggetter / socket-io-namespace.md
Created July 1, 2014 17:58
Should the following result in so many connections being made to the Socket.IO server?

I'm trying to use Socket.IO with namespaces in order to partition the data. See the following code:

<script src="https://cdn.socket.io/socket.io-1.0.6.js"></script>
<script>
var webglStats = io( '/webgl' );
var videoStats = io( '/video' );
var touchStats = io( '/touch' );
</script>
BladeRunnerJS is an open source developer toolkit and lightweight front-end framework for building modular large-scale HTML5 single page apps.