Skip to content

Instantly share code, notes, and snippets.

@jaysoffian
jaysoffian / .bashrc
Created February 1, 2017 20:17
.bashrc for staging/production machines
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
set_prompt() {
local titlebar red yellow reset
#!/bin/sh
usage () {
cat >&2 <<'__USAGE__'
usage: git gsr [-P | --perl-regexp] <old> <new> [paths...]
replace all occurrances of <old> with <new> optionally limited to
<paths...> (as interpreted by git grep)
-P, --perl-regexp interpret <old> as perl regular expression;
@jaysoffian
jaysoffian / kurosawa_top_100.py
Created March 23, 2021 17:59
Convert Akira Kurosawa's top 100 films to a CSV for import to Letterboxd
#!/usr/bin/python3
"""
Convert Akira Kurosawa's top 100 films to a CSV for import to Letterboxd.
List extracted from https://www.openculture.com/2015/01/akira-kurosawas-list-of-his-100-favorite-movies.html
"""
LIST = """
1. Broken Blossoms or The Yellow Man and the Girl (Griffith, 1919) USA
@jaysoffian
jaysoffian / git-lost-and-found
Last active July 15, 2022 21:30
"git lost-and-found" command to help recover objects you added but failed to commit and then deleted by accident
#!/bin/sh
find .git/objects -mtime -2h -type f | while read -r path
do
dir=${path#.git/objects/}
dir=${dir%/*}
name=${path##*/}
id=$dir$name
type=$(git cat-file -t "$id")
if test "$type" = blob
then
@jaysoffian
jaysoffian / gem-install.sh
Last active March 29, 2023 23:02
A script to install one or more gems in a self-contained directory, similar to installing Python packages in a virtual environment
Replaced by gem-venv.sh.
Please see https://gist.github.com/jaysoffian/3c67711d3f00c364365905d877cc4af4 instead.
@jaysoffian
jaysoffian / gem-venv.sh
Last active October 29, 2023 00:13
Like a Python venv, but for installing Ruby gems
#!/bin/bash
# gem-venv.sh
# ~~~~~~~~~~~
# Summary: Like a Python venv, but for installing Ruby gems.
#
# Create a directory and gem wrapper script for installing gems self-contained
# to that directory. Control which `gem` is used via the `-G/--gem` switch,
# defaulting to whatever `gem` is found in PATH.
#
# Optionally takes a list of gems to install using the just created directory