Skip to content

Instantly share code, notes, and snippets.

@eproxus
eproxus / ._Extending the Erlang Shell.md
Last active February 2, 2023 12:22
Extending the Erlang Shell

Extending the Erlang Shell

Erlang makes it possible to extend the Erlang shell with your own built-in functions using the special module user_default. We can use this to add functions to the shell, and even add custom libraries to the code path for all Erlang shells.

How To Setup

  1. Start by creating a file called .erlang in your home directory. Any Erlang expression ending with a dot in this file will be executed when the Erlang shell starts
  2. Create the directory ~/.erlang.d:
    $ mkdir ~/.erlang.d
@eproxus
eproxus / _OP-Z_Automated_Backup_on_macOS.md
Created April 11, 2022 09:44
OP-Z Automated Backup on macOS

OP-Z Automated Backup for macOS

Setup

  1. Store backup.sh somewhere and make it executable:
    $ vim ~/Music/OP-Z/Backups/Support/backup.sh
    (The file opz_backup.sh is only needed as a convenience shortut to manually run the backup)
@eproxus
eproxus / README.md
Last active February 20, 2022 10:21
Hide Firefox Tab Bar on Windows
  1. Go to MenuHelpMore troubleshooting informationApplication BasicsProfile FolderOpen Folder
  2. Create a folder named chrome
  3. Create a new text file inside chrome named userChrome.css and paste the content
  4. Go to about:config in Firefox
  5. Change the setting toolkit.legacyUserProfileCustomizations.stylesheets to true
  6. Restart Firefox
@eproxus
eproxus / 01 Erlang GitHub Actions With setup-beam and Caching.md
Last active September 4, 2023 13:07
How to Setup Erlang GitHub Actions With setup-beam and Caching

Erlang GitHub Actions With setup-beam and Caching

To build and test Erlang projects on GitHub actions with Rebar it is fastest to use the setup-beam action and use caching.

To get started, create a workflow file in .github/workflows in your repository. For this example we use a file called .github/workflows/continuous_integration.yml.

@eproxus
eproxus / COWBOY_STREAM_HANDLER.md
Last active March 21, 2024 12:06
How to Create a Cowboy Stream Handler

How to Create a Cowboy Stream Handler

Add your stream handler to the list of stream handlers in the protocol options:

{ok, Pid} = cowboy:start_clear(ListenerName,
    [{port, Port}],
    #{
        env => #{dispatch => Dispatch},
 stream_handlers => [my_stream_h, cowboy_compress_h, cowboy_stream_h]
@eproxus
eproxus / COWBOY_MIDDLEWARE.md
Last active November 4, 2023 18:39
How to Create a Cowboy Middleware

How to Create a Cowboy Middleware

Add an entry to the middlewares. Usually you want to keep the standard Cowboy handlers afterwards, but you can replace them if you want.

{ok, Pid} = cowboy:start_clear(ListenerName,
    [{port, Port}],
    #{
 env => #{dispatch => Dispatch},
@eproxus
eproxus / new_gen_event.erl
Last active November 13, 2019 15:30
Erlang Behaviour Templates
-module().
-behavior(gen_event).
% Callbacks
-export([init/1]).
-export([handle_event/2]).
-export([handle_call/2]).
-export([handle_info/2]).
-export([terminate/2]).
# Load Order Interactive Interactive Script
# Startup Only login Always
# ------------- ----------- ----------- ------
# /etc/zshenv 1 1 1
# ~/.zshenv 2 2 2
# /etc/zprofile 3
# ~/.zprofile 4
# /etc/zshrc 5 3
# ~/.zshrc 6 4
# /etc/zlogin 7
-module().
-behavior(gen_server).
% API
-export([start_link/0]).
% Callbacks
-export([init/1]).
-export([handle_call/3]).
@eproxus
eproxus / sVimcss.css
Last active November 25, 2018 16:57
sVim Settings with Vimium Hint Styles
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#sVim-command {