I hereby claim:
- I am brodock on github.
- I am brodock (https://keybase.io/brodock) on keybase.
- I have a public key whose fingerprint is 4E65 23FE 0082 24ED 42E3 F4BA D9C6 74CE 5B99 059F
To claim this, I am signing this object:
| require 'thwait' | |
| # Synchronous hand-off between two threads. | |
| # Both threads will block until a transfer is successful. | |
| class Rendevous | |
| def initialize | |
| @mutex = Mutex.new | |
| @send_flag = ConditionVariable.new | |
| @recv_flag = ConditionVariable.new | |
| @container = [] |
| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
| # ... | |
| config.vm.provision 'shell', inline: <<-SCRIPT | |
| curl -s -L -O https://github.com/brodock/apt-select/releases/download/0.1.0/apt-select_0.1.0-0_all.deb && sudo dpkg -i apt-select_0.1.0-0_all.deb | |
| apt-select && sudo apt-select-update | |
| SCRIPT | |
| #... | |
| end |
I hereby claim:
To claim this, I am signing this object:
| // run this inside the javascript console of the Backups page: | |
| urls = $x('/html/body/div/div/div[4]/table/tbody/tr//a') | |
| urls.forEach(function(e) { console.log('curl "' + e.href + '"' + ' -o "' + e.innerHTML + '"') }) | |
| // It will output a ready to use list of wget commands that will download every backup file | |
| // If the console adds line numbering or other useless data like in chrome, try this instead: | |
| urls = $x('/html/body/div/div/div[4]/table/tbody/tr//a') | |
| var wget_list = "" | |
| urls.forEach(function(e) { wget_list = wget_list + 'curl "' + e.href + '"' + ' -o "' + e.innerHTML + "\" \n" }) | |
| console.log(wget_list) |
| require 'therubyracer' | |
| require 'commonjs' | |
| webpack_path = `which webpack`.chomp | |
| webpack_content = File.open(webpack_path).read.sub("#!/usr/bin/env node\n", '') | |
| ctx = V8::Context.new | |
| env = CommonJS::Environment.new(ctx, path: '/usr/local/lib/node_modules') | |
| ctx['require'] = lambda { |this, module_id| env.require(module_id) } |
My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.
As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.
I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.
So, in order to profile your worker, add the sidekiq_profiler.rb (below) to your project
Adjust number of jobs you want your worker to process before you have heap dumped.
Run a sample worker: PROFILE=1 sidekiq -C config/sidekiq.yml and wait for jobs to be processed.
| # create path and copy redis.conf to the correct path | |
| redis: exec redis-server /Users/youruser/projects/yourproject/dev/redis/redis.conf | |
| # path/to/postgres/initdb --locale=C -E utf8 /Users/youruser/projects/yourproject/dev/postgresql/data | |
| postgresql: exec postgres -D /Users/youruser/projects/yourproject/dev/postgresql/data -k /Users/youruser/projects/yourproject/dev/postgresql -h 'localhost' |
| /builds/gitlab-org/gitlab/app/views/projects/new.html.haml:53: [BUG] Segmentation fault at 0x0000000000000038 | |
| ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux] | |
| -- Control frame information ----------------------------------------------- | |
| c:0211 p:---- s:1376 e:001375 CFUNC :build_class | |
| c:0210 p:1228 s:1369 E:000480 METHOD /builds/gitlab-org/gitlab/app/views/projects/new.html.haml:53 | |
| c:0209 p:0039 s:1328 e:001327 METHOD /builds/gitlab-org/gitlab/vendor/ruby/2.6.0/gems/actionview-6.0.2/lib/action_view/base.rb:274 | |
| c:0208 p:0026 s:1316 e:001315 BLOCK /builds/gitlab-org/gitlab/vendor/ruby/2.6.0/gems/actionview-6.0.2/lib/action_view/template.rb:185 | |
| c:0207 p:0039 s:1313 e:001312 METHOD /builds/gitlab-org/gitlab/vendor/ruby/2.6.0/gems/activesupport-6.0.2/lib/active_support/notifications.rb:182 | |
| c:0206 p:0022 s:1307 e:001306 METHOD /builds/gitlab-org/gitlab/vendor/ruby/2.6.0/gems/actionview-6.0.2/lib/action_view/template.rb:386 |
| blueprint: | |
| name: Philips Hue Dimmer RWL022 | |
| description: | |
| "Control lights with a Philips Hue Dimmer Switch (v2).\n\n Blueprint\ | |
| \ Version: 4" | |
| domain: automation | |
| source_url: https://gist.github.com/brodock/0c85f4882b885d4d5499cd88d155c38c | |
| homeassistant: | |
| min_version: "2025.9.1" | |
| input: |
| #!/bin/bash | |
| set -x | |
| PROTON="GE-Proton8-4" | |
| APPID=813780 | |
| CAPTURE_AGE_VERSION=1.6.1 | |
| STEAM_PATH="${HOME}/.steam" | |
| STEAMAPPS="${STEAM_PATH}/root/steamapps" | |
| COMPATIBILITY_TOOLS="${STEAM_PATH}/root/compatibilitytools.d" |