Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@mehagar
mehagar / brakeman.yml
Last active July 2, 2020 14:42
How to use pronto-brakeman as a Github Action
name: Pronto
on: [pull_request]
jobs:
pronto:
runs-on: ubuntu-latest
steps:
- name: Checkout code
@hanbzu
hanbzu / tdd-quotes-beck-dhh.md
Created April 16, 2020 20:09
Some quotes about Test Driven Development (TDD) from DHH and Kent Beck.

Some quotes about Test Driven Development (TDD) from DHH and Kent Beck. They made a debate video or something. Source: https://martinfowler.com/articles/is-tdd-dead/

Code is not complete without tests, but that doesn't mean you need to write your tests first -- DHH

Examples, think of examples. Work from specific to general. But maybe not everybody is like that. -- Kent Beck

A design insight can allow you to do more fine-grained testing. -- Kent Beck

@JamesYang76
JamesYang76 / Time Zone.md
Last active March 9, 2025 15:26
Time Zone for rails

Time zones

There are trhee diffrent time zones in rails

  • System - The server time zone
  • Application - Rails application use own time zone
  • Database - Default is UTC, but do not change it

Cautions

  • config.time_zone should be set when an app dose not support multiple time zones
  • Do not use Date/Time API using system time zone
  • Date could be incorrect by being converted from datetime or time to date
@obelisk68
obelisk68 / tetris_for_Ruby2D.rb
Last active December 15, 2024 14:50
Ruby2D を使ったテトリス
require "ruby2d"
include Ruby2D::DSL
Wait = 18
class Tetromino
def initialize
@pat = Array.new(4)
pats = [["1111"], ["11", "11"], ["011", "110"], ["110", "011"],
["100", "111"], ["001", "111"], ["010", "111"]]
# This is the complete source code to Flappy Dragon:
# https://dragonruby.itch.io/flappydragon
#
# You can tinker with this by getting a copy of DragonRuby Game Toolkit:
# https://dragonruby.org/
#
# Amir Rajan wrote this game, catch him at https://twitter.com/amirrajan !
class FlappyDragon
attr_accessor :grid, :inputs, :game, :outputs
@rponte
rponte / avoid-distributed-transactions.md
Last active September 30, 2025 18:16
THEORY: Distributed Transactions and why you should avoid them (2 Phase Commit , Saga Pattern, TCC, Idempotency etc)

Distributed Transactions and why you should avoid them

  1. Modern technologies won't support it (RabbitMQ, Kafka, etc.);
  2. This is a form of using Inter-Process Communication in a synchronized way and this reduces availability;
  3. All participants of the distributed transaction need to be avaiable for a distributed commit, again: reduces availability.

Implementing business transactions that span multiple services is not straightforward. Distributed transactions are best avoided because of the CAP theorem. Moreover, many modern (NoSQL) databases don’t support them. The best solution is to use the Saga Pattern.

[...]

@humpok
humpok / reset_sidekiq.rb
Created September 13, 2018 13:38
Delete All Sidekiq Batches and Jobs
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch::Status.new(batch.bid).delete }
Sidekiq::Queue.all.each(&:clear)
@simonw
simonw / how-to-upgrade-heroku-postgresql.md
Last active May 30, 2025 04:49
How to upgrade a Heroku PostgreSQL database to a new plan

How to upgrade a Heroku PostgreSQL database to a new plan

I started a project on a Hobby Dev plan (free, limit 10,000 rows), and then later needed to upgrade it to Hobby Basic ($9/month, limit 10,000,000 rows).

After assigning the new database, I had two databases attached to the application. They looked something like this:

  • HEROKU_POSTGRESQL_OLIVE (postgresql-dimensional-3321) Old, free-tier (Hobby Dev) database
@malakai97
malakai97 / DependencyInjectionInRuby.md
Created February 7, 2018 00:34 — forked from blairanderson/DependencyInjectionInRuby.md
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

@gottfrois
gottfrois / components.rb
Created January 4, 2018 15:41
Dry-system component example using gems
# foo/lib/foo.rb
require 'dry/system'
require 'foo/version'
module Foo
Dry::System.register_provider(
:foo,
boot_path: Pathname(__dir__).join('foo/components').realpath
)
end