Skip to content

Instantly share code, notes, and snippets.

@killdash9
killdash9 / httpserver.sh
Last active February 26, 2018 01:44
A minimal HTTP server in bash that listens on port 1234
#!/bin/bash
#Serves the current directory.
test -p .f||mkfifo .f;while :;do cat .f|nc -l ${1:-1234}|(read m u p;echo $u;u=${u#/};{ echo -e 'HTTP/1.0 200 OK\nContent-type:text/html\n';test -d $u&&ls $u|sed "s,.*,<a href=\"$u/&\">&<br>,"||cat $u;}>.f);done
@emeraldsanto
emeraldsanto / presign-sts-get-caller-identity.ts
Last active June 26, 2024 16:09
Presign an AWS STS GetCallerIdentity request for later use, adapted to JavaScript from https://donchev.is/post/aws-lambda-invoker-identification
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { Sha256 } from '@aws-crypto/sha256-js';
import { SignatureV4 } from "@aws-sdk/signature-v4";
import { stringify } from "qs";
async function main(): Promise<string> {
const signer = new SignatureV4({
credentials: defaultProvider(),
region: process.env.AWS_REGION,