Skip to content

Instantly share code, notes, and snippets.

@andy-polhill
andy-polhill / README.md
Last active March 15, 2022 12:14
A simple node server to test webhooks
  1. Run the server with node index.js
  2. Use ngrok to expose the server publicly ngrok http 3000
  3. Subscribe to the relevant hook.
mutation subscribeToHook {
  createdByAdminWebhookSubscriptionCreate(
    topic: <Webhook Topic>
    webhookSubscription: {
      apiVersion: "unstable"
 callbackUrl: "https:///hook"
@andy-polhill
andy-polhill / file1.txt
Created January 31, 2018 22:17
the description for this gist
String file contents
@andy-polhill
andy-polhill / react-perf-redux-midleware.js
Created January 13, 2016 17:32
React Perf Redux Middleware sketch
const whitelist = ['SEARCH_CHANGE_TEXT'];
const perfMiddleware = () => next => action => {
let result;
if (whitelist.includes(action.type)) {
console.group(action.type);
Perf.start();
result = next(action);
Perf.stop();
Perf.printWasted(Perf.getLastMeasurements());
console.groupEnd();
@andy-polhill
andy-polhill / Example.js
Last active November 2, 2015 08:56
Why we need to be able to call a component instance method on some occasions during test
import React, {Component} from 'react';
import Child from './Child'
class Example extends Component {
a() {
//do some stuff
this.c();
}
b() {
var Person = (function(){
var population = 0;
var privateData = new WeakMap();
class Person {
constructor(opts) {
privateData.set(this, {
@andy-polhill
andy-polhill / gist:58f0a3c101b9d1011216
Last active August 29, 2015 14:22
ES5 Person Class
var Person = (function() {
var __population = 0;
function Person(opts) {
var privateProps = ['dob'];
//Private
var props = {
@andy-polhill
andy-polhill / gist:6731301b62f979899285
Created June 9, 2015 15:56
Experiments with ES6 class syntax and private members (through Babel0
class Person {
constructor(options) {
this.firstname = options.firstname;
this.lastname = options.lastname;
Person.privateData.set(this, { dob: options.dob });
}
get fullname() {
@andy-polhill
andy-polhill / speech-bookmarklet
Created December 12, 2014 12:22
Chrome & Safari random voice speech bookmarklet
javascript:
var newUtterance = new SpeechSynthesisUtterance(),
voices = window.speechSynthesis.getVoices();
newUtterance.text = window.prompt("Say", "");
newUtterance.voice = voices[Math.floor(Math.random() * voices.length)];
window.speechSynthesis.speak(newUtterance);
public abstract class StringUtils {
public String cropAndConcat(String toCrop, int index, String toConcat) {
return toCrop.substring(index) + toConcat;
}
public String removeFromAndConcatToEnd(String containing, String concat) {
if (containing.contains(concat)) {
return containing;
}
@andy-polhill
andy-polhill / gist:5411343
Created April 18, 2013 09:05
Package,json with sockets that work fine locally but not hosted
{
"name": "playground",
"version": "0.0.0-8",
"description": "Just Playin",
"main": "main.js",
"dependencies": {
"amdefine": ">=0.0.2",
"socket.io": "~0.9.14",
"express": "~3.1.1",
"jasmine-node": "~1.6.0",