Instantly share code, notes, and snippets.

View spf-lookup-counter.rb
#!/usr/bin/env ruby
# https://tools.ietf.org/html/rfc4408#section-10.1
# SPF implementations MUST limit the number of mechanisms and modifiers
# that do DNS lookups to at most 10 per SPF check, including any
# lookups caused by the use of the "include" mechanism or the
# "redirect" modifier. If this number is exceeded during a check, a
# PermError MUST be returned. The "include", "a", "mx", "ptr", and
# "exists" mechanisms as well as the "redirect" modifier do count
# against this limit. The "all", "ip4", and "ip6" mechanisms do not
View sh.sh
#!/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//\\/\/}"
View nginx.firewall.plist
<!-- 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
View .gitignore
*.dat
*.png
*.txt
pcsensor-temper
View background.js
function open(url, tabId) {
console.log(`vlc://${url}`);
// Open a new tab to start the prompt
chrome.tabs.create({url: `vlc://${url}`}, function(newtab) {
// Focus the old tab
chrome.tabs.update(tabId, {active: true});
// You have 10 seconds to click the button
// If the tab is closed too soon, the button no longer works :(
setTimeout(function(){
View main.js
if (document.body.children.length == 1 && document.body.children[0].tagName == "VIDEO") {
document.body.children[0].style.width = "100%";
}
View altdrag-toggle.ahk
; 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
View download-slack-emoji.sh
#!/bin/bash
# get a token from https://api.slack.com/custom-integrations/legacy-tokens
# or if you don't have permissions to create one, you can inspect the Slack web client and you can get the one it is using
SLACK_TOKEN=
curl -q -s "https://slack.com/api/emoji.list?token=$SLACK_TOKEN" | jq -Mr '.emoji | to_entries | .[] | select(.value | startswith("http")) | "\(.key) \(.value)"' | sort | while read name url; do
fn="$name.${url##*.}"
echo "$fn"
curl -q -s -o "$fn" "$url"
done
View .gitignore
*.tsv
*.gz
*.dat
*.png
*.json
View heroku-replay.sh
#!/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")