This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Now available in package form at https://github.com/rjz/githubhook | |
package handler | |
// https://developer.github.com/webhooks/ | |
import ( | |
"crypto/hmac" | |
"crypto/sha1" | |
"encoding/hex" | |
"errors" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buffer = require('buffer'); | |
const crypto = require('crypto'); | |
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib. | |
const aes256gcm = (key) => { | |
const ALGO = 'aes-256-gcm'; | |
// encrypt returns base64-encoded ciphertext | |
const encrypt = (str) => { | |
// The `iv` for a given key must be globally unique to prevent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON | |
# string. We can hack out the forwarded hostname by extracting the next | |
# `*.ngrok.io` string from the JSON | |
# | |
# Brittle as all get out--YMMV. If you're still reading, usage is: | |
# | |
# $ ./ngrok_hostname.sh <proto> <addr> | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"mime" | |
"net/http" | |
"strings" | |
) | |
// Determine whether the request `content-type` includes a | |
// server-acceptable mime-type | |
// | |
// Failure should yield an HTTP 415 (`http.StatusUnsupportedMediaType`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** `x/crypto` if running in `deno` */ | |
import { createHmac } from 'node:crypto' | |
/** A signing secret */ | |
const HMAC_SECRET = '<YOUR SIGNING SECRET HERE>' | |
/** Length of a hexidecimal HMAC digest */ | |
const HMAC_LENGTH = 64 | |
function hmac(message: string): string { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Represents an error when an unreachable variant is encountered at runtime | |
*/ | |
export class ExhaustiveCheckError<T> extends TypeError { | |
public instance: T; | |
public readonly isUnexpected = true; | |
constructor(msg: string, instance: T) { | |
super(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Depends on `through` | |
// | |
// $ npm install through | |
// | |
// Usage: | |
// | |
// $ echo 'hello' | node stdin-and-fs-stream.js | |
// $ echo 'hello' > tmp && node stdin-and-fs-stream.js tmp | |
// | |
var fs = require('fs'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of mocking out global `fetch` | |
// | |
// Spec works using Jasmine (via Karma) and _either_ tsc or babel. | |
// | |
// $ npm install --save-dev fetch-mock whatwg-fetch | |
// | |
// If using `tsc`, grab the type definitions as well: | |
// | |
// $ typings --save --global dt~fetch-mock dt~whatwg-fetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# | |
# Use `psutils` to convert a PDF into a printable booklet. | |
# | |
# Usage: | |
# | |
# $ ./pdf_to_booklet.sh my_file.pdf | |
# | |
# Distributed under terms of the MIT license. |
NewerOlder