Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Toomey christoomey

View GitHub Profile
@christoomey
christoomey / sql_query_countiner.rb
Created May 19, 2020
SQL Queries Summaries helper
View sql_query_countiner.rb
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):
#
View news_link_spec.rb
View strip_extraneous_whitespace.vim
" 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 Nov 3, 2015
Reliable button markup for use in email templates
View email-button-markup.html
<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>
View debugging.md
  • 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 Jul 22, 2014
Collection of Reading on JS Promises
View promises.md

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 Jan 4, 2018
Configuration for better JSON editing in Vim
View json-vim-config.md

Install jsonlint to act as syntastic json checker:

$ npm install jsonlint -g

Tell syntatastic about it:

" in your ~/.vimrc
View keybase.md

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 Aug 29, 2015
Angular $watch gotcha
View angular.md

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 Aug 29, 2015
Talk notes from my Vim for Ruby and Rails talk at BostonRb's March 2014 meetup
View vim-bostonrb-talk-notes.md
You can’t perform that action at this time.