Skip to content

Instantly share code, notes, and snippets.

View girorme's full-sized avatar
😀

girorme girorme

😀
View GitHub Profile
@girorme
girorme / wsl-dns-commands.md
Last active January 26, 2024 20:03
wsl dns resolutions errors

DNS resolution

option 1

  • Execute the command below
$ sudo sed -i '/nameserver/d' /etc/resolv.conf
$ powershell.exe -Command '(Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses | ForEach-Object { "nameserver $_" }' | tr -d '\r' | sudo tee -a /etc/resolv.conf > /dev/null
@girorme
girorme / k8s-using-kind.md
Created October 17, 2023 16:36
k8s via kind (wsl2)
@girorme
girorme / docker-compose.yml
Last active August 6, 2023 04:52
Postgres docker compose
version: "3.4"
volumes:
my_postgres:
services:
postgres:
container_name: my_postgres
image: postgres:12.0-alpine
restart: always
environment:
- POSTGRES_USER=postgres
@girorme
girorme / magic_number.ex
Last active July 15, 2023 06:18
Extract binary magic number (first 4 bytes) - https://en.wikipedia.org/wiki/List_of_file_signatures
defmodule MagicNumber do
def extract_magic_number(<<byte :: size(32), _rest :: binary>>) do
Integer.to_string(byte, 16)
|> String.split(~r/.{2}/, include_captures: true, trim: true)
|> Enum.map(fn n -> "0x#{n}" end)
end
end
# Usage:
content = File.read!(path)
@girorme
girorme / read-mails-elixir.ex
Last active March 3, 2023 17:32
Read emails imap
defmodule ImapExample do
def mark_unread_emails_as_read(server, username, password) do
{:ok, conn} = ExImap.connect(server: server, ssl: true)
{:ok, _} = ExImap.authenticate(conn, username: username, password: password)
{:ok, _} = ExImap.select(conn, "INBOX")
{:ok, messages} = ExImap.search(conn, "UNSEEN")
Enum.each(messages, fn msg_id ->
{:ok, _} = ExImap.store(conn, msg_id, "+FLAGS", "\\Seen")
end)
@girorme
girorme / solution.ex
Last active May 16, 2022 20:54
tdd livebook
defmodule Solution do
def remove_duplicate_chars(string) do
string
|> String.codepoints()
|> Enum.reduce(fn char, acc ->
acc = if String.contains?(acc, char) do
acc
else
acc <> char
end
<?php
interface Entity {
}
class Book implements Entity {
}
// REPO
interface Repository {
@girorme
girorme / worker-pool.go
Last active February 28, 2024 23:19
worker pool using go channels + waitGroup
package main
import (
"flag"
"fmt"
"net/http"
"sync"
"threadsync/httpclient"
"time"
)
@girorme
girorme / perguntas-entrevistador.md
Created October 1, 2020 14:59
Perguntas para fazer em uma entrevista - Créditos: Gabs Ferreira

Qual será o meu trabalho no dia a dia?

Saber em que projeto você irá trabalhar e como será sua rotina de trabalho é essencial.

Como os times são organizados?

Quantos devs tem no time? Quantos líderes?

Qual a stack de tecnologias utilizadas na empresa?

@girorme
girorme / connect.sh
Last active April 8, 2020 23:12
otp authentication openfortivpn
# --trusted-cert value is prompted in the first on debug output while connection try
sudo /usr/bin/openfortivpn ip:port -u user --trusted-cert 9f069d6b9e248de3a7521981ef06377b296574fa5825cde10b7349da62939c80 --otp-prompt=1 --no-dns