Trending
Nando's Avatar

Nando

@nando.ac

Ruby | Go | Elixir I use Bsky as a repository for my scripts and articles about: πŸ”„ sidekiq.nando.ac 🐘 postgres.nando.ac πŸš„ rails.nando.ac πŸ“Paris - France

61
Followers
61
Following
38
Posts
16.07.2024
Joined
Posts Following

Latest posts by Nando @nando.ac

Picture of a coffee shop in Vietnam

Picture of a coffee shop in Vietnam

Vietnam ❀️

16.05.2025 00:59 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

#postgres

09.04.2025 15:36 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
opening connection to contribyard.com:443...
opened
starting SSL for contribyard.com:443...
SSL established, protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256
<- "GET / HTTP/1.1\r\nAccept: */*\r\nUser-Agent: rest-client/2.1.0 (linux-musl aarch64) ruby/3.2.2p53\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: contribyard.com\r\nSentry-Trace: a8df53e1f85e417681272b1fe4e2678c-c292d42aab79473e\r\nBaggage: sentry-trace_id=a8df53e1f85e417681272b1fe4e2678c,sentry-environment=development,sentry-public_key=1cb040bd5059447083ac5b57ddb9bf70\r\n\r\n"
-> "HTTP/1.1 308 Permanent Redirect\r\n"
-> "Cache-Control: public, max-age=0, must-revalidate\r\n"
-> "Content-Type: text/plain\r\n"
-> "Date: Tue, 15 Oct 2024 17:53:38 GMT\r\n"
-> "Location: https://www.contribyard.com/\r\n"
-> "Refresh: 0;url=https://www.contribyard.com/\r\n"
-> "Server: Vercel\r\n"
-> "Strict-Transport-Security: max-age=63072000\r\n"
-> "X-Vercel-Id: gru1::gltvf-1729014818395-5862adb870d4\r\n"
-> "Transfer-Encoding: chunked\r\n"
-> "\r\n"
-> "f\r\n"
reading 15 bytes...
-> "Redirecting...\n"
read 15 bytes
reading 2 bytes...
-> "\r\n"
read 2 bytes
-> "0\r\n"
-> "\r\n"
Conn keep-alive
RestClient::PermanentRedirect: 308 Permanent Redirect
from /usr/local/bundle/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:249:in `exception_with_response'

opening connection to contribyard.com:443... opened starting SSL for contribyard.com:443... SSL established, protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256 <- "GET / HTTP/1.1\r\nAccept: */*\r\nUser-Agent: rest-client/2.1.0 (linux-musl aarch64) ruby/3.2.2p53\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: contribyard.com\r\nSentry-Trace: a8df53e1f85e417681272b1fe4e2678c-c292d42aab79473e\r\nBaggage: sentry-trace_id=a8df53e1f85e417681272b1fe4e2678c,sentry-environment=development,sentry-public_key=1cb040bd5059447083ac5b57ddb9bf70\r\n\r\n" -> "HTTP/1.1 308 Permanent Redirect\r\n" -> "Cache-Control: public, max-age=0, must-revalidate\r\n" -> "Content-Type: text/plain\r\n" -> "Date: Tue, 15 Oct 2024 17:53:38 GMT\r\n" -> "Location: https://www.contribyard.com/\r\n" -> "Refresh: 0;url=https://www.contribyard.com/\r\n" -> "Server: Vercel\r\n" -> "Strict-Transport-Security: max-age=63072000\r\n" -> "X-Vercel-Id: gru1::gltvf-1729014818395-5862adb870d4\r\n" -> "Transfer-Encoding: chunked\r\n" -> "\r\n" -> "f\r\n" reading 15 bytes... -> "Redirecting...\n" read 15 bytes reading 2 bytes... -> "\r\n" read 2 bytes -> "0\r\n" -> "\r\n" Conn keep-alive RestClient::PermanentRedirect: 308 Permanent Redirect from /usr/local/bundle/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:249:in `exception_with_response'

See in action.

15.10.2024 17:58 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
require 'net/http'
module Net
  class HTTP
    alias_method :initialize_without_timeout, :initialize
    
    def self.enable_debug!
      # raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
      class << self
        alias_method :__new__, :new
        def new(*args, &blk)
          instance = __new__(*args, &blk)
          instance.set_debug_output($stderr)
          instance
        end
      end
    end

    def self.disable_debug!
      class << self
        alias_method :new, :__new__
        remove_method :__new__
      end
    end
  end
end
Net::HTTP.enable_debug!

require 'net/http' module Net class HTTP alias_method :initialize_without_timeout, :initialize def self.enable_debug! # raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development' class << self alias_method :__new__, :new def new(*args, &blk) instance = __new__(*args, &blk) instance.set_debug_output($stderr) instance end end end def self.disable_debug! class << self alias_method :new, :__new__ remove_method :__new__ end end end end Net::HTTP.enable_debug!

Old trick for debugging outgoing requests in #Ruby. It's especially useful when you need to ensure that you're sending requests correctly to third parties by showing them the raw request structure.

