⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const templatized = (template, vars = {}) => { | |
const handler = new Function('vars', [ | |
'const tagged = ( ' + Object.keys(vars).join(', ') + ' ) =>', | |
'`' + template + '`', | |
'return tagged(...Object.values(vars))' | |
].join('\n')) | |
return handler(vars) | |
} |
This is a compiled list of falsehoods programmers tend to believe about working with time.
Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.
- There are always 24 hours in a day.
- February is always 28 days long.
- Any 24-hour period will always begin and end in the same day (or week, or month).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ./pushover.sh -t "Pushover via Bash" -m "Pushover message sent with bash from $(hostname -f)" -p1 -s siren -u http://www.google.com -n "Google" | |
USER_TOKEN=YOUR_USER_TOKEN_HERE | |
# YOUR APPS TOKENS / UPPERCASE NAME WITH _TOKEN (usage: "-a monitor" uses MONITOR_TOKEN) | |
MONITOR_TOKEN=APP_TOKEN | |
BACKUP_TOKEN=APP_TOKEN | |
ALERT_TOKEN=APP_TOKEN | |
APP_LIST="monitor, backup, alert" # FOR USAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am doing this because the server admin forgot to | |
# Renew their certificate! | |
prev_setting = OpenSSL::SSL.send(:remove_const, :VERIFY_PEER) | |
OpenSSL::SSL.const_set(:VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE) | |
# do my connnection thang! | |
OpenSSL::SSL.send(:remove_const, :VERIFY_PEER) | |
OpenSSL::SSL.const_set(:VERIFY_PEER, prev_setting) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THIS STRING IS 256 CHARACTERS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
domain=$1 | |
port=$2 | |
if [ -z "$domain" ] || [ -z "$port" ]; then | |
echo "Usage: domain-alias <domain> <port>" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<root> | |
<appdef> | |
<appname>Terminal</appname> | |
<equal>com.apple.Terminal</equal> | |
</appdef> | |
<item> | |
<name>TMUX Key Remappings</name> | |
<item> | |
<name>TMUX: Right Control to Ctrl+B</name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pull-request { | |
hub pull-request -h $(__github_remote_origin):$(__github_current_branch) | |
} | |
function __github_remote_origin { | |
# Finds the origin on github if it is https or git | |
echo "$1`git remote -v | grep -e "^origin.* (push)" | sed "s#origin[[:blank:]]https://github.com/\([^/]*\)\/.*#\1#" | sed "s#origin.*:\([^/]*\).*push.*#\1#"`" | |
} | |
function __github_current_branch { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function eachAsync(collection, iterator, callback) { | |
var iterate = function(i) { | |
setTimeout(function() { | |
iterator(collection[i]); | |
if (i < collection.length) { | |
iterate(i + 1); | |
} else { | |
callback(); | |
} | |
}, 0); |
NewerOlder