Skip to content

Instantly share code, notes, and snippets.

View alexdesousa's full-sized avatar
🎯
Focusing

Alex de Sousa alexdesousa

🎯
Focusing
View GitHub Profile
@alexdesousa
alexdesousa / ping_server.erl
Last active October 5, 2018 15:03
gen_server: concurrent vs. serial calls.
-module(ping_server).
-behaviour(gen_server).
-export([start/0, serial_burst/2, concurrent_burst/2]).
%gen_server callbacks.
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3,
terminate/2]).
@alexdesousa
alexdesousa / Code.gs
Last active February 21, 2020 20:22
Gathers stats from your DEV articles.
/**
* Gathers statistics from your dev.to articles.
*
* Needs the following colunms:
* - Day
* - Date
* - Time
* - Title
* - Views
* - Reactions
@alexdesousa
alexdesousa / curl.sh
Created June 1, 2021 13:00
`curl <url> | sh` but for Elixir >= 1.12
# Step 2: Pipe the curl's output into elixir directly.
# Warning: only execute scripts you trust.
$ FILENAME="https://raw.githubusercontent.com/wojtekmach/mix_install_examples/d98fce880eedda18747e592ec6c42b6ca817136f/scenic.exs" \
curl "$FILENAME" | exsh
@alexdesousa
alexdesousa / quote_prices.exs
Last active March 7, 2022 20:41
Getting sICX/bnUSD quote prices using Elixir's ICON SDK
#!/usr/bin/env elixir
Mix.install([
{:icon, "~> 0.1"}
])
defmodule Quotes do
use Yggdrasil
alias Icon.Schema.Types.EventLog
@alexdesousa
alexdesousa / pub_sub.ex
Last active July 19, 2023 16:48
Small pubsub implementation using pg2
defmodule PubSub do
@moduledoc """
This module defines the basic pub-sub functions.
"""
@typedoc """
Channel name.
"""
@type channel :: term()