Skip to content

Instantly share code, notes, and snippets.

@kerrizor
kerrizor / bullet_and_minitest.md
Last active January 31, 2024 00:07
Trigger MiniTest failures in Rails when Bullet detects N+1 query violations

In test/test_helper.rb...

### Bullet (N+1 queries)

if ENV['BULLET']
  Bullet.enable = true

  require 'minitest/unit'
@hacksalot
hacksalot / gist:72517b9b1c145116e89e
Created March 17, 2015 02:01
Delete GitHub wiki revisions
# Delete prior revisions from a GitHub wiki so that only the most-recent
# version of the content is available.
# Clone the wiki.
git clone https://github.com/[user]/[repo].wiki.git
# Remove the .git folder.
rm -rf .git
# Reconstruct the local repo with only latest content
@willrax
willrax / my_scene.rb
Last active August 29, 2015 14:01
Parallax scrolling with Sprite Kit and RubyMotion
# Video of it in action: http://cl.ly/VSIF
class MyScene < SKScene
def scroll_action(x, duration)
width = (x * 2)
move = SKAction.moveByX(-width, y: 0, duration: duration * width)
reset = SKAction.moveByX(width, y: 0, duration: 0)
SKAction.repeatActionForever(SKAction.sequence([move, reset]))
end
@dennisreimann
dennisreimann / changelog
Created November 20, 2013 21:10
CHANGELOG generator
#!/usr/bin/env ruby
#
# CHANGELOG generator
#
# Usage:
#
# $ changelog [SINCE UNTIL]
#
# This script collects git commits from a given range (SINCE and UNTIL
# are optional refs, SINCE defaults to the last tag, UNTIL to HEAD).
@phoet
phoet / acceptance_spec_helper.rb
Last active December 23, 2015 19:29
don't put all your stuff in /spec
require 'simplecov'
SimpleCov.command_name "acceptance"
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/poltergeist'
@afeld
afeld / gist:5704079
Last active November 27, 2023 15:43
Using Rails+Bower on Heroku
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index e948314..a24b35a 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -321,7 +321,13 @@ module ActiveSupport
_normalize_legacy_filter(kind, filter)
scopes = Array(chain.config[:scope])
- method_to_call = scopes.map{ |s| s.is_a?(Symbol) ? send(s) : s }.join("_")
+ method_to_call = scopes.map { |s|
@mpapis
mpapis / README.md
Last active December 15, 2015 10:29
An open letter to Github

As GitHub does not include a message when answering my questions I decided to keep track of them myself, this is container gist for my questions and all the answers I get.

Most of the issues are for RVM to make my life easier.

@sos4nt
sos4nt / iterm_open_with
Created March 26, 2013 13:06
Semantic history command for iTerm2 and Sublime Text 3. In iTerm's Preferences > Profiles > Default > Advanced > Semantic History, choose "Run command..." and enter "/your/path/to/iterm_open_with \1 \2".
#!/bin/sh
file "$1" | grep -q "text"
if [ $? -ne 0 ]; then
/usr/bin/open $1
else
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl $1:$2
fi
@sentientmonkey
sentientmonkey / test-logging.rb
Last active December 15, 2015 04:09
hourly log rotation in ruby logger via rotatelogs
#!/usr/bin/env ruby
require 'logger'
# rotatelogs required...
# http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
logger = Logger.new("|rotatelogs ./foo.log.%Y-%m-%d-%H 3600", 0, 0)
10.times do
logger.error "testing..."