Skip to content

Instantly share code, notes, and snippets.

@twolfson
twolfson / main.sh
Created April 13, 2018 23:34
Increment README version script
#!/usr/bin/env bash
# Exit on first error, unset variable, or pipe failure
set -euo pipefail
# Define our constants
README_FILEPATH="README.md"
# Resolve our version being deployed
# **1.0.0** -> 1.0.0
version="$(grep -E "\*\*\d+\.\d+\.\d+\*\*" "${README_FILEPATH}" | sed "s/\*//g")"
@twolfson
twolfson / main.rb
Last active March 16, 2018 18:42
Pipe child process stdout and stderr to main process in Ruby
Open3.popen3("./tmp.sh") do |stdin, stdout, stderr, wait_thr|
# Stream output
# DEV: We'd like to stream both `stderr` and `stdout` but it was getting troublesome
# with `.alive?` and `gets()` blocking each other
while line = stdout.gets()
$stdout.puts(line)
end
# Finish any last stderr or stdout
stdout_remainder = stdout.read()
@twolfson
twolfson / main.sh
Last active October 22, 2021 05:32
Increment CFBundleVersion script, generally reusable for incrementing version in bash
#!/usr/bin/env bash
# Exit on first error, unset variable, or pipe failure
set -euo pipefail
# Define our constants
PLIST_FILEPATH="path/to/plist.plist"
# Resolve our version being deployed
# https://gist.github.com/sekati/3172554
# DEV: `plutil` doesn't support extraction easily (could use `-o -` but it's wrapped in XML/binary/JSON)
@twolfson
twolfson / IconDisabled.png
Created December 16, 2017 11:52
Proof of concept to demonstrate how `tabs.sendMessage` refuses to send in Firefox's responive design mode
IconDisabled.png
@twolfson
twolfson / IconDisabled.png
Last active December 16, 2017 11:53
Proof of concept to demonstrate how `runtime.onMessage` is missing tab in Firefox's responive design mode
IconDisabled.png
@twolfson
twolfson / README.md
Last active November 17, 2017 07:42
Xcode customizations

It's my first time setting up Xcode but I want to keep track of my preferences (probably move it to a dotfile if it becomes serious). Here's our notes:

  • Navigation
    • Navigation: Uses Focused Editor
  • Fonts & Colors
    • Theme: Default
  • Text Editing
    • Editing
      • Page guide at column: 120
  • Source Control
@twolfson
twolfson / README.md
Last active November 14, 2017 08:41
Replace Gratipay content with support me page

I've been adding Gratipay to my README's for a long time. As a result of Gratipay shutting down, I need to update all of my README content. Here's my strategy:

Script

@twolfson
twolfson / README.md
Last active November 10, 2017 00:24
RAILS_ENV overloading with `bin/rake` and `config/boot.rb`

We are using dotenv with Rails and Spring but running into timing issues where Dotenv loads/assumes we're in development before RSpec can override RAILS_ENV

To prevent this from happening consistently, we've added a patch in bin/rake and config/boot.rb

We verified our patch works with puts in spec/rails_helper.rb:

puts("RAILS_ENV", ENV["RAILS_ENV"])
puts("S3_REGION", ENV["S3_REGION"])
ENV["RAILS_ENV"] ||= "test"
@twolfson
twolfson / .gitignore
Last active August 27, 2020 12:05
Proof of concept digraph visualization
node_modules/
@twolfson
twolfson / README.md
Last active November 1, 2017 04:02
KaTeX files for "Practical applications of the dot product" blog post

gist-dot-product-katex

KaTeX files for "Practical applications of the dot product" blog post

Documentation

File structure

We are using BEM notation for our filenames where the "block" is our proof and "element" is the equation in the proof. For example:

  • "projection__cosTheta-equals-axisLength.tex" has proof "projection" and step "cosTheta-equals-axisLength"
    • We try to use camelCasing to associate relevant terms (e.g. length, operations, functions)