Skip to content

Instantly share code, notes, and snippets.

View tombruijn's full-sized avatar

Tom de Bruijn tombruijn

View GitHub Profile
@tombruijn
tombruijn / appsignal-capistrano-3.rake
Created February 27, 2014 09:08
Modified AppSignal deploy task to make it work with Capistrano 3.
namespace :appsignal do
# Description is required for it to show up in the tasks list.
desc 'Notify AppSignal of this deploy!'
task :deploy do
# 1. Needs to be run inside an `on` block
# 2. `appsignal_roles` setting set and supplied with default
on roles(fetch(:appsignal_roles, :app)) do
env = fetch(:rails_env, 'production')
user = ENV['USER'] || ENV['USERNAME']
@tombruijn
tombruijn / keybase.md
Created March 26, 2015 11:52
keybase.md

Keybase proof

I hereby claim:

  • I am tombruijn on github.
  • I am tombruijn (https://keybase.io/tombruijn) on keybase.
  • I have a public key whose fingerprint is D81B 2BFB CD75 EB0A A348 A240 86CF A78E B98D 8B50

To claim this, I am signing this object:

@tombruijn
tombruijn / output
Last active August 29, 2015 14:18
Wrap lines memory
"lines_map"
{:FREE=>-1506, :T_STRING=>1521, :T_ARRAY=>100, :T_DATA=>0, :T_MATCH=>0, :T_NODE=>0}
"each_line_inject"
{:FREE=>-1901, :T_STRING=>1500, :T_ARRAY=>0, :T_DATA=>100, :T_MATCH=>0, :T_NODE=>300}
"map_if"
{:FREE=>-2001, :T_STRING=>1900, :T_ARRAY=>100, :T_DATA=>0, :T_MATCH=>0, :T_NODE=>0}
"reject_map"
{:FREE=>-1801, :T_STRING=>1600, :T_ARRAY=>200, :T_DATA=>0, :T_MATCH=>0, :T_NODE=>0}
"gsub"
{:FREE=>-1602, :T_STRING=>1301, :T_ARRAY=>0, :T_DATA=>0, :T_MATCH=>200, :T_NODE=>100}
# Paperclip gem
# How to fix the issue with ImageMagick crashing on non-image files.
# Must be placed before has_attached_file
# Source: http://awesomeful.net/posts/33-attach-non-image-files-in-rails-with-paperclip
before_post_process :image?
def image?
!({your_model}_content_type =~ /^image.*/).nil?
end
@tombruijn
tombruijn / spree_config.rb
Created August 25, 2011 13:21
Spree i18n config -> When you don't want an error on db:migrate
# config/initializers/spree_config.rb
# Check if Spree::Config is loaded
# If you don't you'll get an error on migrate (the first time only)
if Spree::Config.instance
Spree::Config.set(:default_locale => "nl-NL")
end
@tombruijn
tombruijn / gist:3904610
Created October 17, 2012 09:09
curl post with headers
curl -s -d'postdata=something' -D- http://url -o/dev/null
@tombruijn
tombruijn / failer.js.coffee
Created November 9, 2012 10:26
Konacha testing setup for classes
# app/assets/javascripts/failer.js.coffee
class Failer
ze: (i) ->
i + "wa"
window.failer = new Failer
@tombruijn
tombruijn / hello.jst.eco
Created November 9, 2012 10:28
Konacha testing setup for output
# spec/javascripts/templates/hello.jst.eco
<h1>Hello <%= @name %>!</h1>
# Eco uses instance variables for variables given by the test
@tombruijn
tombruijn / cancan_strong_parameters.rb
Created February 21, 2013 13:54
CanCan + strong_parameters easiest hack
# From: https://github.com/ryanb/cancan/pull/757
# Here for reference
##
# Tell CanCan to use the user-controller resource_params method
# rather than its own (when the user-method) is available
module CanCan
class ControllerResource
def resource_params
@tombruijn
tombruijn / caveatPatchor.js
Last active December 14, 2015 10:18 — forked from protocool/caveatPatchor.js
Propane extension that shows avatars and full names
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.