Skip to content

Instantly share code, notes, and snippets.

Mix.install([:nimble_csv])
defmodule Transform do
@slugs_top_100 ~w(bitcoin ethereum tether binance-coin cardano ripple dogecoin usd-coin polkadot-new uniswap binance-usd bitcoin-cash solana litecoin chainlink internet-computer wrapped-bitcoin ethereum-classic matic-network stellar theta vechain file-coin luna multi-collateral-dai tron aave monero ftx-token eos pancakeswap crypto-com-coin bitcoin-bep2 the-graph maker axie-infinity neo cosmos klaytn shiba-inu bitcoin-sv avalanche tezos algorand unus-sed-leo elrond-egld iota amp compound bittorrent huobi-token hedera-hashgraph terrausd decred kusama chiliz waves quant dash blockstack zcash nem thorchain theta-fuel holo celsius okb helium decentraland enjin-coin sushi yearn-finance trueusd ravencoin near-protocol xinfin-network synthetix-network-token flow zilliqa nexo basic-attention-token qtum bitcoin-gold telcoin harmony bancor paxos-standard ethos kucoin-shares celo digibyte siacoin ontology 0x mdex zencash ankr fantom swissborg curve)
@metrics ~w(activ
@IvanIvanoff
IvanIvanoff / analyze_csv.exs
Last active June 26, 2021 23:11
analyze csv
Mix.install([{:csv, "~> 2.4"}])
num_to_column = fn num ->
cond do
num <= 25 -> <<?A + num::utf8>>
num <= 51 -> "A" <> <<?A + (num - 26)::utf8>>
num <= 76 -> "B" <> <<?A + (num - 51)::utf8>>
num <= 100 -> "C" <> <<?A + (num - 75)::utf8>>
true -> raise("Boom")
end
defmodule EthData do
@from ~U[2019-05-01 00:00:00Z]
@to ~U[2019-08-01 00:00:00Z]
@slug "ethereum"
@special [
"socialGainersLosersStatus",
"socialVolume",
{"socialVolume", "mentionsCount"},
{"ethSpentOverTime", "ethSpent"},
@IvanIvanoff
IvanIvanoff / bad_diff.ex
Created August 14, 2019 12:20
exunit bad diff
defmodule BadListDiff do
use ExUnit.Case
test "bad list diff" do
assert [
"mean_realized_price_usd_10y",
"mean_realized_price_usd_180d",
"mean_realized_price_usd_1d",
"mean_realized_price_usd_20y",
"mean_realized_price_usd_2y",
@IvanIvanoff
IvanIvanoff / find_path.ex
Last active June 5, 2019 13:51
Search where is located a key-value pair in deeply nested structs
defmodule MapUtils do
def find_pair_path(map, key, value) when is_map(map) do
do_find_pair_path(map, key, value, [])
|> Enum.map(&(&1 |> List.flatten() |> Enum.reverse()))
|> Enum.reject(&(&1 == nil || &1 == []))
end
defp do_find_pair_path(map, key, value, path) when is_map(map) do
keys = Map.keys(map)

Keybase proof

I hereby claim:

  • I am ivanivanoff on github.
  • I am ivanivanoff (https://keybase.io/ivanivanoff) on keybase.
  • I have a public key ASACYD-iiQRdWb1-xxvHjzUHw4-lwLroPa9DJpmH2kKmWwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am ivanivanoff on github.
  • I am ivanivanoff (https://keybase.io/ivanivanoff) on keybase.
  • I have a public key ASACYD-iiQRdWb1-xxvHjzUHw4-lwLroPa9DJpmH2kKmWwo

To claim this, I am signing this object:

@IvanIvanoff
IvanIvanoff / pre-commit
Last active October 23, 2022 07:48
pre-commit hook for checking mix formatting
#!/bin/bash
cd `git rev-parse --show-toplevel`
echo "Running pre-commit hook: Check elixir formatting with mix format"
mix format --check-formatted
if [ $? == 1 ]; then
echo "mix format --check-formatted found formatting issues."
exit 1
fi
{What is the capital of Albania?, Tirana, []}
{What is the capital of Andorra?, Andorra, []} la Vella
{What is the capital of Armenia?, Yerevan, []}
{What is the capital of Austria?, Vienna, []}
{What is the capital of Azerbaijan?, Baku, []}
{What is the capital of Belarus?, Minsk, []}
{What is the capital of Belgium?, Brussels, []}
{What is the capital of Bosnia?, and, []} Herzegovina Sarajevo
{What is the capital of Bulgaria?, Sofia, []}
{What is the capital of Croatia?, Zagreb, []}
{Albania, Tirana, []}
{Andorra, Andorra, []} la Vella
{Armenia, Yerevan, []}
{Austria, Vienna, []}
{Azerbaijan, Baku, []}
{Belarus, Minsk, []}
{Belgium, Brussels, []}
{Bosnia, and, []} Herzegovina Sarajevo
{Bulgaria, Sofia, []}
{Croatia, Zagreb, []}