Skip to content

Instantly share code, notes, and snippets.

View keymastervn's full-sized avatar
🥐
salted egg yolk croissant

Dat Le-Tien keymastervn

🥐
salted egg yolk croissant
  • Employment Hero
  • HCMC, Vietnam
  • 19:44 (UTC +07:00)
View GitHub Profile
@keymastervn
keymastervn / alias_matchers.md
Created December 12, 2023 13:05 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@keymastervn
keymastervn / bm__redis_hiredis.rb
Last active April 14, 2022 10:21 — forked from jgaskins/benchmark.rb
Benchmarking redis gem vs hiredis
require 'bundler/inline'
gemfile true do
source 'https://rubygems.org'
gem 'redis'
gem 'hiredis'
gem 'benchmark-ips'
end
require 'benchmark'
@keymastervn
keymastervn / ruby_meta.md
Created January 18, 2022 08:24 — forked from jamesyang124/ruby_meta.md
Ruby meta programming

#!/bin/ruby --verion => 2.0.0-p353

Self

In Ruby, self is a special variable that always references the current object.

  • Inside class or module definition, self refer to the Class or Module object.
  • Inside instance method, self refer to future instance object.
  • Inside class method, self refer to the class.i
@keymastervn
keymastervn / autoreload.rb
Created April 26, 2021 10:33 — forked from mikiobraun/autoreload.rb
autoreloading of ruby files which have changed in the meantime
# This file extends the Kernel's require function and adds the
# AutoReload module which allows to reload files once they have changed
# on the disk.
#
# Basically, you just require your files as usual, and if you want to update
# the files, either call AutoReload.reload(file) or AutoReload.reload_all.
#
# Usage:
# irb -rautoload
#
@keymastervn
keymastervn / benchmark_mini_mime_vs_marcel.rb
Last active April 13, 2021 07:58 — forked from nvh0412/benchmark.rb
Benchmark mini_mime vs marcel
require 'memory_profiler'
require 'benchmark/ips'
puts "Memory stats for requiring mini_mime"
result = MemoryProfiler.report do
require 'mini_mime'
end
puts "Total allocated: #{result.total_allocated_memsize} bytes (#{result.total_allocated} objects)"
puts "Memory stats for requiring marcel"
@keymastervn
keymastervn / introrx.md
Created September 28, 2020 11:12 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@keymastervn
keymastervn / Gemfile
Created June 27, 2020 17:50 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@keymastervn
keymastervn / slim-redux.js
Created August 6, 2019 08:20 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@keymastervn
keymastervn / System Design.md
Created January 28, 2019 06:53 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?