#Rails

15.10.2024 17:57 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Instead of locking #Ruby in both .ruby-version and the Gemfile, you can read .ruby-version directly in the Gemfile:

ruby file: ".ruby-version"

#Rails

12.10.2024 15:19 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Too many memories

09.10.2024 14:26 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
app:
  tty: true
  stdin_open: true

app: tty: true stdin_open: true

To debug a #Rails app in #Docker with #Pry, set stdin_open: true & tty: true in docker-compose.yml. Then, add binding.pry in your code and run docker attach <container_name> to interact with Pry in the container. #Rails #Docker #Debugging

08.10.2024 19:41 πŸ‘ 3 πŸ” 1 πŸ’¬ 0 πŸ“Œ 0
Post image

Friday

04.10.2024 17:21 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Heroku's glory days & Postgres vs the world, w/ Craig Kerstiens
Heroku's glory days & Postgres vs the world, w/ Craig Kerstiens YouTube video by Aaron Francis

#Heroku glory days & #Postgres vs the world, w/ Craig Kerstiens

www.youtube.com/watch?v=HMJk...

03.10.2024 15:14 πŸ‘ 1 πŸ” 1 πŸ’¬ 0 πŸ“Œ 0
Preview
The Staff Engineer's Path For years, companies have rewarded their most effective engineers with management positions. But treating management as the default path for an engineer with leadership ability doesn't serve the indus...

Vai sem medo:

www.oreilly.com/library/view...

27.09.2024 08:04 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Screenshot do aplicativo buscar, mostrando os itens rastreados com AirTag

Screenshot do aplicativo buscar, mostrando os itens rastreados com AirTag

26.09.2024 20:22 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Roupas e Nada lΓ­quido

Uma coisa que penso tbm, se a minha mala for extraviada ( eu consigo sobreviver com isso aqui)

TambΓ©m meto AirTag em tudo para garantir

26.09.2024 20:20 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Small adjustments:

require 'sidekiq/api'

queue_name = 'low'
queue = Sidekiq::Queue.new(queue_name)

queue.each_with_object(Hash.new(0)) do |item, memo|
memo[item['wrapped'] || item.item['class']] += 1
end

#Sidekiq

25.09.2024 16:22 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Thos is a screenshot from a GitHub issue page under the repository golang/go. The issue is titled β€œencoding/json: unexpected json.Unmarshal behavior with maps” and was opened on October 17, 2015. It includes a discussion about the behavior of the json.Unmarshal function in Go when unmarshaling JSON objects into a map. The user β€˜nsoufr’ initiated the issue and provided a description along with code examples illustrating how the unmarshaling behaves differently from what the Go documentation describes. They point out an inconsistency with the map being replaced by an empty map before key-value pairs are added, which doesn’t align with the documentation. The discussion in the comments section seems to revolve around clarifying this behavior and possibly updating the documentation to reflect what actually occurs in the code

Thos is a screenshot from a GitHub issue page under the repository golang/go. The issue is titled β€œencoding/json: unexpected json.Unmarshal behavior with maps” and was opened on October 17, 2015. It includes a discussion about the behavior of the json.Unmarshal function in Go when unmarshaling JSON objects into a map. The user β€˜nsoufr’ initiated the issue and provided a description along with code examples illustrating how the unmarshaling behaves differently from what the Go documentation describes. They point out an inconsistency with the map being replaced by an empty map before key-value pairs are added, which doesn’t align with the documentation. The discussion in the comments section seems to revolve around clarifying this behavior and possibly updating the documentation to reflect what actually occurs in the code

The day I found an issue in the #Golang standard library.

github.com/golang/go/is...

25.09.2024 11:20 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Me :)

25.09.2024 11:11 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Preview
Zero-downtime Postgres schema migrations need this: lock_timeout and retries | Postgres.AI Deploying DB schema changes in heavily loaded systems is challenging. In this article, we explore one of the challenges - how to avoid situations when DDLs get blocked, wait to acquire a lock, and dur...

Zero-downtime #Postgres schema migrations need this: lock_timeout and retries

postgres.ai/blog/2021092...

23.09.2024 22:32 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Mais importante que ego e parecer super-star, Γ© ter um time ΓΊnico com ΓΊnico foco em resolver problemas.

sempre escolha:
Resolver problema ao invΓ©s de Ganhar discussΓ£o.

#BolhaDev
#CarreiraDev

10.09.2024 17:51 πŸ‘ 3 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Afinal de contas, o time que estΓ‘ lΓ‘ foi responsΓ‘vel pelo crescimento da empresa atΓ© agora. JΓ‘ passei por situaΓ§Γ΅es no passado em que alguΓ©m entrava na empresa e dizia: β€˜Na minha empresa anterior era assim’, mas nunca apresentava um caminho claro.

#CarreiraDev
#BolhaDev

10.09.2024 17:49 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Trabalhei em uma empresa por 10 anos, lΓ‘ era Principal Engineer. Agora, fui para uma empresa bem menor, bem no comeΓ§o da jornada.

