Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile

Getting Lazy with Dataflow Graphs in Elixir

Intro

What do Tensorflow, Apache Airflow, Rule Engines, and Excel have in common?

Under the hood they all use DAGs to model data-flow dependencies of the program. Using graphs to model programs is great because you can modify the program at runtime. Lets talk about doing this in Elixir for great good.

@leobessa
leobessa / 2024-cusip-prices.csv
Last active January 28, 2025 02:15
2024 asset closing prices by date and cusip
We can't make this file beautiful and searchable because it's too large.
2024-01-02,00123Q104,9.6600000000
2024-01-02,00130H105,19.3400000000
2024-01-02,00206R102,17.2500000000
2024-01-02,00206RHJ4,983.1800000000
2024-01-02,00206RKG6,886.8200000000
2024-01-02,00206RMM1,809.1800000000
2024-01-02,00214Q104,50.5000000000
2024-01-02,00214Q302,32.7200000000
2024-01-02,00214Q708,26.3300000000
2024-01-02,00215W100,9.0800000000
@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 / 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 / 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 / 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}: