This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hashify = ->(str, memo = []){ str =~ /\./ ? (r = str.split(/\./,2); {r[0] => hashify[r[1],memo << r[0]]}) : {str => [memo << str].join('.')} } | |
| # hashify['a.b.c.d'] => | |
| # {"a"=>{"b"=>{"c"=>{"d"=>"a.b.c.d"}}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Transaction).map do |a| | |
| [a.object_id, a.class, a] | |
| end | |
| ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Mysql2Adapter).map do |a| | |
| [a.object_id, a.class, a] | |
| end | |
| ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::Mysql2Adapter).map do |a| | |
| [a.object_id, a.open_transactions] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Trying to grasp fibers and EM! | |
| # Using this example: http://www.slideshare.net/kbal11/ruby-19-fibers (slide 54) | |
| # Fiber#resume(*params) => when first called, it passes all params as block params to | |
| # Fiber.new | |
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rspec' | |
| class BankAccount | |
| attr_reader :balance | |
| def initialize(initial_value = nil) | |
| @balance = initial_value || 0 | |
| end | |
| def deposit(amount) | |
| @balance += amount | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # 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 ./boot2docker-use-nfs.sh | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defp deps do | |
| [ | |
| {:credo,"~> 0.8", only: [:dev, :test], runtime:false} | |
| ] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage ('Rodando testes') { | |
| // ... | |
| sh "PRONTO_GITHUB_ACCESS_TOKEN=${githubToken}" | |
| PRONTO_PULL_REQUEST_ID=${GITHUB_PR_NUMBER} pronto run -f | |
| github_status github_pr -c "origin/master" | |
| //... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |