Skip to content

Instantly share code, notes, and snippets.

View gboncoffee's full-sized avatar
💜

Gabriel de Brito gboncoffee

💜
View GitHub Profile
@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)
}
@gboncoffee
gboncoffee / html.h
Last active December 6, 2023 03:05
Macros to generate HTML with the C preprocessor
#ifndef __HTML_MACROS
#define __HTML_MACROS
#define HTML(l, head, body) <!DOCTYPE html> \
<html lang=#l> \
head \
body \
</html>
#define HEAD(...) <head> \
@gboncoffee
gboncoffee / queens.lua
Created November 30, 2023 21:13
8 queens problem solution in Lua
#!/usr/bin/env lua
--
-- Copyright (c) 2023 Gabriel G. de Brito
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
@gboncoffee
gboncoffee / knights.lua
Created November 18, 2023 12:38
Knight Tour problem in Lua
#!/usr/bin/env lua
--
-- Copyright (c) 2023 Gabriel G. de Brito
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
@gboncoffee
gboncoffee / battery-monitor.lua
Created October 29, 2023 23:07
Lua script to monitor the battery status
#!/usr/bin/env lua
--
-- System battery notifier ;)
--
sleep = function(sec)
os.execute("sleep " .. sec)
end
@gboncoffee
gboncoffee / kakrc
Last active September 29, 2023 12:49
Kakoune configuration
set-option global indentwidth 0
set-option global scrolloff 10,10
set-option -remove global autocomplete prompt|insert
set-option -add global ui_options terminal_assistant=none
set-option -add global ui_options terminal_enable_mouse=true
set-option global makecmd ''
# hooks
hook global WinCreate ^[^*]+$ %{editorconfig-load}
hook global BufCreate .+\.lua %{
@gboncoffee
gboncoffee / cybercafe-soft.kak
Created September 26, 2023 01:25
Cybercafe theme for Kakoune
# Cybercafe (Soft) theme for Kakoune by Gabriel de Brito
#
# Copyright (C) 2023 Gabriel de Brito
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@gboncoffee
gboncoffee / ll.c
Created September 22, 2023 00:37
Inverting a Linked List in linear time
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct LL {
int d;
struct LL *r;
} LL;
LL *cons(int d, LL *r)