Skip to content

Instantly share code, notes, and snippets.

# stackprof (0.2.7)
require 'stackprof'
class StackProfTest
def test_raw
profile = StackProf.run(mode: :custom, raw: true) do
10.times do
StackProf.sample
end
@yui-knk
yui-knk / sample.md
Last active September 5, 2015 15:40

rails adapter * tables * view

rails 4276b214f8a13a38ac7dc4911e90d295a8e40d5a

books is table, ebooks is view

class MigrationA < ActiveRecord::Migration
  def change
    create_table :books, force: true do |t|
@yui-knk
yui-knk / where_to_sql.rb
Last active August 29, 2015 14:27
Rails ActiveRecord where to_sql is changed (maybe broken....)
# Rails 4.2.3 with mysql2
[1] pry(main)> User.where("id" => 1).to_sql
=> "SELECT `users`.* FROM `users` WHERE `users`.`id` = 1"
[2] pry(main)> User.where("users.id" => 1).to_sql
=> "SELECT `users`.* FROM `users` WHERE `users`.`id` = 1"
[3] pry(main)> User.where("db.users.id" => 1).to_sql
=> "SELECT `users`.* FROM `users` WHERE `db`.`users.id` = 1"
# [3] is invalid SQL because `db`.`users.id`
@yui-knk
yui-knk / gist:8486919
Last active January 3, 2016 15:59
pry #1094
  • centos6.4

  • pry 0.9.12.4

  • rvm 1.25.8

  • ruby 1.9.3

[2] pry(main)> class Foo
@yui-knk
yui-knk / gist:8022158
Last active December 31, 2015 17:39
pry bug??

env

  • windows XP
  • ruby 2.0.0
  • pry 0.9.11 ~ 0.9.12.4

constant Pry::REPL::Readline is undefined through pry_class.rb

    if defined?(Bond) && Readline::VERSION !~ /editline/i
 config.completer = Pry::BondCompleter.start