Skip to content

Instantly share code, notes, and snippets.

Máximo Mussini ElMassimo

Block or report user

Report or block ElMassimo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .git-prompt-colors.sh
override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="Custom"
PathShort="\W" # Display only the current folder
# Display the current folder first
GIT_PROMPT_START_USER="${Green}${PathShort}"
GIT_PROMPT_START_ROOT="${Green}${PathShort}"
# Skip the default prefix
View benchmark_to_proc.rb
require 'benchmark'
class User
def initialize(first_name:, last_name:, email:)
@first_name, @last_name, @email = first_name, last_name, email
end
def to_s
"#{ @first_name } #{ @last_name } (#{ @email })"
end
View mongoid_no_heritage.rb
module Mongoid
# Public: Allows to use inheritance to reuse logic, without using Single-
# Collection Inheritance, storing the model and superclass in different
# collections.
module NoHeritage
extend ActiveSupport::Concern
included do
# Internal: Preserve the default storage options instead of storing in the
@ElMassimo
ElMassimo / thread_with_context.rb
Last active Apr 19, 2017
Thread with access to a shared Request Context
View thread_with_context.rb
# Public: Module that overrides Thread initialization to preserve the request context.
module ThreadWithContext
# Public: Returns a new Thread that preserves the context of the current request.
def new(*args)
request_id = Thread.current[:request_id]
super(*args) {
Thread.current[:request_id] = request_id
yield *args
}
View array_splat_benchmark.rb
require 'benchmark'
ITERATIONS = 1_000_000
def rename(source, dest)
{ source: source, dest: dest }
end
def literal_work
ITERATIONS.times do
You can’t perform that action at this time.