Skip to content

Instantly share code, notes, and snippets.

View epidemian's full-sized avatar

Demian Ferreiro epidemian

View GitHub Profile
@epidemian
epidemian / 0.md
Last active May 2, 2023 23:27
Snake gameplay gif recorder

The gameplay gif you can see on https://github.com/epidemian/snake is a lie. It was not played by a person, but recorded move-by-move.

The code on record-moves.js was used to first record "player" moves one by one and then the code on replay-moves.js was used to replay them on the game.

The readme-moves.json file contains the moves used on the README.

To record the gif, byzanz-record was used, which is the only tool I found that could generate good quality gifs with good-enough frame rate.

The gameplay gif you can see on https://github.com/epidemian/snake is a lie. It was not played by a person, but recorded move-by-move.

The code on record-moves.js was used to first record "player" moves one by one and then the code on replay-moves.js was used to replay them on the game.

The readme-moves.json file contains the

@epidemian
epidemian / speed.md
Last active October 23, 2019 02:42 — forked from scvsoft-marianovicente/speed.md
How to speed up PRs Approves.

How to speed up PR approvals

Since GitHub became popular, so did the concept of pull request (PR) for shipping code. In order to get the benefits of code review we use PRs as a way to review what we deliver.

In this process at least 2 humans are involved[1]:

A requester (who asks for the code review), and a reviewer (who does the code review).

But sometimes a reviewer can have a lot to review, or a requester can ask for something that requieres significant effort to understand and round trips between the two parts. So it ends up costing a lot of human time and effort.

@epidemian
epidemian / authenticated.rb
Last active August 14, 2018 01:50 — forked from jc00ke/authenticated.rb
Using RSpec mocks instead of a dynamic module and module prepend
# spec/support/authenticated.rb
RSpec.shared_context "authenticated", shared_context: :metadata do
before do
allow_any_instance_of(described_class).to receive(:current_user) { current_uset }
end
end
module AttributeAccessor
def self.for(attr_name)
Module.new do
attr_accessor attr_name
end
end
end
class Book
include AttributeAccessor.for(:title)
# "Proof" of https://twitter.com/tweetsauce/status/965259567322943490
# 1 = 1!
# 2 = 2!
# 145 = 1! + 4! + 5!
# 40,585 = 4! + 0! + 5! + 8! + 5!
# These are the only four numbers with this property.
# Store the factorials from 0 to 9 for later use.
factorials = (0..9).map {|n| (1..n).inject(:*) || 1 }
--color
--require spec_helper
@epidemian
epidemian / es.txt
Last active November 14, 2018 18:59
Top 10000 Spanish words from subtitles. Taken from https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists#Spanish
que
de
no
a
la
el
es
y
en
lo
class Mapper < BasicObject
def initialize(enumerable)
@enumerable = enumerable
end
def method_missing(*args, &block)
@enumerable.map { |o| o.public_send(*args, &block) }
end
end
@epidemian
epidemian / 0_super.rb
Created October 31, 2014 20:25
Code snippets for a Suma lightning talk
module Greeting
def greet(who)
"Hello #{who}"
end
end
class Hacker
include Greeting
def greet(who)