Skip to content

Instantly share code, notes, and snippets.

@jamesbibby
jamesbibby / App.jsx
Last active July 24, 2019 11:55
Cloudflare Workers with Typescript and Webpack
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@jamesbibby
jamesbibby / App.jsx
Last active March 28, 2019 17:55
Cloudflare Typescript Worker
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@jamesbibby
jamesbibby / api_gateway_worker.js
Created February 22, 2019 03:28
API Gateway Cloudflare Worker
// The base url for the site
const baseURL = '.bibs.codes';
/**
The actual request handler
Remaps the URL from: api.bibs.codes/service_name to service_name.bibs.codes
**/
async function handleRequest(request) {
const url = new URL(request.url);
// skip the leading '/' and split the request
@jamesbibby
jamesbibby / spa_router_worker.js
Last active October 9, 2020 14:32
SPA Router Cloudflare Worker
const ASSET_PATHS = [
'/asset-manifest.json',
'/favicon.ico',
'/manifest.json',
'/precache-manifest.',
'/serviceWorker.js',
'/static/'
];
const S3_BUCKET = "bibs-hello-world-react";
@jamesbibby
jamesbibby / hello_world_worker.js
Last active February 22, 2019 03:27
Hello World Cloudflare Worker
// listening to the fetch event is how to intercept requests in a worker
addEventListener('fetch', event => {
event.respondWith(new Response('hello world'))
})

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@jamesbibby
jamesbibby / queue.js
Last active August 5, 2016 17:39
ES6 version: queue.js, ES5 version: queue_js.js
import Stomp from 'stomp-client';
const destination = 'pdp.integration';
const client1 = new Stomp('54.215.168.194', 62613);
const client2 = new Stomp('54.215.168.194', 62616);
export function updateTickets() {
console.log('about to send message 1');
@jamesbibby
jamesbibby / queue.js
Created August 5, 2016 17:39
ES6 version: queue.js
import Stomp from 'stomp-client';
const destination = 'pdp.integration';
const client1 = new Stomp('54.215.168.194', 62613);
const client2 = new Stomp('54.215.168.194', 62616);
export function updateTickets() {
console.log('about to send message 1');
@jamesbibby
jamesbibby / pre-commit
Created May 19, 2016 16:24
make this executable in your .git/hooks/pre-commit to automatically update the branch name in your coveralls and travis badges
#!/usr/bin/python
import subprocess
import fileinput
import re
GITHUB_USER="" #enter your username
REPO="" #enter the name of your repo
print "Starting pre-commit hook..."