Skip to content

Instantly share code, notes, and snippets.

Burke Libbey burke

Block or report user

Report or block burke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ,
# usage example:
# $ , yarn --help
# This finds a derivation providing a bin/yarn, and runs it with `nix run`.
# If there are multiple candidates, the user chooses one using `fzy`.
set -euo pipefail
if [[ $# -lt 1 ]]; then
>&2 echo "usage: , <program> [arguments]"
burke /
Last active Oct 22, 2019
Code Release for NixCon 2019

The rest of these files are the code referenced in my NixCon 2019 talk which live in Shopify's non-public codebases. Everything in this gist is extracted with minimal or no change from our codebase, and thus some of it references libraries or other code not included here. cli-ui and cli-kit probably comprise a majority of these cases.

All code Copyright Shopify, 2019, released here under MIT License.

View ohno.rb
module Ohno
def self.replace_index(welp, index)
case welp
when String
welp == "$index" ? index : welp.gsub(/\$index/, index.to_s)


Replacing a space with a newline doesn't obey indentation rules:

  def foo(x)
    a = x.each { |e| puts(e) }
                  # ^ put cursor here and press `r<cr>`.
View centers.rb
#!/usr/bin/ruby --disable-gems
out, stat = Open3.capture2('qpdf', '--qdf', '--object-streams=disable', 'left-key-spacing.pdf', '-')
abort('qpdf fail') unless stat.success?
# coordinates are indexed from top-left, x is horizontal; y is vertical
View helm-dev.el
;;; helm-dev.el --- dev cd - projectile/helm interface. -*- lexical-binding: t -*-
;; Version: 1.0.0
;; Package-Requires: ((helm "1.5") (cl-lib "0.5") (emacs "24.1"))
;;; Code:
(require 'cl-lib)
(require 'helm)
(require 'helm-utils)
View http-promise.rb
ctx =
ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER)
raw_sock =, 443)
ssl_sock =, ctx)
ssl_sock.hostname = host
ssl_sock.sync_close = true
View prepend_path.bash
function prepend_path () {
local path; path=$1; shift
export PATH="$(
awk -v RS=: -v "prepend=$path" '
BEGIN { a = prepend ":" }
$0 != prepend { a = a $0 ":" }
END { print(substr(a, 1, length(a)-1)) }
' <<< $PATH
View one-file-cli-kit.rb
#!/usr/bin/env ruby
require 'cli/ui'
require 'cli/kit'
View darkness.rb
# detects whether a terminal is dark-on-light or light-on-dark.
# Only purposefully supports and iTerm, but a bunch of things use
module BackgroundDetector
DARK = :dark
LIGHT = :light
def terminal_app
theme = `/usr/libexec/PlistBuddy -c "Print :'Default Window Settings'" ~/Library/Preferences/`.chomp
blob = `/usr/libexec/PlistBuddy -c "Print :'Window Settings':'#{theme}':BackgroundColor" ~/Library/Preferences/`.chomp
You can’t perform that action at this time.