Skip to content

Instantly share code, notes, and snippets.

Thiago Brandão Damasceno thiagobrandam

View GitHub Profile
View deep_find.rb
# return path for deep find in nested hashes
def deep_find(hash, term)
paths = []
_deep_find(hash, term, root = "", paths)
def _deep_find(hash, term, root, paths)
if hash.is_a?(Hash)
thiagobrandam / credo_4.ex
Created May 22, 2018
Código exemplo em Elixir
View credo_4.ex
defmodule ProntoCredoExample.Example do
@moduledoc """
This module serves as an example for
cyclomatic complexity
def do_something_complex(a, b, c, d, param) do
g = 0
e = case param
thiagobrandam / credo_3.groovy
Created May 22, 2018
Snippet demonstrando execução do pronto
View credo_3.groovy
stage ('Rodando testes') {
// ...
github_status github_pr -c "origin/master"
thiagobrandam / credo_2.ex
Created May 22, 2018
Dependência no mix.exs
View credo_2.ex
defp deps do
{:credo,"~> 0.8", only: [:dev, :test], runtime:false}
thiagobrandam / credo_1.rb
Created May 22, 2018
Inconsistência no código
View credo_1.rb
# aqui o operador de soma está separado por um espaço
def add (a, b) do: a + b
# aqui o operador de subtração não está
def subtract(a, b), do: a-b
thiagobrandam /
Last active Oct 22, 2015 — forked from olalonde/
Use NFS instead of vboxsf in Docker Machine
# This script will mount /Users in the boot2docker VM using NFS (instead of the
# default vboxsf). It's probably not a good idea to run it while there are
# Docker containers running in boot2docker.
# Usage: sudo ./
View let_spec.rb
require 'rspec'
class BankAccount
attr_reader :balance
def initialize(initial_value = nil)
@balance = initial_value || 0
def deposit(amount)
@balance += amount
View fibers_and_em.rb
# Trying to grasp fibers and EM!
# Using this example: (slide 54)
# Fiber#resume(*params) => when first called, it passes all params as block params to
# In the next calls of resumes, *params is the return value of any Fiber.yield
# Fiber.yield stops execution of current fiber
# So, in the run-loop from EM, the fiber stops execution and gives up control
thiagobrandam / transaction_debug.rb
Last active Aug 29, 2015
Debugging transactions ...
View transaction_debug.rb
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Transaction).map do |a|
[a.object_id, a.class, a]
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Mysql2Adapter).map do |a|
[a.object_id, a.class, a]
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Mysql2Adapter).map do |a|
[a.object_id, a.open_transactions]
View transliterate.sql
-- Copyright (c) 2009, Ionut Gabriel Stan. All rights reserved.
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
You can’t perform that action at this time.