This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# a simple command line tool that acts like Guard, but you can run any arbitrary command on any set of arbitrary files that change. | |
# | |
# Example usage: | |
# | |
# # Run test when a certain 3 files are modified. | |
# myguard.rb "ruby test_foo.rb" foo.rb foo_test.rb foo.json | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detect which `ls` flavor is in use (Mac or Linux) | |
if ls --color > /dev/null 2>&1; then | |
ls_color_flag="--color" # GNU/Linux | |
else | |
ls_color_flag="-G" # BSD/macOS | |
fi | |
# Always show color when interactive | |
alias ls="ls ${ls_color_flag}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn inclusive-range | |
"Like range, but STOP (when defined) is inclusive. Leads to simpler code | |
without all the inc'ing etc. E.g., | |
(inclusive-range 1 5) #=> (1 2 3 4 5)" | |
([] (range)) | |
([stop] (range (inc stop))) | |
([start stop] (range start (inc stop))) | |
([start stop step] (range start (inc stop) step))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pbpaste | |
IO.popen(["xclip", "-o"]).read | |
end | |
alias paste pbpaste | |
class Object | |
def pbcopy | |
Thread.new do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U edit-command-line | |
zle -N edit-command-line | |
bindkey '^xe' edit-command-line | |
bindkey '^x^e' edit-command-line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
(date_col - (extract(dow from date_col) || ' day')::interval)::date as week_of_starting_sunday | |
from | |
mytable | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Makefile | |
# | |
# Format: | |
# [target]: [dep1 [dep2 ...]] | |
# <tab>command(s) that build target | |
# | |
# Be sure to use actual tab characters for indentation before commands. | |
# | |
# Cheat sheet: | |
# $@ -> refers to the current target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -ex | |
sudo apt update | |
sudo apt install -y cargo | |
cd ~/repos | |
git clone --depth=1 https://github.com/BurntSushi/ripgrep | |
cd ripgrep | |
cargo build --release | |
./target/release/rg --version | |
sudo ln -s $PWD/target/release/rg /usr/local/bin/rg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# The goal here is a script that can be called like this: | |
# | |
# sqlite-now-mem users.tsv,users,id,login,email products.tsv,products,id,name | |
# | |
# For each comma-separated tuple passed are arguments, the input file | |
# will be loaded into the table, and any following values are the | |
# names of columns for which indexes will be created. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use File::Basename qw(basename); | |
my $PROGRAM = basename($0); | |
if ($ARGV[0] =~ /^(?:-h|--help)$/) { | |
print "Turn blanks from TSV input lines into \\N for mysqlimport consumption.\n"; | |
print "Usage examples:\n"; |
OlderNewer