Skip to content

Instantly share code, notes, and snippets.

View jodosha's full-sized avatar

Luca Guidi jodosha

View GitHub Profile
@jodosha
jodosha / README.md
Created October 6, 2023 08:03
Hanami DEV Memory Footprint

Assessment

This is a memory footprint assessment of all the possibilities to start the Rack server and the assets watch. I know this isn't a scientific approach, but it gives us the order of magnitude of the differences between the options.

Conclusions

  • Using Ruby and NPM as middlemen to execute other commands wastes memory.
    • bundle exec hanami server and assets, npm exec
  • Foreman executes 3 Ruby processes.
⚡ git log -1
1961f9e [3 hours ago] (Luca Guidi) Refactoring: ensure proper level of abstraction in GitHub REST client
⚡ npm start -- --remote=mattzcarey/code-review-gpt#96 --debug=true
> [email protected] start
> ts-node ./src/index.ts review --remote=mattzcarey/code-review-gpt#96 --debug=true
DEBUG Review started.
DEBUG Model used: gpt-4
@jodosha
jodosha / install_nix_in_an_lxd_container.md
Created February 12, 2023 17:40 — forked from derekmahar/install_nix_in_an_lxd_container.md
How to Install Nix in an LXD Container

How to Install Nix in an LXD Container

Steps to install the Nix package manager inside an Ubuntu 20.04 LXD container using the images:ubuntu/focal image:

  1. On the LXD host, create an Ubuntu 20.04 container:
    lxc init images:ubuntu/focal container1
    
  2. On the LXD host, enable nested security on the container:
@jodosha
jodosha / 1.json
Created November 18, 2022 14:03
Rack upload exception
{"foo": "100% bar"}
@jodosha
jodosha / ivar_vs_accessor.rb
Last active June 27, 2022 08:31
Ruby Benchmark: ivar vs accessor
#!/usr/bin/env ruby
# frozen_string_literal: true
require "benchmark/ips"
class Ivar
def initialize
@ivar = 23
end
@jodosha
jodosha / hash_assign_vs_merge.rb
Created April 12, 2022 12:55
Ruby: Compare Hash direct assignment vs merge
#!/usr/bin/env ruby
# frozen_string_literal: true
require "benchmark/ips"
hash1 = {}
hash2 = {}
Benchmark.ips do |x|
x.report("assign") do
@jodosha
jodosha / fibonacci.rb
Created September 29, 2021 07:40
Give Ruby 3 an Elixir flavor: provide pattern matching for recursion
# frozen_string_literal: true
module PatternMatching
def self.extended(base)
base.class_eval do
@__pn_methods = {}
end
end
def __pn_methods
@jodosha
jodosha / output.log
Created August 11, 2021 06:44
dry-configurable test suite output at f44ea91
Failures:
1) Dry::Configurable::DSL compiles but deprecates giving a default as positional argument
Failure/Error: expect(logger.string).to match(/#{FileUtils.pwd}.*default value as positional argument to settings is deprecated/)
expected "/Users/jodosha/.gem/ruby/3.0.1/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:262:in `block in run...ed and will be removed in the next major version\nProvide a `default:` keyword argument instead\n\n" to match /\/Users\/jodosha\/Code\/dry-rb\/dry-configurabl
e.*default value as positional argument to settings is deprecated/
Diff:
@@ -1,2 +1,3 @@
-/\/Users\/jodosha\/Code\/dry-rb\/dry-configurable.*default value as positional argument to settings is deprecated/
⚡ bundle exec rake
/Users/jodosha/.rubies/ruby-3.0.1/bin/ruby -I/Users/jodosha/.gem/ruby/3.0.1/gems/rspec-core-3.10.1/lib:/Users/jodosha/.gem/ruby/3.0.1/gems/rspec-support-3.10.2/lib /Users/jodosha/.gem/ruby/3.0.1/gems/rspec-core-3.10.1/exe/rspec /Users/jodosha/Code/hanami/monolith-template/spec/suite --pattern **/*_spec.rb
An error occurred while loading ./spec/suite/main/features/home_spec.rb.
Failure/Error: class Action < Hanami::Action
TypeError:
no implicit conversion of nil into String
# /Users/jodosha/.gem/ruby/3.0.1/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/configuration.rb:410:in `public_directory'
# /Users/jodosha/.gem/ruby/3.0.1/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/application_configuration.rb:81:in `public_send'
@jodosha
jodosha / config.ru
Created May 7, 2021 06:51
Code spike for hanami-api + dry-container + dry_auto-inject (see https://github.com/hanami/api/pull/26)
# frozen_string_literal: true
require "bundler/setup"
require "hanami/api"
require "hanami/api/container"
class Routes
def url(name)
"/#{name}"
end