Skip to content

Instantly share code, notes, and snippets.

@nrdmn
nrdmn / vsock-notes.md
Last active March 30, 2026 04:00
vsock notes

vsock notes

about vsocks

Vsocks are a means of providing socket communication (either stream or datagram) directly between VMs and their host operating system. The host and each VM have a 32 bit CID (Context IDentifier) and may connect or bind to a 32 bit port number. Ports < 1024 are privileged ports.

@hannesdatta
hannesdatta / download_from_dropbox.py
Last active December 16, 2024 15:27
Python script to download entire folder/directory structure from a (shared) Dropbox folder to a local computer
################################################################
# DOWNLOAD ENTIRE FOLDER STRUCTURE FROM DROPBOX TO LOCAL DRIVE #
################################################################
# Instructions:
# (1) install dropbox API using pip
# > pip install dropbox
# (2) Create application to make requests to the Dropbox API
# - Go to: https://dropbox.com/developers/apps
@serverlessunicorn
serverlessunicorn / APIGW_websocket_IAM_Auth_HowTo
Last active June 22, 2023 08:49
How to client-side IAM auth an Amazon API Gateway WebSocket connection
async def connect():
# Create a version of the websocket client class that handles AWS sigv4
# authorization by overriding the 'write_http_request' method with the
# logic to construct an x-amzn-auth header at the last possible moment.
def class WebSocketSigv4ClientProtocol(WebSocketClientProtocol):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
def write_http_request(self, path: str, headers) -> None:
# Intercept the GET that initiates the websocket protocol at the point where
# all of its 'real' headers have been constructed. Add in the sigv4 header AWS needs.
@colmmacc
colmmacc / shardcalc.py
Last active March 7, 2026 04:24
Calculate the blast radius of a shuffle shard
import sys
# choose() is the same as computing the number of combinations. Normally this is
# equal to:
#
# factorial(N) / (factorial(m) * factorial(N - m))
#
# but this is very slow to run and requires a deep stack (without tail
# recursion).
#
@eddiewebb
eddiewebb / readme.md
Last active January 12, 2026 06:31
Hugo JS Searching with Fuse.js
@terabyte
terabyte / amazon.md
Created December 6, 2017 02:27
Amazon's Build System

Prologue

I wrote this answer on stackexchange, here: https://stackoverflow.com/posts/12597919/

It was wrongly deleted for containing "proprietary information" years later. I think that's bullshit so I am posting it here. Come at me.

The Question

Amazon is a SOA system with 100s of services (or so says Amazon Chief Technology Officer Werner Vogels). How do they handle build and release?

@irvingpop
irvingpop / ssh_key.tf
Last active January 23, 2025 09:07
Terraform external data source example - dynamic SSH key generation
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use:
# "${data.external.ssh_key_generator.result.public_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key}" (contents)
# "${data.external.ssh_key_generator.result.private_key_file}" (path)
data "external" "ssh_key_generator" {
program = ["bash", "${path.root}/../ssh_key_generator.sh"]
query = {
customer_name = "${var.customer_name}"
customer_group = "${var.customer_group}"
@atinux
atinux / async-foreach.js
Last active February 2, 2026 23:07
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle: