Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
RobertAudi / ts
Created March 6, 2014 13:40
ZSH wrapper around tarsnap
#!/usr/bin/env zsh
commandIsValid() {
cmds=( "h" "help" "l" "list" "z" "zip" "rm" "remove" )
local cmd="$1"
for e in $cmds[@]; do
if [[ "$e" == "$cmd" ]]; then
return 0
fi
@RobertAudi
RobertAudi / shot
Last active August 29, 2015 13:57
Take a screenshot and upload it to imgur.com, all from the command-line. OS X and ZSH. Inspired by https://github.com/JonApps/imgur-screenshot
#!/usr/bin/env zsh
#### CONFIG #######################################################################################
#### !!! REQUIRED !!! Put your imgur API key in the `IMGUR_KEY` environment variable.
#### Image format
# local image_format="jpg"
#### Show cursor (only in full screen screenshots)
export ORIG_GEM_PATH=${GEM_PATH:-}
export ORIG_GEM_HOME=${GEM_HOME:-}
export ORIG_PATH=${PATH}
omg() {
if [[ "$1" =~ "^h(elp)?\$" ]]; then
echo "Usage: omg [h|help|r|reset]"
elif [[ "$1" =~ "^r(eset)?\$" ]]; then
if [[ -z "$ORIG_GEM_HOME" ]]; then
unset GEM_HOME
@RobertAudi
RobertAudi / TweetbotRSSmode.md
Created March 12, 2014 11:35
Mute tweets with no links in them in Tweetbot

Tweetbot RSS mode

^(.(?!(https?://|\.[a-z]{2,6})))*$
@RobertAudi
RobertAudi / cvimrc.vim
Last active August 29, 2015 14:01
cVim custom mappings (Vim for Chrome)
let barposition = "bottom"
set numerichints
set typelinkhints
unmap gt
unmap K
unmap gT
unmap J
unmap E
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
set hlsearch
highlight CurSearch guibg=green
nnoremap <silent> N N:silent! call HighlightCurrentMatch()<CR>
nnoremap <silent> n n:silent! call HighlightCurrentMatch()<CR>
function! HighlightCurrentMatch()
let col = col(".") - 1
let endCol = searchpos(getreg("/"), "cne")[1] + 1
let line = line(".")
let matchPat = '/\%' . line . 'l\%>' . col . 'c\%<' . endCol . 'c/'
@RobertAudi
RobertAudi / autoenv
Last active August 29, 2015 14:05
My take on directory-specific environments on the command-line
#!/usr/bin/env zsh
#
# USAGE: autoenv [action]
#
# Actions:
# up (aliased to u)
# down (aliased to d)
#
error() { echo "$@" 1>&2 }
#
# Generate a unique token before the creating a
# new record. Option to specify an array of
# attributes as predicates for the uniqueness check.
# The tokenable attribute is always appended to
# the list of predicates.
#
# Example usage in a model:
#
# class Contribution < ActiveRecord::Base
@RobertAudi
RobertAudi / BasicTerminal.scpt
Created June 30, 2010 03:06
Open a new Terminal.app window with the *Basic* color theme using applescript
tell application "Terminal" to activate
tell application "System Events"
tell process "Terminal"
tell menu item "Basic" of menu "New Window" of menu item "New Window" of menu "Shell" of menu bar item "Shell" of menu bar 1
click
end tell
end tell
end tell