Skip to content

Instantly share code, notes, and snippets.

View pimterry's full-sized avatar
👶
50% parental leave, not going to be very responsive for a while

Tim Perry pimterry

👶
50% parental leave, not going to be very responsive for a while
View GitHub Profile
Contributor License Agreement
Definitions: "You" means the individual or legal entity who submits a contribution, "We" or "Us" means Toolshed Labs SLU (the organization behind the HTTP Toolkit open-source project) and its manager & representative Timothy Hugh Perry (https://github.com/pimterry).
By contributing Your code to this project You grant Us a non-exclusive, irrevocable, worldwide, royalty-free, sublicenseable, transferable license under all of Your relevant intellectual property rights (including copyright, patent, and any other rights), to use, copy, prepare derivative works of, distribute and publicly perform and display the contributions on any licensing terms, including without limitation: (a) open source licenses like the MIT license; and (b) binary, proprietary, or commercial licenses. Except for the licenses granted herein, You reserve all right, title, and interest in and to the contribution.
You confirm that You are able to grant Us these rights. You represent that You are legally entitle
@pimterry
pimterry / awaitFirst.js
Created January 9, 2020 17:56
JS code (untested) to wait for the first success, or throw the last error.
const awaitFirst = (promises) =>
new Promise((resolve, reject) => {
let count = promises.length;
promises.forEach(p =>
p.then(resolve, (e) => {
count = count - 1;
if (count === 0) reject(e);
})
);
});
@pimterry
pimterry / nginx.conf
Created June 10, 2020 13:16 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@pimterry
pimterry / mockttp-response-rewriting.js
Created April 8, 2021 11:31
A tiny Mockttp script that creates a response-rewriting proxy using Mockttp.
const mockttp = require('mockttp');
const server = mockttp.getLocal();
server.start().then(async () => {
// This creates a proxy rule, which will forward all traffic to the real server:
await server.anyRequest().thenPassThrough({
// Every time the real server gets a response, this callback will be called:
beforeResponse: (response) => {
console.log(`Got ${response.statusCode} response with body: ${response.body.text}`);
{
"log": {
"version": "1.2",
"creator": {
"name": "HTTP Toolkit",
"version": "16b657aaeff07eec548e31ccf2d5573154e287ba"
},
"pages": [
{
"id": "Curl/7.68.0",