Skip to content

Instantly share code, notes, and snippets.

@ericfreese
ericfreese / colors.itermcolors
Created January 17, 2016 20:00
iTerm Color Scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
num calls time self name
-----------------------------------------------------------------------------------
1) 2 3189.82 1594.91 98.07% 2649.66 1324.83 81.46% bracketed-paste-magic
2) 2553 3190.85 1.25 98.10% 119.65 0.05 3.68% _zsh_autosuggest_invoke_original_widget
3) 2552 3214.51 1.26 98.83% 115.11 0.05 3.54% _zsh_autosuggest_modify
4) 2552 3215.56 1.26 98.86% 94.16 0.04 2.90% _zsh_autosuggest_widget_modify
5) 2545 539.92 0.21 16.60% 83.57 0.03 2.57% (anon)
6) 2550 482.11 0.19 14.82% 51.35 0.02 1.58% _zsh_autosuggest_bound_self-insert
7) 2550 36.20 0.01 1.11% 36.20 0.01 1.11% _zsh_autosuggest_orig_self-insert
8) 2552 35.93 0.01 1.10% 35.93 0.01 1.10% _zsh_autosuggest_highlight_apply
# A proof of concept implementation of fetching history suggestions
# asynchronously using `coproc`
#
# See https://github.com/zsh-users/zsh-autosuggestions/issues/170
#
# Problems with this approach:
# - Requires MONITOR option not be set
# - Usage of coproc may conflict with end user
# - Usage of SIGUSR1 signal may conflict with end user
# - Spawns a new process for every suggestion, which seems excessive
@ericfreese
ericfreese / fetch_boulder_addresses.rb
Last active January 18, 2017 15:15
Download all valid addresses for Boulder, CO
#!/usr/bin/env ruby
require 'csv'
require 'active_support/all'
OUTPUT_FILENAME = 'boulder_addresses.txt'
if !FileTest.exist?("Owner_Address.csv")
puts 'downloading address data...'
`wget http://assessor.boco.solutions/ASR_PublicDataFiles/Owner_Address.csv`
@ericfreese
ericfreese / mq.styl
Created January 25, 2017 21:35
Stylus media query mixin
mq(from = null, to = null) {
width-query = null
if from {
width-query = 'min-width: ' + (from + 1px)
}
if to {
to-query = 'max-width: ' + to
@ericfreese
ericfreese / git-rewrite
Last active September 9, 2024 23:46
Git script to rewrite history in various ways
#!/bin/env zsh
# Run an interactive rebase, automatically marking $1 to be reworded
function git_rewrite_reword() {
GIT_SEQUENCE_EDITOR="sed -ie 's/pick $1/reword $1/'" \
git rebase -i --autostash $1^
}
# Run an interactive rebase, automatically marking $1 to be edited
function git_rewrite_edit() {
@ericfreese
ericfreese / emoji-line
Last active September 25, 2020 22:34
A kinda crappy swiss army knife for generating lines of emojis
#!/usr/bin/env zsh
program="${0:t}"
function usage() {
echo "usage: $program [--grep <pattern>] [--length <length>] [--sample <sample>] [--version <version>]" >&2
exit 1
}
function main() {

PostgreSQL Fiddle

Requires bash and docker.

Usage

./pg-fiddle start to start a docker container running a PostgreSQL server

While the server is running:

  • ./pg-fiddle schema to reset the schema of the database from schema.sql.

PostgreSQL Fiddle

Requires bash and docker.

Usage

./pg-fiddle start to start a docker container running a PostgreSQL server

While the server is running:

  • ./pg-fiddle schema to reset the schema of the database from schema.sql.
@ericfreese
ericfreese / delegated_macros.ex
Created February 10, 2023 23:38
Elixir delegated macros
# TODO: Doesn't handle delegating to a delegated macro
# TODO: Only works with `require`, not `import`
defmodule DelegatedMacros do
@callback delegated_macro_modules() :: [atom()]
# To be used into a module wanting to call delegated macros
defmacro __using__(from: module) do
quote do
require unquote(module)