Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile
@doc """
Asserts that the given changeset is invalid, and that when the
assertion_expression is applied to the error_message it results in a truthy
value.
"""
defmacro assert_invalid(changeset, field, assertion_expression) when is_atom(field) do
expr = Macro.to_string(assertion_expression)
quote do
error_messages = unquote(changeset)
@leobessa
leobessa / mvn_install_files.rb
Created November 27, 2019 17:37
Script for mvn install:install-file for jars in directory
Dir["./**/*.jar"].map do |f|
group_dir, artifact_id, version, file_name = f.reverse.split("/", 4).map(&:reverse).reverse
path = File.absolute_path f
group_id = group_dir.sub("./","").gsub("/",".")
packaging = "jar"
pom_path = path.sub /\.[^.]+\z/, ".pom"
"mvn install:install-file -Dfile=#{path} -DgroupId=#{group_id} -DartifactId=#{artifact_id} -Dversion=#{version} -Dpackaging=#{packaging} -DpomFile=#{pom_path} -DcreateChecksum=true"
end
@leobessa
leobessa / README.md
Last active May 3, 2019 17:53
COBAN

README COBAN

URL

A url para integração com a COBAN segue o seguinte modelo:

https://totvs.coban.myconsig.com.br/token/%{jwt}

JWT

@leobessa
leobessa / keybase.md
Created January 7, 2019 16:53
keybase.md

Keybase proof

I hereby claim:

  • I am leobessa on github.
  • I am leobessa (https://keybase.io/leobessa) on keybase.
  • I have a public key ASCOWpKCSTYeyNpiZsvLccj-Q2OWHTB__xvUIs4JalibFwo

To claim this, I am signing this object:

@leobessa
leobessa / hu.md
Last active November 23, 2015 14:09
Seminário de MQ

Problema

Um hospital deseja gerar a escala de plantão noturna de 5 farmacêuticos para o mês de Dezembro de 2015. Durante todo o mês será necessária a presença de pelo menos 2 farmacêuticos de plantão. Os farmacêuticos f1, f2, f3, f4 e f5 trabalham no regime 12X36, com cargas horárias quem demandam 12, 13, 10, 12 e 10 plantões respectivamte. Além disso, todos funcionários devem ter pelo menos 1 (uma) folga de 24h (ao todo ou em parte) no domingo a cada 4 semanas.

Formulação do problema usando PL

Seja X uma matriz 5x31, onde:

[{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Alexandre S. Cauduro","site_abbr":"P1","reward_units":0.5},{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Paula Vargas de Saboya","site_abbr":"P2","reward_units":0.5},{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Claudia Carolina Vieira Silva Davini","site_abbr":"P3","reward_units":0.5},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"German Salinas Perez","site_abbr":"P1","reward_units":0.5},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"Paula Vargas de Saboya","site_abbr":"P2","reward_units":0.5},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"Elssi Espinosa","site_abbr":"P3","reward_units":0.5},{"lifetime":"['2015-12-01T19:00:00-02:00','2015-12-02T07:00:00-02:00')","name":"Alessandra","site_abbr":"P1","reward_units":1},{"lifetime":"['2015-12-01T19:00:00-02:00','2015-
[{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Alexandre S. Cauduro","site_abbr":"P1"},{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Paula Vargas de Saboya","site_abbr":"P2"},{"lifetime":"['2015-12-01T07:00:00-02:00','2015-12-01T13:00:00-02:00')","name":"Claudia Carolina Vieira Silva Davini","site_abbr":"P3"},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"German Salinas Perez","site_abbr":"P1"},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"Paula Vargas de Saboya","site_abbr":"P2"},{"lifetime":"['2015-12-01T13:00:00-02:00','2015-12-01T19:00:00-02:00')","name":"Elssi Espinosa","site_abbr":"P3"},{"lifetime":"['2015-12-01T19:00:00-02:00','2015-12-02T07:00:00-02:00')","name":"Alessandra","site_abbr":"P1"},{"lifetime":"['2015-12-01T19:00:00-02:00','2015-12-02T07:00:00-02:00')","name":"Alexandre S. Cauduro","site_abbr":"P2"},{"lifetime":"['2015-12-01T19:00:00-02:00','2015-12-02T07:00
set WORKERS = 1..5;
set DAYS = 1..31;
set WORKER_DEMAND = {13,13,12,13,13};
set SUNDAYS = {6,13,20,27};
var working {i in DAYS, j in WORKERS} integer >= 0, <= 1;
minimize Total_Work: sum {i in DAYS, j in WORKERS} working[i,j];
subject to Min_Service {i in DAYS}:
@leobessa
leobessa / Gemfile
Created July 20, 2012 20:56
Heroku Cedar static file server with rack
source :rubygems
gem "rack", "~> 1.4"
gem "rack-rewrite", "~> 1.2.1"
gem "thin"
@leobessa
leobessa / spec_helper.rb
Created October 20, 2011 06:44
How to define example group run order in RSpec 2
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}