Skip to content

Instantly share code, notes, and snippets.

@johnstanfield
johnstanfield / ap.sh
Created September 7, 2021 02:00
When staying at a hotel with a Chromecast, make the laptop an AP and connect the Chromecast to it to bypass hotel authentication
#!/bin/bash
# i want to stream netflix and prime video from my chromecast to the hotel TV
#
# hotels often have an authentication / agreement page that you have to click OK on
# chromecasts do not play nicely with those
#
# solution: connect your laptop to the hotel's wi-fi, then set up an AP and connect the chromecast to the AP
# your laptop will be both a client of the hotel's WLAN and an access point + bridge of your own WLAN
#
@johnstanfield
johnstanfield / tunnel.sh
Last active January 7, 2022 12:49
open google chrome via socks5 tunnel to aws
# prerequisites
# 1) you have a (Linux) EC2 instance with SSH enabled, source/destination check disabled, etc.
# 2) you have a security group rule with a tag named roaming (this script updates that rule to allow you access) (note: tag the rule, not the security group)
# grant access to your IP access
myip=$(curl -s https://ipv4.icanhazip.com)
read sgid sgrid < <(echo $(aws ec2 describe-security-group-rules --filter Name=tag:Name,Values=roaming | jq '.SecurityGroupRules[0].GroupId, .SecurityGroupRules[0].SecurityGroupRuleId' -r))
aws ec2 modify-security-group-rules --group-id $sgid --security-group-rules SecurityGroupRuleId=$sgrid,SecurityGroupRule=\{CidrIpv4=$myip\/32,FromPort=22,ToPort=22,IpProtocol=TCP,Description=roaming\}
# open tunnel
@johnstanfield
johnstanfield / kill-touchpad-triple-click.sh
Created January 13, 2022 14:01
disable center touchpad button
# i often click between the buttons on my touchpad.
# this is because the touchpad is lined up with the center of the laptop
# rather than the center of the keyboard home row
# this script finds the device id of the touchpad (which changes as devices are plugged/unplugged) and disables the triple click
# note: on new installations, run xinput to identify your touchpad which may not contain the word TouchPad
touchPadId=$(xinput | grep TouchPad | awk -F 'id=' '{print $2}' | cut -f1)
xinput --set-button-map $touchPadId 1 1 3
@johnstanfield
johnstanfield / jqsay
Last active February 25, 2022 17:25
jqsay -- turn bash args into json
#!/usr/bin/env bash
# jq-say
# format string as JSON message
#
# treat odd args as keys and even args as values
# use jq to output something like this, for as many args supplied:
# {"arg1": "arg2", "arg3": "arg4"}
#
# very helpful for echo'ing log messages as JSON
@johnstanfield
johnstanfield / edit-docker-image.sh
Created July 27, 2022 19:52
Edit a Docker image and push it to ECR. Sometimes you just want to pull a container image, edit a file, and push it back, outside of source control and CI/CD. This is how.
# note: get your AWS credentials however you usually do that (e.g. aws configure or set the env vars)
REPO_URL=accountid.dkr.ecr.region.amazonaws.com/repo-name
EXISTING_TAG=version1
NEW_TAG=version1-hotfix
# get everything ready
mkdir -p ~/slipstream
cd ~/slipstream
`aws ecr get-login --no-include-email`