Skip to content

Instantly share code, notes, and snippets.

@brymck
brymck / buildkite-bazel-gce.sh
Last active August 31, 2020 07:16
Install Buildkite with Bazel on GCE
# I'm using a Debian 9 image on an n1-standard-1 machine type
#-----------------------------------------------------------------------------------------------------------------------
# Configuration
#-----------------------------------------------------------------------------------------------------------------------
# This is the token you get from going to
# https://buildkite.com/organizations/your-organization/agents
# and clicking Reveal Agent Token
BUILDKITE_AGENT_TOKEN=foo
@brymck
brymck / buildkite-bazel.sh
Last active September 18, 2020 07:43
Install Buildkite with Bazel on an EC2 instance
# I use the Amazon Linux 2 AMI on a t3.medium (2 vCPU, 4 GiB memory) instance attached to a 20 GB volume
#-----------------------------------------------------------------------------------------------------------------------
# Configuration
#-----------------------------------------------------------------------------------------------------------------------
# This is the token you get from going to
# https://buildkite.com/organizations/your-organization/agents
# and clicking Reveal Agent Token
export BUILDKITE_AGENT_TOKEN=foo
@brymck
brymck / trigramfuzzyset.py
Last active April 28, 2018 17:12
Fairly fast trigram fuzzy set implementation
# based on fuzzyset but considerably optimized to focus on trigrams and cosine similarity and be immutable through public
# interfaces after initialization
import re
from math import sqrt
from operator import itemgetter
from collections import defaultdict
_non_word_sub = re.compile(r'[^\w, ]+').sub
class TrigramFuzzySet(object):
@brymck
brymck / cusip.clj
Created May 19, 2014 00:03
Appends the check digit to a CUSIP
;; Example usage:
;; (cusip "ABCD1234")
;; => "ABCD12348"
(use '[clojure.string :as string])
(defn clean-cusip
"Converts a string into an unchecked 8-character CUSIP, padding with '0' if
necessary"
[s]
@brymck
brymck / clojure_big_o.md
Created January 5, 2014 09:36
Clojure Big-O

Clojure Big-O

op hash-map sorted-map hash-set sorted-set vector queue list lazy seq
conj log32n log2n log32n log2n 1 1 1 1
assoc log32n log2n - - log32n - - -
dissoc log32n log2n - - - - - -
disj - - log32n log2n - - - -
nth - - - - log32n n n n
get log32n log2n log32
@brymck
brymck / color_cells.bas
Created September 20, 2012 08:41
Color all cell background and foreground indices
' For when you want to preserve color indices when saving from Excel 2007+ to
' .xls format. Copy into PERSONAL.XLS or your worksheet and run with
' Alt+F11, Ctrl+G, ColorCells()
Private Const StartRow As Integer = 2
Private Const StartCol As Integer = 2
Private Const LastColorIndex As Integer = 56
Public Sub ColorCells()
Dim i As Integer
@brymck
brymck / kill_java.bat
Created September 4, 2012 06:58
Kill off a Java process with better information than what Task Manager gives you
@echo off
rem List all running Java processes, excluding useless metrics
tasklist /fi "IMAGENAME eq javaw.exe" /fo LIST /v ^
| find /v "Session" ^
| find /v "User" ^
| find /v "CPU" ^
| find /v "Status"
echo.
:user_input
@brymck
brymck / flickr_set.rb
Created September 3, 2012 13:40
Download all photos from a set in Flickr
#!/usr/bin/env ruby
# To get a list of available albums:
# flickr_set.rb bryanmckelvey
#
# To download an album:
# flickr_set.rb bryanmckelvey "Fall 2011"
require "fleakr"
# Get an API key at http://www.flickr.com/services/apps/create/apply
@brymck
brymck / changeInput.sh
Created August 6, 2012 15:41
Assign input method to a keyboard shortcut in Mac
#!/bin/sh
# Run with
# curl -L https://raw.github.com/gist/3275691/changeInput.sh | sh
git clone git://gist.github.com/2146751.git changeInput
cd changeInput
gcc t.m -o changeInput -lobjc -framework foundation -framework carbon
cp changeInput ~/bin
# Then open Automator and create something like:
# Service
@brymck
brymck / hoge.tex
Created August 6, 2012 14:40
Bare minimum Japanese LaTeX skeleton
% bare minimum Japanese document for Mac
%
% build with:
% latexmk -pdf hoge.tex
\documentclass[11pt]{article}
\usepackage[top=0.5in, bottom=0.75in, left=0.75in, right=0.75in]{geometry}
\usepackage{xltxtra}
\XeTeXlinebreaklocale "ja"
\setmainfont[Mapping=tex-text]{Hiragino Mincho Pro W3}