Skip to content

Instantly share code, notes, and snippets.

View mpouleijn's full-sized avatar

Michel Pouleijn mpouleijn

View GitHub Profile
@mpouleijn
mpouleijn / gist:2575613
Created May 2, 2012 09:48 — forked from stympy/gist:948168
Trace slow queries in Rails
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 5
THRESHOLD = 300 # In ms
def sql(event)
return unless event.duration > THRESHOLD
callers = Rails.
backtrace_cleaner.
site_name: 'Shopishop'
site_slogan: 'Shopping with bags'
site_logo: '<span>Shop</span><span class="purple">I</span><span class="oblique">Shop</span>'
default_locale: 'en'
# External services
airbrake_key: ''
s3_hostname: ''
PATH
remote: .
specs:
JDC-planning (0.0.2)
activesupport (= 3.0.9)
json
rake (= 0.8.7)
typhoeus (= 0.2.4)
yard
@mpouleijn
mpouleijn / development.rb
Created May 31, 2012 10:09
Mail Interceptor
# Register the interceptor for a environment
#
require "mail_interceptor"
AppName::Application.configure do
#...
config.action_mailer.register_interceptor(MailInterceptor)
end
require 'router'
use Rack::CommonLogger
use Rack::ShowExceptions
use Rack::Lint
use Rack::Static, :urls => ["/static"]
run Router.new
@mpouleijn
mpouleijn / $!.rb
Created June 4, 2012 07:02
5 things you didn't know about exceptions - By Avdi Grimm
# What the heck is $! ?
require 'English'
puts $!.inspect
begin
raise "Oops"
rescue
puts $!.inspect
puts $ERROR_INFO.inspect
@mpouleijn
mpouleijn / shared_example.rb
Created July 25, 2012 07:41
Minitest shared example
class MiniTest::Spec
def self.shared_examples
@shared_examples ||= {}
end
end
module MiniTest::Spec::SharedExamples
def shared_examples_for(desc, &block)
MiniTest::Spec.shared_examples[desc] = block
end
# code inspired from http://jainmarket.blogspot.com/2009/05/creating-custom-table-view-cell.html
class CustomCell < UITableViewCell
attr_accessor :primaryLabel
attr_accessor :secondaryLabel
def createLabels
@primaryLabel = UILabel.alloc.init
@mpouleijn
mpouleijn / gist:5d0d8f2a1a5e46f2875e
Last active September 4, 2015 08:32 — forked from jordelver/gist:3139365
How to write an image file to an SD card under Mac OS X (for Raspberry Pi)

Find the SD card device

In this case, the SD card is /dev/disk4. DO NOT get this wrong or you may destroy all the data on the wrong disk/card/drive.

diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0

1: EFI 209.7 MB disk0s1

Keybase proof

I hereby claim:

  • I am mpouleijn on github.
  • I am mpouleijn (https://keybase.io/mpouleijn) on keybase.
  • I have a public key whose fingerprint is A878 AA73 CF9B AF56 CAAA AB3E 0DD3 CFB7 85B4 9A99

To claim this, I am signing this object: