Skip to content

Instantly share code, notes, and snippets.

@udkyo
udkyo / README.md
Created March 27, 2018 08:23 — forked from obscurerichard/README.md
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

@udkyo
udkyo / gist:67bb60565227ef5cda1b10162401a96d
Created April 4, 2018 18:29
docker-compose network thing.
version: "3.4"
services:
spawner:
image: docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
entrypoint: |
sh -c "docker run --rm --name childcontainer --network ${stack}_default -d alpine sleep 10 && ping childcontainer"
@udkyo
udkyo / Dockerfile
Last active May 1, 2024 12:51
Basic container for X11 forwarding goodness
FROM ubuntu
RUN apt update \
&& apt install -y firefox \
openssh-server \
xauth \
&& mkdir /var/run/sshd \
&& mkdir /root/.ssh \
&& chmod 700 /root/.ssh \
&& ssh-keygen -A \
&& sed -i "s/^.*PasswordAuthentication.*$/PasswordAuthentication no/" /etc/ssh/sshd_config \
@udkyo
udkyo / gist:a5da4ca6496efc3e238d36fd813bc305
Created May 22, 2018 10:09
Terraform - get local external IP
data "external" "public_ip" {
program = [ "sh", "-c", "echo {\\\"ip\\\": \\\"$(curl ifconfig.io)\\\"}" ]
//populates ${data.external.public_ip.result.ip}
}
@udkyo
udkyo / channel.go
Created August 12, 2018 20:51
Goroutine & channel simple example
// I read some needlessly confusing explanations of channels when I was
// learning go, so I figured I'd post a very straightforward example and
// describe it to death with comments
//
// If anyone ever stumbles across it, I hope it helps :)
package main
import (
"fmt"
"time"
# I use this for quickly getting SSH pub keys from one host to another in the lab
# when I've provisioned them an awkward way, running this and then something along the lines of
# mkdir ~/.ssh && chmod 755 ~/.ssh && curl [host_with_key] >> ~/.ssh/authorized_keys
while true; do nc -l -p 1500 -c 'echo -e "HTTP/1.1 200 OK\n\n$(cat ~/.ssh/id_rsa.pub)"'; done
@udkyo
udkyo / delete_all_awslogs.sh
Created August 11, 2019 09:28 — forked from pahud/delete_all_awslogs.sh.md
delete all aws log groups
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table | awk '{print $2}' | grep -v ^$ | while read x; do aws logs delete-log-group --log-group-name $x; done
@udkyo
udkyo / make_mojave_iso.sh
Last active March 4, 2020 09:57 — forked from lamlion/make_mojave_iso.sh
Create OSX Mojave ISO
#!/bin/bash
# Install OSX Mojave through App Store. After downloading, the "InstallESD" is automatically mounted, which causes this script to fail.
# Therefore, "/Volumes/InstallESD" should be unmounted before running this script!
# Summary of instructions
#1 Download Mojave from App Store
#2 open terminal and run "umount /Volumes/InstallESD"
#3 make script executable: "chmod +x make_mojave_iso.sh"
#4 Run "./make_mojave_iso.sh"
@udkyo
udkyo / make_catalina_iso.sh
Last active March 5, 2020 16:46 — forked from davertay/make_catalina_iso.sh
Catalina ISO for Virtualbox
hdiutil create -o /tmp/Catalina -size 8000m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Catalina.dmg -noverify -mountpoint /Volumes/install_build
sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --nointeraction --volume /Volumes/install_build
hdiutil convert /tmp/Catalina.dmg -format UDTO -o ~/Downloads/Catalina
mv ~/Downloads/Catalina.cdr ~/Downloads/Catalina.iso
@udkyo
udkyo / .zshrc
Created June 2, 2020 08:06
VSCode terminal history persistence helper
function hist {
[ ! -d ~/.history ] && mkdir ~/.history
chmod 700 ~/.history
name="history$(pwd | sed 's/\//-/g')"
echo "Using history file $name"
HISTFILE=~/.history/$name
HISTSIZE=4096
SAVEHIST=4096
setopt appendhistory
fc -R