Skip to content

Instantly share code, notes, and snippets.

View christoomey's full-sized avatar

Chris Toomey christoomey

View GitHub Profile
" Change the current working directory to the directory that the current file you are editing is in.
nnoremap <Leader>cd :cd <C-R>=escape(expand('%:p:h'), ' ')<CR><CR>
" Opens a file with the current working directory already filled in so you have to specify only the filename.
nnoremap <Leader>e :e <C-R>=escape(expand('%:p:h'), ' ')<CR>/
nnoremap <Leader>s :split <C-R>=escape(expand('%:p:h'), ' ')<CR>/
nnoremap <Leader>v :vsplit <C-R>=escape(expand('%:p:h'), ' ')<CR>/
@christoomey
christoomey / notes.md
Last active August 29, 2015 13:56
Vim & Tmux Boston IO Talk Notes
# Kill current session and switch to next
tk () {
current_session=$(tmux display-message -p '#S')
tmux switch-client -n
tmux kill-session -t "$current_session"
}
@christoomey
christoomey / vim-range-command.vim
Created September 12, 2013 13:24
Vim command that accepts range
function! PrintGivenRange() range
echo "firstline ".a:firstline." lastline ".a:lastline
echo "firstline contents" . getline(a:firstline)
echo "lastline contents" . getline(a:lastline)
endfunction
command! -range PassRange <line1>,<line2>call PrintGivenRange()
vmap ,pr :PassRange<cr>
@christoomey
christoomey / tmux.conf
Created June 21, 2013 14:41
Tmux copy-pipe
# Use vim keybindings in copy mode
setw -g mode-keys vi
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
@christoomey
christoomey / fitbit.rb
Last active December 18, 2015 01:48
Fitbit & My Fitness Pal interactions
#!/usr/bin/env ruby
require "fitgem"
require "pp"
require "yaml"
config_file = begin
File.open(".fitgem.yml")
rescue Object => e
puts 'No .fitgem.yml config file found'
@christoomey
christoomey / perspective.mkd
Created December 6, 2012 01:50
Perspective Keymaps

Summary of the keymaps active on http://perspectiveapp.com. Note, these are only active on the /projects, /next, and /now pages.

Navigation

  • \<Esc> => Refocus the current list (projects, next, now)
  • g:p => Go to Projects page
  • g:x => Next Actions page
  • g:w => Now Items page
@christoomey
christoomey / spanWrapper.js
Created November 15, 2012 01:00
Compiled js version of spanWrapper utility
// Compiled js version of spanWrapper library written in coffeescript.
// Source code can be found in https://gist.github.com/4075843
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
window.CJT || (window.CJT = {});
CJT.SpanWrapper = (function() {
SpanWrapper.prototype.STRING_NOT_FOUND = -1;
@christoomey
christoomey / spanWrapper.js.coffee
Created November 15, 2012 00:31
Javascript utility to wrap instances of a search string within a target string
window.CJT or= {}
class CJT.SpanWrapper
STRING_NOT_FOUND: -1
constructor: (options={}) ->
@tagname = options.tagname ? 'span'
@classname = options.classname ? ''
wrap: (target, searchString) =>
@christoomey
christoomey / index.coffeescript
Created July 26, 2012 21:06
A web page created at CodePen.io.
preRender = ->
canvas = document.getElementById 'preRender'
context = canvas.getContext '2d'
radius = 20
centerX = centerY = radius + 1
context.beginPath()
context.arc centerX, centerY, radius, 0, (2 * Math.PI), false
x = Math.floor(radius - (radius / 3))