Skip to content

Instantly share code, notes, and snippets.

View WLSF's full-sized avatar

Willian Frantz WLSF

View GitHub Profile
version: '3'
services:
db:
image: postgres:11-alpine
restart: always
ports:
- 5432:5432
volumes:
- ./db-data:/var/lib/postgresql/data
@WLSF
WLSF / report.ex
Created November 15, 2020 17:15
Macro to catch errors
defmodule Report do
defmacro __using__(_opts) do
quote do
import Report
end
end
defmacro dispatch(name, do: block) do
function_name = String.to_atom(name)
@WLSF
WLSF / reports.ex
Last active November 21, 2020 23:09
Trying decorators to check if implicit tracing would be a good idea.
defmodule Reports do
use Decorator.Define, [trace: 0]
def trace(body, context) do
quote do
try do
unquote(body)
rescue
e ->
IO.puts("Erro: " <> e.message)
@WLSF
WLSF / http_server.ex
Created June 25, 2022 19:13
Web Server with Elixir
defmodule HTTPServer do
@moduledoc """
Este módulo é responsável por estabelecer uma conexão de servidor TCP
para suportar requisições HTTP.
Função principal: `start/1`
"""
defmodule Conn do
@moduledoc """
Let's write some Elixir.
defmodule FooBar do
def foo(a) do
if a < 0 do
bar(a, -1)
else
bar(a, 1)
end
end
#include <stdio.h>
#pragma warning(disable:4996)
struct WAV_FORMAT {
char riff[4];
int32_t file_size;
char wave[4];
char fmt[4];
int32_t data_length;
int16_t format_tag;