Skip to content

Instantly share code, notes, and snippets.

@mcastelino
mcastelino / iptables-cheatsheet.md
Last active June 25, 2025 14:45
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@travisjeffery
travisjeffery / functional-options.md
Last active April 23, 2023 11:13
How to do functional options in Golang

Here's the simplest example showing how to do functional options in Golang.

They're a great way to enable users to set options and ease adding new options later.

package main

import (
	"flag"
	"fmt"
@justinclayton
justinclayton / taint_module.sh
Created January 19, 2016 18:48
Terraform: taint all resources from one module
#!/bin/bash
module=$1
for resource in `terraform show -module-depth=1 | grep module.${module} | tr -d ':' | sed -e 's/module.${module}.//'`; do
terraform taint -module ${module} ${resource}
done
@Sinnohd
Sinnohd / keyrotate.py
Created January 5, 2016 10:26
Script to rotate AWS keys and replace them in .boto and .aws/config
#!/usr/bin/python
import boto.iam, boto.exception
import argparse, os
import ConfigParser
parser = argparse.ArgumentParser(description="Rotate Access Keys.")
parser.add_argument(
"-p",
"--profile",
@dlamotte
dlamotte / pex-build.py
Last active November 30, 2017 10:10
Using pex to build a single python executable (minimal requirements)
#!/usr/bin/env python2.7
from pex.pex_builder import PEXBuilder
from pex.resolvable import resolvables_from_iterable
from pex.resolver import CachingResolver
from pex.resolver_options import ResolverOptionsBuilder
import argparse
import os
import shutil
import sys
@skoji
skoji / remove-slack-settings.sh
Created November 2, 2015 03:34
remove Slack settings (OS X)
rm -rf ~/Library/Application\ Support/Slack/
rm -rf ~/Library/Containers/com.tinyspeck.slackmacgap/
rm -rf ~/Library/Preferences/com.tinyspeck.slackmacgap.plist
rm -rf ~/Library/Saved\ Application\ State/com.tinyspeck.slackmacgap.savedState
rm ~/Library/Safari/LocalStorage/*slack*
@brianlechthaler
brianlechthaler / namegen.sh
Created October 21, 2015 17:01
Name Generator
echo First word, Adjective:
curl -s "http://api.wordnik.com:80/v4/words.json/randomWord?hasDictionaryDef=false&includePartOfSpeech=adjective&minCorpusCount=0&maxCorpusCount=-1&minDictionaryCount=1&maxDictionaryCount=-1&minLength=5&maxLength=-1&api_key=YOUR_API_KEY_HERE"
echo
echo
echo Second word, Noun:
curl "http://api.wordnik.com:80/v4/words.json/randomWord?hasDictionaryDef=false&includePartOfSpeech=noun&minCorpusCount=0&maxCorpusCount=-1&minDictionaryCount=1&maxDictionaryCount=-1&minLength=5&maxLength=-1&api_key=YOUR_API_KEY_HERE"
echo
echo
echo Now, combine these two, and you have your name.
echo For example, if your two words were ‘taught’ and ‘webzines’, your name would be TaughtWebzines.
@jesusgoku
jesusgoku / NamesGenerator.php
Last active January 2, 2016 12:53
Port of NameGenerator use for Docker
<?php
namespace JesusGoku;
/**
* NamesGenerator
*
* Port of NameGenerator use for Docker
*
* @author Jesús Urrutia <[email protected]>
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active September 23, 2025 21:29
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

#!/usr/bin/env bash
size=1024 # MB
mount_point=$HOME/tmp
name=$(basename "$mount_point")
usage() {
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \
"(default: mount)" >&2
}