View debugging-rails-model.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Org has the following columns: | |
# - id | |
# - name | |
class Org < ApplicationRecord | |
has_many :users | |
end | |
# User has the following columns: | |
# - id | |
# - first_name |
View debugging-ruby-arrays.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [2, 3, 4] | |
b = %w[Cats Frogs Dogs] | |
new_array = [] | |
a.each do |item| | |
new_item = b[item].downcase | |
item = b + item | |
new_array.push(itom) | |
end |
View gist:8021f80026af12318455
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BadFoo | |
@foo = :original | |
class_attribute :attrs, instance_accessor: false | |
self.attrs = [:original] | |
puts "1." | |
puts "attrs: #{self.attrs} #{self.attrs.object_id}" | |
puts "@foo: #{@foo} #{@foo.object_id}" | |
class << self | |
@foo = :singleton | |
class_attribute :attrs, instance_accessor: false |
View xvfb-run.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# $Id: xvfb-run 2027 2004-11-16 14:54:16Z branden $ | |
# This script starts an instance of Xvfb, the "fake" X server, runs a command | |
# with that server available, and kills the X server when done. The return | |
# value of the command becomes the return value of this script, except in cases | |
# where this script encounters an error. | |
# | |
# If anyone is using this to build a Debian package, make sure the package |