Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / sh.sh
Last active February 2, 2021 09:27
Bash on Windows shell script file association
#!/bin/bash
# Put this file in C:\ and then run z-register.bat by right clicking it and using "Run as Administrator"
# Translate the windows path to the equivalent Bash on Windows path, then run it!
drive="${1:0:1}"
path="${1:2}"
dir=$(dirname "/mnt/${drive,,}${path//\\/\/}")
cd "$dir"
"/mnt/${drive,,}${path//\\/\/}"
@stefansundin
stefansundin / nginx.firewall.plist
Last active November 2, 2022 16:18
This lets you run nginx as a normal user and still receive connections on port 80 and 443. Setup nginx to listen to port 8080 for http and 8443 for https.
<!-- https://gist.github.com/stefansundin/f0ad99195333480157ce67e97c8d28c7
UPDATE:
This is not actually necessary, as you can use the following commands to allow nginx to bind to privileged ports:
$ sudo chown root:wheel /usr/local/opt/nginx/bin/nginx
$ sudo chmod u+s /usr/local/opt/nginx/bin/nginx
@stefansundin
stefansundin / .gitignore
Last active November 18, 2017 04:04
TEMPer cron + gnuplot
*.dat
*.png
*.txt
pcsensor-temper
Moved to https://github.com/stefansundin/open-with-vlc
@stefansundin
stefansundin / altdrag-toggle.ahk
Created June 8, 2017 06:56
Press Ctrl+Alt+A to toggle AltDrag. Compile with AutoHotKey: https://www.autohotkey.com/
; Press Ctrl+Alt+A to toggle AltDrag
; 0x111 = WM_COMMAND
; 0x8000+1 = SWM_TOGGLE https://github.com/stefansundin/altdrag/blob/8547fc8ea13829af712586558851b9ed50ae23e8/altdrag.c#L27
DetectHiddenWindows, on
^!a::
SendMessage, 0x111, 0x8000+1, 0,, ahk_class AltDrag
return
@stefansundin
stefansundin / download-slack-emoji.sh
Last active February 9, 2023 15:05
Download all of your Team's custom Slack emojis.
#!/bin/bash -eo pipefail
# Log in to Slack in a web browser and open the network tools to inspect the traffic.
# Filter the requests with "/api/" and pick one to inspect.
# You need the xoxc token from the request body, and a copy of the cookies. It is the "d" cookie that is important, but you can copy all of them. Make sure that the cookie value is percent encoded!
# Paste the values below.
# You need to have curl and jq installed.
# You can also get the xoxc token from localStorage. Run this in the JavaScript console:
# Object.entries(JSON.parse(localStorage.localConfig_v2)["teams"]).reduce((o,e) => Object.assign(o, { [e[1]["name"]]: e[1]["token"] }), {})
@stefansundin
stefansundin / .gitignore
Last active March 17, 2019 06:04
Gnuplot Heroku runtime metrics
*.tsv
*.gz
*.dat
*.png
*.json
@stefansundin
stefansundin / heroku-replay.sh
Last active August 30, 2018 17:39
Replay production Heroku requests to your local dev environment.
#!/bin/bash -e
app=rssbox
dev=http://rssbox.dev
heroku logs -t -s heroku -d router -a $app | {
while IFS= read -r line
do
path=$(echo $line | grep -oE 'path="([^"]+)"' | cut -d'"' -f2)
code=$(curl -s -o /dev/null -w "%{http_code}" "$dev$path")
@stefansundin
stefansundin / openssh-7.3.sh
Last active September 13, 2022 21:03
Install OpenSSH 7.3 in Ubuntu 16.04
# WARNING: Use this at your own risk. It will probably break your other packages and cause other havoc.
# These days you should just upgrade to Ubuntu 18.04.
$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
wget https://launchpadlibrarian.net/277739251/openssh-client_7.3p1-1_amd64.deb
wget https://launchpadlibrarian.net/298453050/libgssapi-krb5-2_1.14.3+dfsg-2ubuntu1_amd64.deb
wget https://launchpadlibrarian.net/298453058/libkrb5-3_1.14.3+dfsg-2ubuntu1_amd64.deb
wget https://launchpadlibrarian.net/298453060/libkrb5support0_1.14.3+dfsg-2ubuntu1_amd64.deb