Skip to content

Instantly share code, notes, and snippets.

View prakashmurthy's full-sized avatar

Prakash Murthy prakashmurthy

View GitHub Profile
@prakashmurthy
prakashmurthy / gist:45802e036e658708f4d6c59352413f2f
Created February 26, 2019 17:13
Medium article titled 'Sorry, Y’all, but Climate Change Ain’t the First Existential Threat'
Sorry, Y’all, but Climate Change Ain’t the First Existential Threat
Go to the profile of Mary Annaïse Heglar
Mary Annaïse Heglar
Feb 18
URL: https://medium.com/@maryheglar/sorry-yall-but-climate-change-ain-t-the-first-existential-threat-b3c999267aa0
Dear Climate Movement:
I’m with you when you say that climate change is the most important issue facing mankind. I’ll even go so far as to say it’s the most important one ever.
@prakashmurthy
prakashmurthy / trace.rb
Last active September 1, 2016 20:30
tracing system stack error when there is no stack trace
$enable_tracing = false
$trace_out = open('trace.txt', 'w')
set_trace_func proc { |event, file, line, id, binding, classname|
if $enable_tracing && event == 'call'
$trace_out.puts "#{file}:#{line} #{classname}##{id}"
end
}
$enable_tracing = true
@prakashmurthy
prakashmurthy / my_assignment_test.rb
Last active August 17, 2016 13:53
Files for adding a new test in rails codebase for issue #26122
# activerecord/test/cases/my_assignment_test.rb
require "cases/helper"
require "models/stat"
class MyAssignmentTest < ActiveRecord::TestCase
ActiveRecord::Schema.define do
create_table :stats, force: true do |t|
t.integer :count, default: 0
end
end
@prakashmurthy
prakashmurthy / thousands_of_assignments.rb
Last active August 16, 2016 21:04
Executable test script for rails issue #26122
##############################################################################
# thousands_of_assignments.rb
# Script for https://github.com/rails/rails/issues/26122
##############################################################################
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
@prakashmurthy
prakashmurthy / decimal_rounding_test.rb
Last active August 17, 2016 13:54
Files for adding a new test in rails codebase
# activerecord/test/cases/decimal_rounding_test.rb
require "cases/helper"
require "models/thing"
class DecimalRoundingTest < ActiveRecord::TestCase
ActiveRecord::Schema.define do
create_table :things, force: true do |t|
t.decimal :price, precision: 4, scale: 4
end
end
##############################################################################
# decimal_rounding_error.rb
# Script for https://github.com/rails/rails/issues/26108
##############################################################################
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
@prakashmurthy
prakashmurthy / cap_error.rb
Created August 12, 2016 16:31
Capistrano incompatibility with rake
cap aborted!
NoMethodError: undefined method `already_invoked' for <Rake::Task load:defaults => []>:Rake::Task
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/dsl.rb:16:in `invoke'
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/application.rb:91:in `load_imports'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:697:in `raw_load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:94:in `block in load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:93:in `load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:77:in `block in run'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'

[master] $ git bisect start

[master] $ git bisect good fd65a9000b550509358dfdcd557c0bb882630d4e

[master] $ git bisect bad 4e961ca184d39bcc3755d017e94bf03c6e656b29

Bisecting: a merge base must be tested [ee614af6fa6c9e8cac70bcfd7d3583d0b4ff907b] Merge pull request #17812 from jonatack/patch-8 [(no branch, bisect started on master)] $ git bisect good

@prakashmurthy
prakashmurthy / example_mailer.rb
Created June 18, 2016 00:05
blind copy all emails sent by a rails system to a specific email account
class ExampleMailer < ActionMailer::Base
default bcc: "example.archive0912@gmail.com"
...
end
@prakashmurthy
prakashmurthy / diff.md
Last active October 28, 2015 17:47
add_foreign_key inconsistent behavior

add_foreign_key seems to be behaving inconsistently when it is called with rake db:rollback.

When called from rake db:migrate, a custom name built with table name & column name is used for the index name. When called from rake db:rollback, the name used for the index is a generic one.

Here is the diff from the above behavior in my db/schema.rb file:

-  add_index "line_items", ["location_id"], name: "index_line_items_on_location_id", using: :btree
+  add_index "line_items", ["location_id"], name: "fk_rails_4335959382", using: :btree