Screen Shot 2014-11-24 at 10.31.40 AM

Making curl + github easy / case sensitive github code search

Create a visible / easy to reuse token in https://github.com/settings/applications by storing the token in the application name.

Screen Shot 2014-11-24 at 10.31.40 AM

 

Use curl to search for code (notice the per-page 100) and grep case sensitive.


curl -s -H 'Accept: application/vnd.github.v3.text-match+json' --user "TOKEN_GOES_HERE:x-oauth-basic" 'https://api.github.com/search/code?per_page=100&page=3&q=user:YOURORG+SEARCHTERM' | grep 'SearchTERM'

 

Cleaning up unmanaged files in boxen / puppet

Nginx and env files .. maybe others … get a mess after a while of trying different branch, since they are never auto-cleaned up. Already made this into a PR, but nobody seems to care … so fix it via overwrites.

Add an empty directory as modules/ours/files/emptydir + .gitkeep (pick whatever you want for ‘ours’).

  # remove any unmanaged configs
  # https://github.com/boxen/puppet-nginx/pull/34
  File <| title == $nginx::config::configdir |> {
    purge => true,
    force => true,
    source => "puppet:///modules/ours/emptydir",
    recurse => "true",
  }

  File <| title == $nginx::config::sitesdir |> {
    purge => true,
    force => true,
    source => "puppet:///modules/ours/emptydir",
    recurse => "true",
  }

  File <| title == $boxen::config::envdir |> {
    purge => true,
    force => true,
    source => "puppet:///modules/ours/emptydir",
    recurse => "true",
  }

Stop rails from swallowing after_commit exceptions

Problem
By default rails just swallows any exception raised in after_commit blocks.

Solution
Send these exceptions to and exception service to get notified (Airbrake / Rollbar etc).

Gem
https://github.com/grosser/after_commit_exception_notification

Copy-paste

module Foo
  module CommittedWithExceptions
    def committed!
      super
    rescue Exception => e # same as active_record/connection_adapters/abstract/database_statements.rb:370
      ExceptionService.report("after_commit exception", e)
      raise
    end
  end
end

ActiveRecord::Base.include Foo::CommittedWithExceptions