Skip to content

Instantly share code, notes, and snippets.

View diasbruno's full-sized avatar

Bruno Dias diasbruno

View GitHub Profile
@diasbruno
diasbruno / ip_address_eth0.sh
Created April 15, 2024 12:46
Find host's IP
#!/bin/env bash
set -eu
ip -br a s eth0 | awk '{ split($3,a,"/"); print a[1]; }'
@diasbruno
diasbruno / rpmbuild-tree.sh
Created April 5, 2024 19:24
Example of RPM packaging on /usr/local/bin
.
├── BUILD
│   ├── test-0.0.1
│   │   └── test.sh
│   └── test.sh
├── BUILDROOT
├── RPMS
│   └── x86_64
│   └── test-0.0.1-1.el8.x86_64.rpm
├── SOURCES
@diasbruno
diasbruno / pipelines_de_erros.ts
Last active February 11, 2024 01:55
Pipeline de errors.
// `isAuth`, `validateBody` e `addCredit` podem term cada um um tipo de erro diferente.
// temos 2 maneiras: classificar os erros no mesmo dominio (mais comum)
// ou, precisa de um objeto de unificação (existem outras tecnicas mais exóticas).
// Modo mais comum.
class CreateAccountErrors {}
class NotAuthError extends CreateAccountErrors {}
class ValidateCreateAccountError extends CreateAccountErrors {}
class AddCreditError extends CreateAccountErrors {}
@diasbruno
diasbruno / shell.nix
Last active November 21, 2023 11:54
Fix to run Erlang/Elixir from nix on macOS ()
{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
erlang = nixpkgs.beam.interpreters.erlangR25.override {
configureFlags = ["--disable-jit"];
};
beamPackages = nixpkgs.beam.packagesWith erlang;
in pkgs.mkShell {
nativeBuildInputs = with pkgs; [erlang elixir];
}
@diasbruno
diasbruno / haskell-github-action-with-coverage.org
Last active February 18, 2023 20:54
haskell github action with coverage

haskell github action with coverage

@github:haskell/actions

enabling coverage

This requires your project to be configured with `–enable-coverage`. This way it compiles in a way to be instrumented.

@diasbruno
diasbruno / daggy_example.js
Created January 27, 2023 17:01
data types with daggy example.
const { taggedSum } = require('daggy');
const AuthenticationError = taggedSum(
'AuthenticationError',
{
AccountSuspended: [],
InformationMismatch: [],
}
);
@diasbruno
diasbruno / base_component.js
Created October 20, 2022 19:24
dependency inversion with closures
export default function BaseComponent(apicall) {
return (props): React.FC => { // <<- this is the real renderable component
const { /* ... */ } = useUser(apicall);
return /* ... */
};
}
@diasbruno
diasbruno / vdom.hs
Created July 11, 2022 21:08
micro virtual dom
module MVD where
data Kind = Div | A
deriving (Eq, Show)
data Opts = ClassName String
deriving (Eq, Show)
data HTML = HTML Kind Opts
| HText String
633 comby -matcher .rb ':[[h]].each do |:[[j]]|:[[i]]end' ''
635 comby -matcher .rb ':[h].each do |:[j]|:[i]end' ''
636 comby -matcher .rb ':[h].each do |:[j]|:[[i]]end' ''
637 comby -matcher .rb ':[[h]].each do |:[[j]]|:[[i]]end' ''
638 comby ':[[h]].each do |:[[j]]|:[[i]]end' '' -matcher -rb
639 comby ':[[h]].each do |:[[j]]|:[[i]]end' '' -matcher .rb
640 comby ':[[h]].each do |:[[j]]|:[[i]]end' ''
641 comby ':[[h]].each do |:[[j]]|:[[i]]end' '' --matcher .rb
642 comby ':[[h]].each do |:[[j]]|:[[i]]end' '' -matcher .rb
643 comby ':[[h]].each do |:[[j]]|' '' -matcher .rb
@diasbruno
diasbruno / index.js
Created May 13, 2021 15:26
Deriving everything with reduce - Stack meeting at Snowman Labs
// Derivação de `map` com `reduce`.
> f = item => item + 2;
[Function: f]
> [1, 2, 3, 4].reduce((acc, item) => { acc.push(f(item)); return acc; }, []);
[ 3, 4, 5, 6 ]
> [1, 2, 3, 4].map(f);
[ 3, 4, 5, 6 ]
// Reduzindo com outros acumuladores.