Here’s a messy, unoptimized Ruby method. Let’s clean it up.
- How can we make this more extensible?
- How should it handle invalid inputs (negative prices, nil codes)
- How could we extract this logic into a separate class/module
Dear Colleagues,
After much reflection, I’ve made the difficult decision to leave GitHub, with my last day being October 29, 2024.
My time here has been nothing short of transformative. The one constant through all the highs and lows has been the incredible people I’ve had the privilege to work with. You have consistently shown courage in speaking up, advocating for what’s right, and putting out extraordinary work. I’ve grown more here over the last five years than in any other position, thanks in no small part to the collaboration, mentorship, and friendship you’ve all offered me.
I’ll miss our shared problem-solving, the inside jokes, and, of course, our collective drive to make great things happen. I hope we keep in touch and that our paths cross again.
Thank you all so much. It has truly been an honor and a priveledge to call you my calleagues. I wish you all the best in your future endeavors.
See https://api.slack.com/apis/socket-mode#implementing for more info about implementing a custom websocket client for Slack.
A previous version of this was posted to
https://gist.github.com/chrisbloom7/52bc954b4df09b9cb829a73cfd5466c0,
but that version no longer works with newer versions of the async-websockets
gem. (It also wasn't easily testable.)
# frozen_string_literal: true | |
# Basic implementation of a websocket connector for Slack using the slack-ruby-client gem | |
# | |
# Run this rake task in a virtual container that is set to automatically restart on failure; this | |
# will help deal with disconnects from Slack since socket URLs are temporary. | |
# https://api.slack.com/apis/connections/socket-implement#disconnect | |
# | |
# This rake task can be called in multiple virtual containers to help with resilliancy and rolling restarts | |
# https://api.slack.com/apis/connections/socket-implement#connections |
I've found a bug that is specific to the following scenario:
longblob
column typepaper_trail
gemUnder those conditions, after saving changes to the serialized field, record#changed?
still reports true, and record#changes
contains an entry for the serialized field where both the before and after elements are identical. Calling record#reload
clears the changes and loads the record with the changed value. If paper_trail
is removed from the scenario, the ActiveModel attribute mutation tracking works as expected.
test result | reserved method | call type | error reported | |
---|---|---|---|---|
Error | :render_to_body | called directly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :render_to_body | called indirectly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :instance_variable_get | called directly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :instance_variable_get | called indirectly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :process | called directly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :process | called indirectly | ArgumentError: wrong number of arguments (given 1, expected 0) | |
Error | :logger | called indirectly | SystemStackError: stack level too deep | |
Error | :logger | called directly | SystemStackError: stack level too deep | |
Error | :send_action | called indirectly | ArgumentError: wrong number of arguments (given 1, expected 0) |
class MySingletonClass | |
include Singleton | |
attr_reader :client | |
def initialize | |
@client = Service::We::Only::Ever::Need::One::Connection::To.new(SERVICE_URL) | |
end | |
end |
package main | |
import ( | |
"fmt" | |
) | |
var a1 = [3]int{1, 2, 3} | |
var s1 = a1[0:3] | |
func main() { |
# A prime is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers | |
def prime?(int) | |
# A prime is a natural number greater than 1... | |
return false if int < 2 | |
# Is _int_ evenly divisible by any number 2 -> int-1? | |
(2..(int - 1)).each do |divisor| | |
return false if int % divisor == 0 | |
end | |
return true |