Acho que a melhor dica que eu poderia dar nesse caso Γ© nΓ£o ser um cara chato, que chega e aponta que tudo estΓ‘ errado e que nada funciona.

#CarreiraDev
#BolhaDev

10.09.2024 17:46 πŸ‘ 4 πŸ” 1 πŸ’¬ 1 πŸ“Œ 0
require 'sidekiq/api'
queue_name = 'low'
queue = Sidekiq::Queue.new(queue_name)

queue.each_with_object(Hash.new(0)) do |item, memo|
 memo[item['wrapped']] += 1
 puts memo
end

{
    "ArtifactIndexerJob" => 817,
    "FieldJob" => 183,
    "WebhookJob" => 19435,
    "EmbeddingsJob" => 122,
    "UpdaterJob" => 526280,
    "EventCacheWarmupJob" => 140
}

require 'sidekiq/api' queue_name = 'low' queue = Sidekiq::Queue.new(queue_name) queue.each_with_object(Hash.new(0)) do |item, memo| memo[item['wrapped']] += 1 puts memo end { "ArtifactIndexerJob" => 817, "FieldJob" => 183, "WebhookJob" => 19435, "EmbeddingsJob" => 122, "UpdaterJob" => 526280, "EventCacheWarmupJob" => 140 }

Counting how many items the queue has per #Sidekiq Job.
#ActiveJob #Rails

10.09.2024 12:50 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
$ docker-compose build \
	--build-arg CONTRIBSYS_GEM_SERVER_USERNAME=$(op read "op://Shared/Sidekiq Pro - Contribsys/username") \
	--build-arg CONTRIBSYS_GEM_SERVER_PASSWORD=$(op read "op://Shared/Sidekiq Pro - Contribsys/password")

$ docker-compose build \ --build-arg CONTRIBSYS_GEM_SERVER_USERNAME=$(op read "op://Shared/Sidekiq Pro - Contribsys/username") \ --build-arg CONTRIBSYS_GEM_SERVER_PASSWORD=$(op read "op://Shared/Sidekiq Pro - Contribsys/password")

This is how you build an image with credentials from a #1Password shared vault.

In this example, I'm passing the #Sidekiq private gem server credentials to be used on the image-building process for a #Rails application.

More info:
developer.1password.com/docs/cli/sec...

09.09.2024 18:35 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Tudo isso levando em consideraΓ§Γ£o que vocΓͺ nΓ£o conseguiu chamar alguΓ©m que entende dessa parte para um pair

08.09.2024 13:55 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Nessa situaΓ§Γ΅es o que mais funciona Γ© quebrar o problema em partes menores, ex:
Tenta reduzir o escopo da olhando apenas para a parte do cΓ³digo que serΓ‘ afetada pela sua modificaΓ§Γ£o, nΓ£o necessariamente precisar entender o todo.

Escrever testes/ou ler os testes para essa Γ‘rea do software.

08.09.2024 13:54 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

engraΓ§ado que tudo isso ai eu gosto muito heheh, nao sabia que a galera falava mal heheh.

06.09.2024 10:01 πŸ‘ 2 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Win 98 :)

06.09.2024 10:01 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Preview
How to Monitor and Fix PostgreSQL Database Locks in Rails PostgreSQL database locks usually work seamlessly until they don't. Before your Rails app dataset and traffic reach a certain scale, you're unlikely to face any locks-related issues. But if your app s...

How to Monitor and Fix #Postgres Database Locks in #Rails

pawelurbanek.com/rails-postgr...

06.09.2024 08:43 πŸ‘ 4 πŸ” 1 πŸ’¬ 0 πŸ“Œ 0
Scaling Rails & Postgres to Millions of Users at Microsoft: Lessons & Takeaways – StepChange Do you have a Rails app built on PostgreSQL and need to scale it to millions of users? In this interview, I speak with Andrew Atkinson, one of StepChange's expert consultants, who brings deep expertis...

Scaling #Rails & #Postgres to Millions of Users at Microsoft: Lessons & Takeaways

stepchange.work/blog/scaling...

06.09.2024 08:39 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
curl --request POST \
  --variable studyId=$studyId \
  --expand-url https://api.host.co/studies/{{studyId}}/candidates \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer xxxxxxx' \
  --data @payload.json

curl --request POST \ --variable studyId=$studyId \ --expand-url https://api.host.co/studies/{{studyId}}/candidates \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer xxxxxxx' \ --data @payload.json

Passing variables to the middle of URLs using #cURL

06.09.2024 08:37 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
set = Sidekiq::RetrySet.new

items = set.each do |item|
  item.delete  if item.klass == "MyHeavyJob"
end; nil

set = Sidekiq::RetrySet.new items = set.each do |item| item.delete if item.klass == "MyHeavyJob" end; nil

How to remove #Sidekiq jobs from retry set by class name:

05.09.2024 21:58 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

copy 🍝

Sidekiq::Client.push_bulk(
'class' => SomeJob,
'args' => array_of_args
)

05.09.2024 21:55 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0