Skip to content

Instantly share code, notes, and snippets.

View brandonpittman's full-sized avatar

Brandon Pittman brandonpittman

View GitHub Profile
@brandonpittman
brandonpittman / VO2MDToggle.vim
Last active August 29, 2015 14:03
Quickly convert .otl <=> .md
function! VO2MD()
let lines = []
let was_body = 0
for line in getline(1,'$')
if line =~ '^\t*[^:\t]'
let indent_level = len(matchstr(line, '^\t*'))
if was_body " <= remove this line to have body lines separated
call add(lines, '')
endif " <= remove this line to have body lines separated
call add(lines, substitute(line, '^\(\t*\)\([^:\t].*\)', '\=repeat("#", indent_level + 1)." ".submatch(2)', ''))
@brandonpittman
brandonpittman / SortMappings.vim
Last active August 29, 2015 14:03
Sort mappings for Vim
" Sort shortcuts
vnoremap <silent> <Leader>S :sort<CR>
nnoremap <silent> <Leader>S :sort<CR>
function! CleanSpell()
runtime spell/cleanadd.vim
endfunction
@brandonpittman
brandonpittman / change.sh
Created July 14, 2014 02:11
Shell function to enhance the standard 'cd' behavior.
# Alias to `cd` for best effect
change() {
cd "$1"
clear
ls -al
}
@brandonpittman
brandonpittman / defer.zsh
Last active August 29, 2015 14:04
Defer file[s] function for zsh
# Usage: defer file1 [file2] [...] date
function defer () {
date=${*: -1}
folder="$DEFERRED/$date"
for i in "$@"; do
if [ "$i" != "$date" ]; then
mkdir -p "$folder" && mv "$i" "$folder/$i"
fi
@brandonpittman
brandonpittman / DoubleQuoteShellVariables.vim
Last active August 29, 2015 14:05
Vim regex to double quote shell script variables
:%s/\v(\$\w+)/"\1"/g
@brandonpittman
brandonpittman / times.exs
Created September 2, 2014 23:40
Solution to Programming Elixir named functions exercise
defmodule Times do
def double(n) do
n * 2
end
def triple(n) do
n * 3
end
def quadruple(n) do
#!/usr/bin/env elixir
System.cmd("open", ["sticky-notifications://note?message=#{System.argv}"])
@brandonpittman
brandonpittman / spec.zsh
Last active August 29, 2015 14:06
Rspec function
function spec () {
if [[ -d spec ]]; then
clear
rspec
else
echo "\033[1;31m\n No Rspec directory found! \033[0m"
return 1
fi
}
@brandonpittman
brandonpittman / Afternoon.applescript
Last active August 29, 2015 14:06
Defer OmniFocus tasks to the afternoon 'smartly'.
property usesFlagsForScheduling : false -- true or false, true flags any tasks that the script runs on
property methodForScheduling : "Start" -- Options are "Start", "Due", or "Start and Due"
property useGrowlForAlerts : true -- true or false
property promptForUserOptions : false -- will change after first run
global setToTomorrow
# Checks to see if it's after 5pm
set setToTomorrow to false
if hours of (current date) ≥ 17 then
set setToTomorrow to true