Skip to content

Instantly share code, notes, and snippets.

View gmcabrita's full-sized avatar

Gonçalo Mendes Cabrita gmcabrita

View GitHub Profile
@gmcabrita
gmcabrita / karafka_web_ui.user.js
Created December 3, 2024 14:50
karafka web ui, hide topic lags at 0 from tooltip
// ==UserScript==
// @name Karafka Web UI Fixes
// @description Fixes some Karakfa Web UI annoyances
// @namespace http://tampermonkey.net/
// @version 2024-12-03
// @author Gonçalo Cabrita
// @match *://*/karafka/dashboard*
// @updateURL https://gist.github.com/gmcabrita/55568fcc1c4bd11f20b4f33980696555/raw/karafka_web_ui.user.js
// @downloadURL https://gist.github.com/gmcabrita/55568fcc1c4bd11f20b4f33980696555/raw/karafka_web_ui.user.js
// @supportURL https://gist.github.com/gmcabrita/55568fcc1c4bd11f20b4f33980696555#new_comment_field
== Parsing redacted.json (6259 bytes)
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]
Warming up --------------------------------------
          json 2.8.1     4.675k i/100ms
                  oj     3.907k i/100ms
          Oj::Parser     6.201k i/100ms
           rapidjson     3.364k i/100ms
Calculating -------------------------------------
          json 2.8.1     47.534k (± 5.9%) i/s   (21.04 μs/i) -    238.425k in   5.038350s
~/Developer/ruby-json-bench (main) % bundle exec awfy ips JSON 'parsing'
Running IPS for:
> JSON/parsing...
> [mri - branch 'main'] JSON / parsing
> [yjit - branch 'main'] JSON / parsing
+---------------------------------------------------------------+
|                         JSON/parsing                          |
+--------+---------+-----------------+------------+-------------+
| Branch | Runtime | Name            | IPS        | Vs baseline |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas facilisis molestie libero nec ultrices. Curabitur ut odio eget dolor convallis tempor. Pellentesque non nibh at eros dapibus sollicitudin vitae eget tellus. Donec ut metus non turpis lobortis ultricies a sed nisl. Aenean elementum consequat erat, sed tempor nunc. Nam eu vestibulum enim, et ullamcorper urna. Morbi fringilla congue justo suscipit vestibulum. Sed at enim et mauris luctus vehicula. In bibendum odio at felis vehicula tincidunt. Mauris cursus neque ac ex porta, ut lobortis neque aliquet. Nunc magna dolor, tempor eu libero eu, cursus venenatis lacus. Etiam ac elementum ligula. Pellentesque sollicitudin consectetur libero eget rhoncus. Integer mauris neque, eleifend vel tellus sit amet, imperdiet rutrum leo.[^1]

Quisque at metus ut orci vehicula bibendum ut eu lorem. Nam eu vestibulum lorem. Duis id ante libero. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam condimentum magna eget com

If you’re an app developer reading this, can you tell me, off the top of your head, how your app behaves on a link with 40 kbps available bandwidth, 1,000 ms latency, occasional jitter of up to 2,000 ms, packet loss of 10%, and a complete 15-second connectivity dropout every few minutes?

https://chatgpt.com/share/13e444bc-f16e-4ce7-841f-e8362f366da4

macOS

1. Create a configuration file for pfctl

sudo nano /etc/pf.conf:

@gmcabrita
gmcabrita / .index.yml_generator.rb
Last active June 5, 2024 14:21
ruby-lsp .index.yml excluded_gems generator
require "yaml"
require "bundler"
config_file = ".index.yml"
config = if File.exist?(config_file)
YAML.load_file(config_file)
else
{}
end
bundler_gems = Bundler.locked_gems&.specs.map { _1.name }
@gmcabrita
gmcabrita / rss2gmail.js
Last active May 16, 2024 21:36
gmail gapps script rss feed reader
function fetchAndEmailRSSFeeds() {
const rssUrls = [
"https://brandur.org/atoms.atom",
"https://sirupsen.com/atom.xml",
"https://ferd.ca/feed.rss",
"https://andrewkelley.me/rss.xml",
"https://apenwarr.ca/log/rss.php",
"https://www.evanjones.ca/index.rss",
"https://danluu.com/atom.xml",
"https://thume.ca/atom.xml",
# config/initializers/active_record.rb
Rails.application.reloader.to_prepare do
ActiveRecord::Relation.include(ExplainAnalyze::Relation)
end

Multiple GitHub accounts (Work vs Personal)

This setup uses some tricks to ensure that the right email/name/ssh-key is used for the right repos without having to think about it ever again.

  • First generate two SSH keys, ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519_work
  • Add one key to your personal account and the other to your work account

.ssh/config

@gmcabrita
gmcabrita / fetch.simple.js
Created November 11, 2023 10:49
await fetch node bun memory usage benchmark jarred sumner https://twitter.com/jarredsumner/status/1710517742984712341
var i = 0;
async function main() {
while(true) {
console.log(
"Memory usage: ",
(process.memoryUsage.rss() / 1024 / 1024) | 0,
"MB",
"( time:",
performance.now(),
")",