-
Notifications
You must be signed in to change notification settings - Fork 0
Ruby & Rails
alex [dot] kramer [at] g_m_a_i_l [dot] com edited this page May 9, 2023
·
13 revisions
brew update && brew upgrade ruby-build && rbenv install 3.1.2 && rbenv global 3.1.2module M
def self.pub
puts "pub!"
self.priv
end
def self.priv
puts "priv!"
end
class << self
private :priv
end
endconfig.after_initialize do
puts "SOME_VAR: #{ENV.fetch('SOME_VAR')}"
end# Get all Things sorted by creation time
latest_things = Thing.where(some_column: "some value").sort_by(&:created_at)rails db:migrate:status
bundle exec rails db:migrateCapybara (browser based test scenarios; ruby)
│
▼
Selenium ruby API (ruby API that maps to Selenese,
the Selenium browser-automation scripting language)
│
▼
Driver (e.g. Chromedriver; browser-specific bindings
for executing Selenese scripts against a particular browser)
Turn on debug logging:
response = HTTParty.post(
"https://tw.yahoo.com",
headers: headers,
body: body.to_json,
debug_output: $stdout
)require "wavefile"
include WaveFile
SAMPLE_RATE = 44100
FORMAT = Format.new(:mono, :float, SAMPLE_RATE)
def square(lambda, vol, duration_ms)
num_cycles = (duration_ms/1000.0) * (SAMPLE_RATE / lambda)
([vol] * (lambda/2) + [-vol] * (lambda/2)) * num_cycles
end
Writer.new("/tmp/descending.wav", Format.new(:mono, :pcm_16, SAMPLE_RATE)) do |writer|
for lambda in (1..1000)
writer.write(Buffer.new(square(lambda, 0.1, 100), FORMAT))
end
end