Skip to content

Instantly share code, notes, and snippets.

View gboncoffee's full-sized avatar
💜

Gabriel G. de Brito (AKA 96) gboncoffee

💜
View GitHub Profile
@gboncoffee
gboncoffee / music-dl
Created July 6, 2024 13:56
Snippet for downloading mp3 with yt-dlp
#!/bin/sh
which yt-dlp
yt-dlp -i -x --audio-format mp3 $@
@gboncoffee
gboncoffee / gitconfig
Created July 6, 2024 13:55
The only two config files that matter
[user]
email = gabrielgbrito@icloud.com
name = Gabriel G. de Brito
[advice]
addEmptyPathspec = false
[init]
defaultBranch = main
[format]
pretty = oneline
[receive]
@gboncoffee
gboncoffee / edit.html
Created June 23, 2024 22:34
Example of a minimal wiki web app with only Go's standard library
<h1>Editing {{.Title}}</h1>
<form action="/save/{{.Title}}" method="POST">
<div><textarea name="body" rows="20" cols="80">{{printf "%s" .Body}}</textarea></div>
<div><input type="submit" value="Save"></div>
</form>
@gboncoffee
gboncoffee / mergeSortCuda.cu
Created June 16, 2024 18:41
Merge Sort running on Nvidia GPU via CUDA
#include <iostream>
void coutArray(float array[], int n) {
for (auto i = 0; i < n - 1; ++i) std::cout << array[i] << ", ";
std::cout << array[n - 1] << std::endl;
}
__global__ void gpuCopyArray(float dest[], float src[], int n) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
@gboncoffee
gboncoffee / saguisimdasm.exs
Created May 11, 2024 23:54
Assembler de Sagui Vetorial (Sagui em Bando)
#
# Montador ridiculamente simples para Assembly de Sagui Vetorial.
# Escreve arquivos no formato hex do Logisim Evolution.
# (Informações sobre a licença abaixo)
# (Licensing information below)
#
# DÚVIDAS:
#
# - Como eu uso essa desgraça?
#
@gboncoffee
gboncoffee / calc.exs
Created April 8, 2024 00:44
Reverse polish calculator in Elixir
defmodule Calc do
defp exec_op(_, "clear"), do: []
defp exec_op([fa | [fb | r]], token) do
case token do
"+" -> [fa + fb | r]
"-" -> [fa - fb | r]
"*" -> [fa * fb | r]
"/" -> [fa / fb | r]
"swap" -> [fb | [fa | r]]
end
@gboncoffee
gboncoffee / calc.erl
Created April 7, 2024 20:38
Reverse polish calculator in Erlang
-module(calc).
-export([main_loop/1]).
read_tokens() ->
case io:get_line("calc> ") of
[] -> [];
L -> string:tokens(lists:droplast(L), " ")
end.
exec_token(S, T) ->
@gboncoffee
gboncoffee / rule110.odin
Created April 4, 2024 03:26
Rule 110 in Odin
package main
import "core:fmt"
import "core:os"
import "core:strconv"
import "core:strings"
panic_read :: proc() {
fmt.eprintln("cannot read from stdin")
os.exit(1)
@gboncoffee
gboncoffee / drw.h
Created March 10, 2024 17:06
Header-only distribution of drw.c and drw.h
#ifndef __DRW_INCLUDED
#define __DRW_INCLUDED
/*
* drw.h - Header-only library for easy X11 text-oriented graphics.
*/
/*
* Copyright (C) 2023 Gabriel de Brito
*
@gboncoffee
gboncoffee / goserve.go
Created December 17, 2023 03:09
The simplest static web server in Go
package main
import "net/http"
func main() {
port := ":6969"
handler := http.FileServer(http.Dir("."))
http.ListenAndServe(port, handler)
}