Skip to content

Instantly share code, notes, and snippets.

Jesus Castello matugm

Block or report user

Report or block matugm

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 array-random.rb
def a
t = Time.now
Array.new(10_000_000) { rand }
puts Time.now - t
end
10.times { a }
View hash-benchmark.rb
require 'benchmark'
N = 1_000_000
Benchmark.bm(10) { |x|
0.step(to: 16) { |size|
data = (1..size).zip(Array.new(size))
x.report(size) {
i = 0
View strings_vs_symbol_benchmark.rb
require 'benchmark/ips'
str = { "foo" => 1 }
sym = { foo: 1 }
Benchmark.ips do |x|
x.report("string") { str["foo"] }
x.report("symbol") { sym[:foo] }
x.compare!
View keybase.md

Keybase proof

I hereby claim:

  • I am matugm on github.
  • I am jesus_castello (https://keybase.io/jesus_castello) on keybase.
  • I have a public key whose fingerprint is 5697 A6C4 0820 FCB6 E86E BD21 53CB 0DB1 23B1 3816

To claim this, I am signing this object:

View time-range.rb
require 'time'
require 'pp'
objects = [Time.strptime("20", "%M"), Time.strptime("21", "%M"), Time.strptime("25", "%M"),Time.strptime("26", "%M")]
@range = Hash.new { |hash, key| hash[key] = [] }
def add_into_time_range(time)
base = time.min - (time.min % 5)
key = "#{time.hour}:#{base}"
@matugm
matugm / toc.md
Last active Oct 13, 2017
Table Of Contents
View toc.md

Ruby Deep Dive - Table Of Contents

  • Using Pry to Learn Ruby
    • The Power of Pry
    • Where did this method come from?
    • Debugging using Pry
  • Understanding Exceptions
    • What are Exceptions and Why They Happen
    • Understanding Stack Traces
    • Using Exceptions
View topic.md
View refactor-styles.rb
#coding: utf-8
class HighLine
module BuiltinStyles
def self.included(base)
base.extend ClassMethods
end
STYLES = {
erase_line: "\e[K",
View seed-database.rb
require 'faker'
20.times do
post = Post.create!(title: Faker::Lorem.word, body: Faker::Lorem.paragraph)
puts "Created #{post.title}"
end
@matugm
matugm / refactor.js
Created Jul 14, 2015
javascript refactor
View refactor.js
// Old
$(function() {
var flashCallback;
flashCallback = function() {
return $(".alert").fadeOut();
};
$(".flash-message").bind('click', (function(_this) {
return function(ev) {
return $(".alert").fadeOut();
};
You can’t perform that action at this time.