Skip to content

Instantly share code, notes, and snippets.

View gmcabrita's full-sized avatar

Gonçalo Mendes Cabrita gmcabrita

View GitHub Profile

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(),
")",
@gmcabrita
gmcabrita / waydroid.sh
Created November 3, 2023 09:28
waydroid weston
#!/bin/bash
if [ "$(systemctl is-active waydroid-container.service)" == 'active' ];then
killall -9 weston
sudo systemctl stop waydroid-container.service
exit
fi
killall -9 weston
sudo systemctl restart waydroid-container.service
if [ -z "$(pgrep weston)" ]; then
weston --xwayland &> /dev/null &
<!doctype html> <html ng-app="mwgApp" lang="en-US"> <head> <meta charset="utf-8"> <title ng-bind="title || 'McCann Worldgroup | Integrated Global Network of Specialty Marketing Agencies'">McCann Worldgroup | Integrated Global Network of Specialty Marketing Agencies</title> <base href="/"> <link rel="canonical" href="https://www.mccannworldgroup.com/"/> <meta name="description" content="{{description || 'McCann Worldgroup is a leading global marketing services company with an integrated network of advertising agencies in over 120 countries'}}"> <meta name="viewport" content="width=device-width"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta property="og:type" content="Website"/> <meta property="twitter:card" content="Summary"/> <meta property="og:title" content="McCann Worldgroup | Integrated Global Network of Specialty Marketing Agencies" /><meta property="twitter:title" content="McCann Worldgroup | Integrated Global Network of Specialty Marketing Agencies" /><meta property="og:url" content="htt
import { cursor } from "./cursor"
let progressValue: number = 0
let currentValue: number = 0
let timer: Timer | undefined = undefined
let maxLength: number = 0
let lastProgress: number = 0
let barChar: string = "▣"
let emptyChar: string = "⬚"