Skip to content

Instantly share code, notes, and snippets.

View joaomarcos96's full-sized avatar

João Marcos joaomarcos96

View GitHub Profile
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@chx
chx / gist:22372925d1db05e19e76d7438262a575
Last active March 15, 2024 12:46
Remove the new Slack "rail" containing activity and other useless things
const domObserver = new MutationObserver(() => {
let rail = document.querySelector('div.p-tab_rail');
if (rail) {
rail.remove();
let old_strip = document.querySelector('div.p-workspace_switcher_prototype div.p-control_strip')
if (old_strip) {
old_strip.remove()
}
let strip = document.querySelector('div.p-control_strip');
document.querySelector('div.p-workspace_switcher_prototype').appendChild(strip);
@romulogomes
romulogomes / rails_helper.rb
Last active May 2, 2024 16:32
Factories lowest
def red(text)
"\033[31m#{text}\033[0m"
end
number_of_factories_to_analyze = 10
load_begin = Time.now
stats = {}
ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, start, finish, _id, payload|
execution_time_in_seconds = finish - start
stats[payload[:name]] = stats[payload[:name]].to_f + execution_time_in_seconds
@andrehjr
andrehjr / rails_helper.rb
Created January 12, 2024 12:28
Top slowest factories
def red(text)
"\033[31m#{text}\033[0m"
end
load_begin = Time.now
# This will return slowest factories within the suite
stats = {}
ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, start, finish, _id, payload|
execution_time_in_seconds = finish - start
@leandronsp
leandronsp / cractor.rb
Created January 17, 2022 01:14
A dead simple Actor in Ruby, simulating the same API for Ractors
class Cractor
def initialize(*args, &block)
@inbox = Queue.new
@outbox = Queue.new
Thread.new do
result = yield(self, *args)
self.yield(result)
end

How to run examples

  1. Run $ createdb uniq-db-test to create DB
  2. Run example with Ruby (e.g., $ ruby 1_find_or_create_by_single_thread.rb)

Benchmark output

With many successful INSERTs

Warming up --------------------------------------
@joaomarcos96
joaomarcos96 / arch_faster_rubocop_vscode.md
Last active February 8, 2021 13:10
Faster RuboCop for VSCode in Arch Linux
@joaomarcos96
joaomarcos96 / pre-push.sh
Last active February 8, 2021 13:10
git pre-push hook to confirm push force or delete on any branch
#!/bin/sh
current_branch=$(git rev-parse --abbrev-ref HEAD)
push_command=$(ps -ocommand= -p $PPID)
is_destructive='force|delete|\-f'
confirm_destructive_action(){
read -p 'Are you sure you want to push to "'$current_branch'" ? (y/n): ' -n 1 -r < /dev/tty
@joaomarcos96
joaomarcos96 / ExportOptions.plist
Last active March 19, 2021 21:34
iOS automated deploy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>upload</string>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>MyTeamID</string> <!-- your team ID, something like "AB12C345DE" -->

Installing Ruby 2.3.x in Arch Linux

Have openssl-1.0 and gcc installed

sudo pacman -S --needed openssl-1.0 gcc

Install Ruby 2.3.x with gcc and openssl path defined