Skip to content

Instantly share code, notes, and snippets.

View MatheusRich's full-sized avatar
🤔
Always learning, always changing

Matheus Richard MatheusRich

🤔
Always learning, always changing
View GitHub Profile
@MatheusRich
MatheusRich / request.rb
Last active November 26, 2024 04:49
Request Specs vs. System Specs Comparison
require "rails_helper"
RSpec.describe "User management", type: :request do
# Runs in about 0.2 seconds (excluding file load time)
it "lists existing users" do
User.create!(name: "John", age: 30)
get users_path
expect(page).to have_table "Users" do |table|
@MatheusRich
MatheusRich / compress_video
Created August 22, 2024 15:42 — forked from trvswgnr/compress_video
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
@MatheusRich
MatheusRich / jekyll_erb.rb
Created January 13, 2024 02:13
Hacky ERB post-processor to Jekyll
module EmbeddedRuby
module ErbRenderer
class Context
def initialize(variables)
variables.each do |key, value|
instance_variable_set(:"@#{key}", value)
self.class.attr_reader key
end
end
@MatheusRich
MatheusRich / hacking-ruby-resources.md
Last active July 8, 2023 15:10
Hacking CRuby Resources

Hacking Ruby Resources

Some resources for people interested in hacking the CRuby (MRI) code base.

CRuby

Garbage Collection

@MatheusRich
MatheusRich / chatgpt.md
Last active June 16, 2023 18:37
Google Translate vs. ChatGPT: What About Portuguese?
title Trabalhar no meu idioma nativo requer empatia
teaser É exaustivo passar o dia todo se comunicando em um idioma que não é o nativo, mas podemos praticar a gentileza e a compreensão para aliviar parte dessa carga mental.
author Matheus Richard

Algumas semanas atrás, eu estava conversando com um colega de trabalho e

@MatheusRich
MatheusRich / keybase.md
Created November 26, 2021 17:56
keybase.md

Keybase proof

I hereby claim:

  • I am matheusrich on github.
  • I am matheusrich (https://keybase.io/matheusrich) on keybase.
  • I have a public key ASADwR7uoK7Vh1ejTiSySqkdoNSUqlQMVaK5cijh0IQdFwo

To claim this, I am signing this object:

@MatheusRich
MatheusRich / erb-vs-eruby-vs-tag.rb
Created December 31, 2020 03:47
Comparing ruby native's ERB, Eruby and Rails' tag builder
require 'bundler/inline'
gemfile do
source 'http://rubygems.org'
gem 'benchable'
gem 'rails'
gem 'erubi'
end
@MatheusRich
MatheusRich / git-cagate.sh
Last active May 22, 2020 00:07
A simple bash script that creates a custom git command to ignore ALL kinds modifications (untracked files, modified files etc)
#!/bin/bash
# A simple bash script that creates a custom git command to ignore ALL kinds of
# modifications (untracked files, modified files, etc)
# Installation: run `sudo sh git-cagate.sh`
# Usage: run `git cagate` to ignore ALL modifications
cd /bin/ || exit
touch git-cagate
echo "touch .empty" >> git-cagate
@MatheusRich
MatheusRich / nested_properties.cr
Last active March 9, 2020 02:31
Macro for creating nested properties such as properties based on hash keys
macro define_option_property(*options)
{% for option in options %}
def {{option.id}}?
@options[:{{option}}]
end
{% end %}
end
class CLI
OPTIONS = {
@MatheusRich
MatheusRich / rspec-order-by-modification-time.rb
Created January 23, 2020 16:36
How to sort Rspec specs by file modification time
RSpec.configure do |config|
config.register_ordering(:global) do |items|
items.sort_by { |item| -File.mtime(item.metadata[:absolute_file_path]).to_i }
end
end