Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alexander de Sousa alexdesousa

🎯
Focusing
View GitHub Profile
@alexdesousa
alexdesousa / curl.sh
Created Jun 1, 2021
`curl <url> | sh` but for Elixir >= 1.12
View curl.sh
# 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 / pub_sub.ex
Last active Mar 26, 2020
Small pubsub implementation using pg2
View pub_sub.ex
defmodule PubSub do
@moduledoc """
This module defines the basic pub-sub functions.
"""
@typedoc """
Channel name.
"""
@type channel :: term()
@alexdesousa
alexdesousa / Code.gs
Last active Feb 21, 2020
Gathers stats from your DEV articles.
View Code.gs
/**
* Gathers statistics from your dev.to articles.
*
* Needs the following colunms:
* - Day
* - Date
* - Time
* - Title
* - Views
* - Reactions
@alexdesousa
alexdesousa / ping_server.erl
Last active Oct 5, 2018
gen_server: concurrent vs. serial calls.
View ping_server.erl
-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]).