Skip to content

Instantly share code, notes, and snippets.

View abatkin's full-sized avatar

Adam Batkin abatkin

View GitHub Profile
@abatkin
abatkin / listize.vim
Created May 6, 2013 02:42
Map \q to quote each line Map \j to join lines with a comma Map \s to quote and join all lines Works in visual mode only Great for taking a list of things and quoting for use in an SQL query
vnoremap <leader>q :<c-u>call <SID>QuoteLines()<cr>
vnoremap <leader>j :<c-u>call <SID>JoinLines()<cr>
vmap <leader>s <leader>qgv<leader>j
function! s:JoinLines()
silent! execute "normal! gv:\<c-u>'<,'>-1s/\\v$/,/g\<cr>gvJ"
endfunction
function! s:QuoteLines()
silent! execute "normal! gv:s/\\v(^\\s*)([^[:space:]].{-})(\\s*$)/\\1'\\2'\\3/\<CR>"
@abatkin
abatkin / School.java
Created February 15, 2013 13:20
School class with hashCode() and equals() From a challenge at http://beust.com/weblog/2013/02/13/coding-challenge-light-edition/
/*
* A few assumptions:
* * School is immutable (otherwise, implementing hashCode/equals doesn't really make sense)
* * The problem is incompletely specified, with respect to how to handle missing values:
* * What do you do when both name and nickname are null?
* * What if one School has a name + nickname and the other has just a name, but the names match?
* My decision (and I think this is reasonable) is: Both must match. If a value is null in one,
* it must be null in the other to be considered equal
*/
class School {
@abatkin
abatkin / id_rsa.pub
Created September 25, 2012 00:07
ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDw8vdRpf7ZpKf+eA3+Ify8ZMzFbUb0DoOZkRYHT9rQ7Rtjs3sB6bl5GgfKGX4y0cj8EiGmiPpsIylASEWeZKpf28stPDulc+pcr8we+A6XIuXPo1z8D4MLKXwg79XcHpa+Jr7OWef3JtkF5lv0z8Tpfr/nNyM/XcB9Opzawmz7sbtTVbEYnIMzPFvz5PgGFdm4yWO242yTuBMD5eLvldCpfeHQFRmohTkjVKJtDbjybVA2o6Mc8LS2K8E0mWTdo/V/fyR2MM/ekBfBXwLFkRusxQSC+3lpoFyQM++95f3DkID4HUUJTGUuDTEUZOr1u98HLtDTkucrgnLkfbC2Kvj abatkin@alpha.batkin.net
@abatkin
abatkin / .vimrc
Created June 21, 2012 03:57
Home vimrc (on linux)
call pathogen#infect()
syntax enable
filetype plugin indent on
set nocompatible
"if filereadable("$VIMRUNTIME/mswin.vim")
:so $VIMRUNTIME/mswin.vim
"endif
:behave mswin
@abatkin
abatkin / 20-aliases.zsh
Created June 21, 2012 03:55
ZSH aliases
alias ant='ant -logger org.apache.tools.ant.listener.AnsiColorLogger'
alias ll='ls --color=tty -lrt'
alias kde=". ~/kde/env.sh && cd ~/kde/src"
alias vi=vim
@abatkin
abatkin / 10-env.zsh
Created June 21, 2012 03:55
ZSH environment variables
export EDITOR=vim
export VISUAL=vim
export PAGER=less
# Also setup JAVA_HOME, ANT_HOME, PATH
@abatkin
abatkin / 06-keys.zsh
Created June 21, 2012 03:54
ZSH keybindings
bindkey '^[[B' down-line-or-history
bindkey '^[[A' up-line-or-history
@abatkin
abatkin / 05-zsh.zsh
Created June 21, 2012 03:53
ZSH option settings
setopt nocorrectall
setopt correct
@abatkin
abatkin / adambatkin.zsh-theme
Created June 21, 2012 03:53
My oh-my-zsh theme
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)$(git_prompt_short_sha)'
ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$fg[red]%}("
ZSH_THEME_GIT_PROMPT_SHA_AFTER=")%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
@abatkin
abatkin / .zshrc
Created June 21, 2012 03:52
My oh-my-zsh .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="adambatkin"
# Example aliases