Skip to content

Instantly share code, notes, and snippets.

# I want to turn this:
array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# into this:
=> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
def to_grid(ary)
array = ary.dup
row_length = Math.sqrt(array.size).to_i
result = []
@ktheory
ktheory / query_trace.rb
Created February 29, 2012 16:58 — forked from belt/query_trace.rb
QueryTrace... ported to rails3
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?
Gem::Specification.new do |s|
s.name = 'bang'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jeff Kreeftmeijer'
s.email = 'jeff@kreeftmeijer.nl'
s.summary = 'Bang!'
s.description = 'Bangs existing model methods'
s.files = ['bang.rb']