Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

# Org has the following columns:
# - id
# - name
class Org < ApplicationRecord
has_many :users
end
# User has the following columns:
# - id
# - first_name
@tyleramos
tyleramos / debugging-ruby-arrays.rb
Created October 11, 2018 20:30
Debugging BE (Ruby) - arrays
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
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
@tyleramos
tyleramos / xvfb-run.sh
Created September 18, 2012 18:32
XVFB Run Bash script
#!/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