Skip to content

Instantly share code, notes, and snippets.

View tiagoefmoraes's full-sized avatar

Tiago Moraes tiagoefmoraes

View GitHub Profile
@tiagoefmoraes
tiagoefmoraes / date_time_generators.ex
Created December 8, 2023 01:16 — forked from LostKobrakai/date_time_generators.ex
stream_data generators to create elixir date/time structs
defmodule DateTimeGenerators do
use ExUnitProperties
@time_zones ["Etc/UTC"]
def date do
gen all year <- integer(1970..2050),
month <- integer(1..12),
day <- integer(1..31),
match?({:ok, _}, Date.from_erl({year, month, day})) do
@tiagoefmoraes
tiagoefmoraes / defstruct_test.ex
Created April 6, 2022 11:34
DefStructTest - cover all `defstruct` calls on your elixir app
defmodule MyApp.DefStructTest do
use ExUnit.Case, async: true
test "to cover defstruct" do
project_structs()
|> Enum.each(&assert &1.__struct__(), to_string(&1))
end
defp project_structs do
{:ok, modules} = :application.get_key(:my_app, :modules) # change to your app's name
@tiagoefmoraes
tiagoefmoraes / regex.livemd
Last active January 29, 2022 21:34
Elixir regex sigil highlighting

Regex Syntax Highlight

Section

Run in Livebook

@tiagoefmoraes
tiagoefmoraes / phoenix.md
Last active December 16, 2021 01:13 — forked from teamon/phoenix.md
Run Phoenix inside LiveBook

Phoenix in LiveBook

Info

You can import this Gist directly into your LiveBook instance.

Setup

Mix.install([:jason, :plug_cowboy, :phoenix, :phoenix_html, :phoenix_live_view])
@tiagoefmoraes
tiagoefmoraes / backtrace
Last active July 17, 2020 21:00
Baby Squeel x ActiveRecord >= 5.2.1
raise on line: https://github.com/rails/rails/blob/7b5cc5a5dfcf38522be0a4b5daa97c5b2ba26c20/activerecord/lib/active_record/associations/join_dependency/join_association.rb#L58
RuntimeError:
now I have the table
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency/join_association.rb:58:in `tables='
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency.rb:145:in `block in construct_tables!'
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency/join_part.rb:38:in `block in each_children'
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency/join_part.rb:37:in `each'
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency/join_part.rb:37:in `each_children'
# /.gem/ruby/2.5.3/gems/activerecord-5.2.4.3/lib/active_record/associations/join_dependency.rb:144:in `construct_tables!'
# /.gem/ruby/2.5.3/gems/polyamoro
NFe*
Pendente*
transmitir -> Aguardando Autorização
Aguardando Autorização
autorizada -> Autorizada
erro -> Erro
volta -> Pendente
Autorizada
Erro
@tiagoefmoraes
tiagoefmoraes / machine.js
Last active October 17, 2019 15:02
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@tiagoefmoraes
tiagoefmoraes / gist:92efc670dcdb8194b481a1e3e8b0d688
Created August 8, 2017 16:35 — forked from ninthspace/gist:4360267
How I migrated from rbenv to chruby, and kept per-project gems nice and tidy.

Remove rbenv and any rubies, gems etc.:

$ rm -rf ~/.rbenv

Uninstall rbenv if installed via Homebrew

$ brew uninstall rbenv

Remove references to rbenv in ~/.bash_profile etc.

@tiagoefmoraes
tiagoefmoraes / esnextbin.md
Created December 5, 2016 15:01
esnextbin sketch
@tiagoefmoraes
tiagoefmoraes / esnextbin.md
Last active November 14, 2016 18:11
esnextbin sketch