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):
#
" Strip extraneous whitespace (duplicate or trailing) in current paragraph.
function! s:StripDuplicateWhitespace()
let save_cursor = getpos(".")
normal! {jms
normal! }me
's,'es/\S\@<=\s\{2,}/ /g
's,'es/\s\+$//
call setpos('.', save_cursor)
endfunction
command! StripDuplicateWhitespace call <sid>StripDuplicateWhitespace()
@christoomey
christoomey / email-button-markup.html
Created November 3, 2015 14:54
Reliable button markup for use in email templates
<div><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://upcase.com/rails?utm_source=jb-copy-new-rails-dream-job&amp;utm_medium=email&amp;utm_campaign=day-1-of-5-assessing-your-skills-and-filling-in-the-gaps" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="10%" strokecolor="#b6bc38" fillcolor="#db6d14">
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:18px;font-weight:bold;">See the Rails Trail</center>
</v:roundrect>
<![endif]--><a href="https://upcase.com/rails?utm_source=jb-copy-new-rails-dream-job&amp;utm_medium=email&amp;utm_campaign=day-1-of-5-assessing-your-skills-and-filling-in-the-gaps">See the Rails Trails</a></div>
  • Demo error
  • Describe feature spec
  • rails/info
  • discuss ctags of gems (link to videos)
  • better_errors
  • binding.pry
    • show_source
  • bundle show --paths
    • Upcase spec/features/user_accepts_team_invitation_spec.rb:13 (using_session)
  • method(:using_session).source_location
@christoomey
christoomey / promises.md
Created July 22, 2014 14:19
Collection of Reading on JS Promises

JS Promises

[Intro to Q library][] is a great starting point

Other recommended reading:

  • [PromisesJS Intro Article][] a good starting place
  • A good [article about what exactly promise objects are][]
  • [Great article][] that builds up a simple Promise implementation incremenetally
@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

Keybase proof

I hereby claim:

  • I am christoomey on github.
  • I am christoomey (https://keybase.io/christoomey) on keybase.
  • I have a public key whose fingerprint is DFE3 B12A 74A7 63B1 3CF9 CEC6 9273 CF6D 703D CCC8

To claim this, I am signing this object:

@christoomey
christoomey / angular.md
Last active August 29, 2015 13:57
Angular $watch gotcha

Turns out that angular $watch statements will always fire once to "initialize" the 'watch' statement. The officially recommended workaround, should you not want this behavior, is to use an object identity check to compare the values, ie:

$scope.$watch 'allProviders', (selected, prior) ->
  return if selected is prior
  ...
@christoomey
christoomey / vim-bostonrb-talk-notes.md
Last active August 29, 2015 13:57
Talk notes from my Vim for Ruby and Rails talk at BostonRb's March 2014 meetup