Skip to content

Instantly share code, notes, and snippets.

@briangordon
briangordon / Text to pixel array
Created March 10, 2013 06:09
HTML5 JavaScript snippet for turning arbitrary text into a binary array of pixel on/off
var buffer = document.createElement('canvas');
var bufContext = buffer.getContext("2d");
buffer.width = 60;
buffer.height = 20;
bufContext.fillStyle = "#FFFFFF";
bufContext.fillRect(0, 0, 60, 20);
bufContext.textBaseline = "top";
@briangordon
briangordon / eve-pathfinder.cpp
Last active January 3, 2017 19:43
My improved version of MagicalTux's EVE online path finder.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <sys/time.h>
// We specify the total number of systems explicitly so that we can initialize data structures before reading in the whole csv file.
@briangordon
briangordon / list-processes.ps1
Last active June 3, 2017 23:48
Short PowerShell snippet I wrote for repeatedly dumping all running processes less than a minute old to a file
while($true) {
Get-Process | ? {$_.StartTime -gt (Get-Date).AddMinutes(-1)} | Select-Object ProcessName,Description,Path >> out.txt
sleep 0.01
}
@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
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

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 / 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 / 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 / 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
@briangordon
briangordon / gitgraphjs.html
Created March 28, 2019 05:32
gitgraphjs.com (https://web.archive.org/web/20181222070223/http://gitgraphjs.com/) gives you the building blocks to start working with the JS version but leaves you to put it together. Here's a fully working example to get it running.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.15.1/gitgraph.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.15.1/gitgraph.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/domready/1.0.8/ready.js"></script>
<script type="text/javascript">
domready(function() {
var gitgraph = new GitGraph({
template: "blackarrow",