Skip to content

Instantly share code, notes, and snippets.

View christoomey's full-sized avatar

Chris Toomey christoomey

View GitHub Profile
@christoomey
christoomey / sql_query_countiner.rb
Created May 19, 2020 14:22
SQL Queries Summaries helper
module SqlQueryCountingHelpers
# This helper can be used to instrument a segment of test code to analyze the
# SQL queries being executed for that portion of the code path.
#
# It's intended to be used around specific portions of a spec rather than an
# entire spec as the FactoryBot usage adds a good amount of noise to the SQL
# analysis due to the many objects & associations created.
#
# Usage example (using spec/requests/api/v1/projects_spec.rb):
#
@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 / gist:1206762
Created September 9, 2011 17:09
Linode Ubuntu 10.04 (Lucid) with passenger & nginx for rails hosting
#################################################################
# #
# A guide to setting up a linode Ubuntu VPS for #
# Ruby on Rails hosting with nginx & passenger #
# #
# Compiled by Chris Toomey [ctoomey.com] on Sept. 9 2011 #
# #
#################################################################
# Start with base 10.04 image. Setup the DNS for any domains you
@christoomey
christoomey / json-vim-config.md
Last active January 4, 2018 18:24
Configuration for better JSON editing in Vim

Install jsonlint to act as syntastic json checker:

$ npm install jsonlint -g

Tell syntatastic about it:

" in your ~/.vimrc
@christoomey
christoomey / gist:1238761
Created September 24, 2011 00:12
nginx management script
#! /bin/sh
### BEGIN INIT INFO
#
# Source https://raw.github.com/jnstq/rails-nginx-passenger-ubuntu/master/nginx/nginx
#
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@christoomey
christoomey / log.js
Created April 29, 2011 00:29
Wrapper for console.log
// usage: log('inside coolFunc',this,arguments);
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
# 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 / 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'