Skip to content

Instantly share code, notes, and snippets.

@briangordon
briangordon / make-letters.sh
Created March 4, 2019 22:47
Shell script to make letter icons for Slack
mkdir letters
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:A letters/a.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:B letters/b.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:C letters/c.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:D letters/d.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:E letters/e.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:F letters/f.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:G letters/g.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:H letters/h.png
convert -background transparent -fill black -font Chalkduster -pointsize 72 label:I letters/i.png
# UFW configuration for a home DMZ box exposed to the public internet, with only sshd reachable from the outside world.
# In addition to setting these rules you should also:
# 1. Edit /etc/ufw/before.rules to remove the default rules which permit incoming DHCP packets from the outside world.
# 2. Edit /etc/ufw/before.rules to remove the default rules which permit incoming ICMP packets from the outside world.
# 3. Edit /etc/default/ufw to turn off non-local ipv6 because I don't know enough about it to be confident.
ufw default deny incoming
ufw default allow outgoing
ufw limit log proto tcp to 0.0.0.0/0 port ssh
ufw allow proto udp from 192.168.0.0/16 to 0.0.0.0/0 port bootpc comment "required for dhclient"
@briangordon
briangordon / bash_ps1.sh
Last active February 3, 2019 04:50
By default, Debian only colorizes bash output for regular users. Rather than copy your ~/.bashrc to /root, take just take it out and have /etc/bash.bashrc source this instead.
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
@briangordon
briangordon / DefaultKeyBinding.dict
Created January 25, 2019 06:54
Put this in ~/Library/KeyBindings/ to fix MacOS home/end keys behaving stupidly
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
@briangordon
briangordon / gist:d6014bc1b96f6d89a51ce7906cea9a03
Created November 16, 2018 00:29
Dtrace one-liner for watching readers of your chrome profile
dtrace -n 'syscall::open*:entry /strstr(copyinstr(arg0), "Chrome/Default") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' > chrome-accessors

Keybase proof

I hereby claim:

  • I am briangordon on github.
  • I am brian (https://keybase.io/brian) on keybase.
  • I have a public key ASA8l7cfD9ar5ZcXq_MkGZCVjV9B9eo9l1dpQ5D4LsgOsAo

To claim this, I am signing this object:

@briangordon
briangordon / git-review-aliases.txt
Last active September 16, 2022 17:51
Aliases for code reviewing GitHub pull requests using a GitFlow/OneFlow branching model
*****************************************************************************************************************************
Introduction
The code review workflow that I prefer is to check out a feature branch, then `reset --soft` to move the branch HEAD to
just before the changes. That way I still have all of the changes in my working copy, and those exact changes are staged
for commit. My IDE will highlight the changed lines right in the editor and let me click the gutter to view a quick diff.
This is incredibly useful. But problems arise when develop has been merged into a running PR, bringing along a whole bunch
of other unrelated changes that have already been reviewed. I don't want all of those other changes to be highlighted in
my IDE, but I do want them in my working copy.
package cellfactory
import javafx.application.Application
import javafx.collections.FXCollections
import javafx.scene.control.ListView
import javafx.scene.layout.StackPane
import javafx.scene.{Scene, control => jfxsc}
import javafx.stage.Stage
import javafx.util.Callback
@briangordon
briangordon / gist:df79f7cd3750ac9fe1109553c8262aee
Last active September 11, 2017 00:59
pureconfig ConfigReader for case class with "auxiliary constructor" type logic
case class HalfLife(lowerBoundHours: BigDecimal, upperBoundHours: BigDecimal, meanHours: BigDecimal)
def computeMean(lowerBoundHours: BigDecimal, upperBoundHours: BigDecimal): BigDecimal = {
// TODO linear interpolation is terrible here. These are exponential quantities.
(lowerBoundHours + upperBoundHours) / 2
}
// Hack to get pureconfig to create instances of HalfLife without an explicit mean-hours value.
import com.typesafe.config.{ConfigObject, ConfigValueFactory}
import pureconfig.ConfigReader
@briangordon
briangordon / animal-verbs.txt
Last active October 7, 2019 18:49
Animal names which are also verbs
Ape his behaviors
Badger her about
Bat your eyelids
Bear fruit
Buck the system
Buffalo him into
Bug him about
Carp about
Chicken out
Clam up