Skip to content

Instantly share code, notes, and snippets.

View aequanimitas's full-sized avatar
🦀
noob

Hector Avenido aequanimitas

🦀
noob
View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@aequanimitas
aequanimitas / binary_tree.erl
Created October 30, 2021 07:14 — forked from d11wtq/binary_tree.erl
Binary tree implementation in Erlang.
%% @doc A binary tree implementation in Erlang.
%% A binary tree stores keys and values.
-module(binary_tree).
-export([init/0, init/1, insert/3, lookup/2]).
-define(EMPTY_NODE, {node, 'empty'}).
%% @doc Initialize an empty binary tree node.
%% This is how the root of the tree should be established.
%%
@aequanimitas
aequanimitas / rbtree.erl
Created October 30, 2021 06:11 — forked from mjn/rbtree.erl
Erlang implementation of a red-black tree
-module(rbtree).
-export([insert/3, find/2]).
% Node structure: { Key, Value, Color, Smaller, Bigger }
find(_, nil) ->
not_found;
find(Key, { Key, Value, _, _, _ }) ->
{ found, { Key, Value } };
@aequanimitas
aequanimitas / Elixir Email Validation
Created July 11, 2018 04:53 — forked from mgamini/Elixir Email Validation
Elixir Email Validation
defmodule EmailValidator do
# ensure that the email looks valid
def validate_email(email) when is_binary(email) do
case Regex.run(~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/, email) do
nil ->
{:error, "Invalid email"}
[email] ->
try do
Regex.run(~r/(\w+)@([\w.]+)/, email) |> validate_email
@aequanimitas
aequanimitas / watcher.sh
Last active June 24, 2022 16:13 — forked from josevalim/watcher.sh
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
# fswatch lib/ test/ | mix test --stale --listen-on-stdin
fswatch -0 --latency=0.01 --one-per-batch lib test | mix test --stale test/
@aequanimitas
aequanimitas / latency.markdown
Created October 8, 2016 23:24 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@aequanimitas
aequanimitas / introrx.md
Created June 17, 2016 07:17 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
npm install babel-{cli,core,eslint,loader,preset-es2015,preset-react} webpack webpack-{dev,hot}-middleware mocha jsdom {css,style,sass}-loader react-addons-test-utils expect --save-dev
reboot a gl0be tattoo router, basic auth, lets create a faux api for this
http://username:password@ip.of.default.gateway/goform/formGlobal?encap=pppoe&username=username%40globelines.com.ph&password=password&submit-url=%2Fglobe_1pwn1.asp&reboot=Save+and+Reboot