Skip to content

Instantly share code, notes, and snippets.

View alisinabh's full-sized avatar

Alisina Bahadori alisinabh

View GitHub Profile
@alisinabh
alisinabh / opposite_math_macro.exs
Last active December 16, 2016 00:07
Creating a macro with elixir to vice versa nested math operations
defmodule OppositeMath do
@moduledoc """
This module helps with oppositting nested math formuals like 2 + 5 * 4 + 6 => 2 - 5 / 4 - 6 for sake of learning elixir macros
"""
@doc """
This macro opposites all math symbols in a formula
## Examples
iex> OppositeMath.opposite 1+1
@alisinabh
alisinabh / bitconverter_sample.ex
Last active February 16, 2023 22:16
Elixir convert binary (byte array) to signed Int32 with pattern matching and vice versa [DEPRECARED - just use whats inside the functions]
defmodule ZigorProxy.BitConverter do
@moduledoc """
This module handles standard binary operations.
Converting binaries to and from general data types.
"""
require Logger
@doc """
Converts binary of 4 bytes into an signed integer.