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 Aaa do | |
| # terminal condition. If we've gotten through the whole pattern we're done. | |
| def matches(<<>>, <<>>), do: true | |
| # If the first character matches and has a question mark we must make an | |
| # epsilon transition. We have to try both "universes". In one "universe" | |
| # we proceed as if we consumed the optional match, and the other we proceed | |
| # as if we didn't. The success of either means the match succeeds. This | |
| # means for this branch we don't get TCO =( but this should be relatively rare. | |
| def matches(<<char, ??, rest1 :: binary>>, string = <<char, rest2 :: binary>>) do |
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
| :net_kernel.start([:"main@127.0.0.1"]) | |
| :erlang.set_cookie(:cook) | |
| {:ok, peer, peername} = | |
| :peer.start(%{connection: 0, name: :peer, host: ~C'127.0.0.1'}) | |
| :peer.call(peer, :erlang, :set_cookie, [:cook]) | |
| Node.connect(peername) | |
| # add code paths | |
| :rpc.call(peername, :code, :add_paths, [:code.get_path()]) |
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
| { | |
| "Elixir debug": { | |
| "prefix": "dd", | |
| "body": "|> dbg", | |
| "description": "injects an elixir dbg statement" | |
| }, | |
| } |
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
| const beam = @import("beam.zig"); | |
| const e = @import("erl_nif.zig"); | |
| const std = @import("std"); | |
| pub fn make(env: beam.env, value: anytype) beam.term { | |
| const T = @TypeOf(value); | |
| if (T == beam.env) return value; | |
| switch (@typeInfo(T)) { | |
| .Array => return make_array(env, value), | |
| .Pointer => return make_pointer(env, value), |
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
| const E = enum(u12) { | |
| Int = 0xFFF, | |
| String = 0xFFE, | |
| Pointer = 0xFFD, | |
| } | |
| const P = packed union(?e){ | |
| const this = @This(); | |
| Int: packed struct { |
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
| { | |
| "Inspect": { | |
| "prefix": "ins", | |
| "body": "|> IO.inspect(label: \"$RELATIVE_FILEPATH:#{__ENV__.line}\")", | |
| "description": "Adds a pipeline with a labelled `IO.inspect`", | |
| } | |
| } |
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 T do | |
| @foo [%{foo: "bar"}] | |
| def t(@foo) do | |
| :ok | |
| end | |
| end | |
| # DISASSEMBLED RESULT: |
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(:"7tbgPucj") do | |
| def(fun0(arg0, arg1, arg2)) do | |
| expr0 = fun1(arg0, arg1, arg0, true, arg2, arg0, arg2) | |
| expr1 = fun3(expr0, arg1, arg2, 0.3876953125, expr0, arg2) | |
| expr2 = [arg1, expr1, -0.8984375] | |
| expr3 = [arg0, arg2, false, expr0, <<185, 89>>, -980.70703125, arg0, expr0, arg2] | |
| expr4 = [arg2, expr1, expr0, arg1, false, -9, :ulI] | |
| expr5 = :j | |
| 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
| defprotocol Convertible do | |
| def convert(a, target_struct) | |
| end | |
| defmodule ConversionBoilerplate do | |
| defmacro __using__() do | |
| quote do | |
| def convert(a, to: struct_module) do | |
| # maybe do some asserts here | |
| module = Module.concat(__MODULE__, struct_module) |
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
| defprotocol Proto do | |
| def generic_getter(value) | |
| end | |
| defmodule A do | |
| defstruct [:a] | |
| def generic_getter(v), do: v.a | |
| defimpl Proto do | |
| defdelegate generic_getter(value), do: A |