Skip to content

Instantly share code, notes, and snippets.

@mattes
mattes / gist:5869665
Last active December 19, 2015 00:38
sh test
#!/bin/sh
# curl https://gist.github.com/mattes/5869665/raw | sh
echo "hello world"
{
"bold_folder_labels": true,
"create_window_at_startup": false,
"font_size": 12,
"open_files_in_new_window": true,
"rulers":
[
80
],
"show_full_path": false,
curl https://gist.github.com/mattes/00112233/raw | bash
@mattes
mattes / helpers.sh
Created July 10, 2013 17:44
bash helpers
function installed? { command -v $1 >/dev/null 2>&1; }
function dir? { [[ -d $1 ]]; }
function brew_installed? { brew list | grep -x $1 >/dev/null 2>&1; }
@mattes
mattes / gist:5999246
Last active December 19, 2015 18:29
my mac setup
# xcode install
# brew install
# http://mxcl.github.io/homebrew/
# git install
# https://help.github.com/articles/set-up-git
# brew install rbenv && ruby-build
# https://github.com/sstephenson/ruby-build
# install sublime text
sed -i '' -e 's/#port = 5432/port = 50725/' local/var/pgsql/data/postgresql.conf
@mattes
mattes / pre-commit
Last active December 21, 2015 05:28
Git pre-commit hook. Verify this repository has a clean work tree.
#!/bin/sh
# see also ...
# https://github.com/git/git/blob/master/git-sh-setup.sh#L168
# Verify this repository has a clean work tree.
# Return false (= 0), if there are any unstaged/ uncommitted changes.
# Return true (= 1), if there are no changes in the repository.
has_clean_work_tree () {
git rev-parse --quiet --verify HEAD &> /dev/null || return 0 # false
@mattes
mattes / pid-file.sh
Last active December 24, 2015 04:09
pid-file.sh <pid-file> <appear|disappear> [wait sec]
#!/usr/bin/env bash
file=$1
to=$2
wait_seconds=$3 # optional
[[ $file == "" ]] && echo "No file given." && exit 1
[[ $wait_seconds == "" ]] && wait_seconds=10
[[ $to == "" ]] && echo "Wait for file to appear or disappear?" && exit 1
@mattes
mattes / gist:6888820
Last active December 25, 2015 00:38
create random password
echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
echo "$(date +%y)$(openssl rand -hex 4)"
@mattes
mattes / rbenv-install.sh
Last active January 7, 2017 00:34
rbenv one-line installer
#!/usr/bin/env bash
# curl https://gist.github.com/mattes/6989885/raw/rbenv-install.sh | bash
if [[ $(uname) == "Darwin" ]]; then
brew install rbenv ruby-build
echo "Add the following to ~/.bash_profile ..."
echo 'eval "$(rbenv init -)"'
else
# linux ...