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_relative 'test_helper' | |
| require 'helix_runtime' | |
| require 'etl-test/native' | |
| class MyTest < Minitest::Test | |
| def test_valid | |
| assert_equal true, IbanChecker.check('TL380080012345678910157') | |
| 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
| # | |
| # to run and restart continuously when the code changes: | |
| # | |
| # find scripts lib mix.* | entr -rc mix run --no-halt scripts/plug_demo.exs | |
| # | |
| defmodule MySimpleServerPlug do | |
| # https://hexdocs.pm/plug/Plug.Conn.html | |
| import Plug.Conn | |
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
| def recurly_tax_info(request) | |
| # dump from https://api.recurly.com/js/v1/tax?vat_number=&country=FR¤cy=USD&version=3.0.10&key=my_key&callback=__jp1 | |
| country = request.uri.query_values['country'] | |
| currency = request.uri.query_values['currency'] | |
| vat_number = request.uri.query_values['vat_number'] | |
| expect(country).to eq('FR') | |
| expect(currency).to eq('USD') | |
| expect(vat_number).to eq('') |
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
| function darkback { | |
| osascript -e "tell application \"Terminal\" to set background color of window 1 to {0,0,0}" | |
| } | |
| function lightback { | |
| osascript -e "tell application \"Terminal\" to set background color of window 1 to {65535,65535,65535}" | |
| } |
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
| # Important: please make sure to still carefully read each gem changelog! | |
| require 'yaml' | |
| def system!(cmd) | |
| raise "Cannot run command!!!" unless system(cmd) | |
| end | |
| gems = YAML.load(IO.read('outdated.yml')).fetch('gems') | |
| gems.each do |gem| |
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
| # NOTE: several improvements to be made but I'm in a VAT preparation hurry | |
| # - use "up" and "down" to make the migration reversible | |
| # - use Sequel methods for extension/server create | |
| Sequel.migration do | |
| change do | |
| file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data', 'vat_rates.csv')) | |
| run 'CREATE EXTENSION file_fdw;' | |
| run 'CREATE SERVER file_fdw_server FOREIGN DATA WRAPPER file_fdw;' | |
| create_table(:vat_rates, foreign: 'file_fdw_server', options: {format: 'csv', header: 'true', filename: file, delimiter: ','}) do | |
| String :month, null: false |
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
| def command_as(command, as:) | |
| command(%Q{su -c #{Shellwords.escape(command)} --login #{as}}) | |
| end | |
| %w(my_user).each do |user| | |
| describe "RVM setup for user #{user}" do | |
| %w(ruby-2.4.0).each do |ruby_version| | |
| let(:subject) { command_as('rvm list strings', as: user) } | |
| it "has #{ruby_version} installed" do | |
| expect(subject.stdout.split("\n")).to include(ruby_version) |
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
| source 'https://rubygems.org' | |
| gem 'colorize' |
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
| # Example of use to detect a class method call throughout a whole test suite | |
| # This could also be achieved with a RSpec double. | |
| class Dir | |
| old_method = method(:[]) | |
| define_singleton_method(:[]) do |*args| | |
| # Use failure in a test-suite where you'd need to detect use | |
| fail "FIXME - Dir[] called with args #{args.inspect}" | |
| # Or call through using this, if you only need to trace | |
| # old_method.call(*args) |