Skip to content

Instantly share code, notes, and snippets.

View ch1ago's full-sized avatar
🏠
Working mostly from home since 2006

Thiago Almeida ch1ago

🏠
Working mostly from home since 2006
  • Mexico City
  • 09:31 (UTC -06:00)
View GitHub Profile
#!/usr/bin/env ruby
class Symbol
def with(*args, &block)
->(caller, *rest) { caller.send(self, *rest, *args, &block) }
end
end
require 'active_support/core_ext/string'
require 'colorize'
inherit_from:
- .rubocop_todo.yml
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
EnabledByDefault: true
UseCache: true
CacheRootDirectory: ~
@ch1ago
ch1ago / test_helper.rb
Created June 17, 2017 14:10
Minitest for weekends
#...
n = Time.now
if n.friday? || n.saturday? || n.sunday?
Minitest::Test.class_eval do
def result_code
failure && failure.result_code || '👍 '
end
end
@ch1ago
ch1ago / irbrc
Created April 12, 2017 20:09
irbrc
#!/usr/bin/ruby
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
@ch1ago
ch1ago / thesis.md
Created January 27, 2017 18:07
thesis

THIAGO PINTO - THESIS

SOFTWARE ARCHITECTURE with emphasys on Management


TABLE OF CONTENTS

@ch1ago
ch1ago / errors.rb
Created June 5, 2016 18:00
overview of errors.rb
class ActiveRecordError < StandardError
class RecordInvalid
class SubclassNotFound
class SerializationTypeMismatch
class AdapterNotSpecified
class AdapterNotFound
class ConnectionNotEstablished
class RecordNotFound
class RecordNotSaved
class RecordNotDestroyed
@ch1ago
ch1ago / app_nfe_base.rb
Last active May 31, 2016 14:29
hash decorators
# app/nfe/base.rb
module Nfe
class Base
def self.array(array)
array.map { |hash| new(hash) }
end
def initialize(hash)
@hash = hash.stringify_keys
@ch1ago
ch1ago / abc.rb
Created May 29, 2016 02:37
ruby with tests
# ruby abc.rb
require 'minitest'
require 'minitest/autorun'
class Abc
def a
return 'aaa'
end
timezone:
- info
source for TZInfo is 'cat /usr/share/zoneinfo/zone.tab'
rails uses this as standard ::ActiveSupport::TimeZone.all
rake time:zones:all
- test:
raises an error
Time.zone='Fuck'
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>