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 / rule110.go
Last active August 5, 2023 03:59
Rule 110 in Go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
// Copyright (C) 2023 Gabriel de Brito
@gboncoffee
gboncoffee / rule110.ml
Last active August 5, 2023 03:59
Rule 110 in OCaml
open List;;
(*
* 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
@gboncoffee
gboncoffee / uwufiew.c
Last active August 14, 2023 13:04
UwUfiew algorithm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*
* uwufiew, weceives inpuwut fwom standawt inpuwut ow fiwes and concatenates a
* uwufiewd vewsion to the standawt ouwutpuwut.
*
* fwee softwawe, wincesed uwundew the MIT wicense, youwu shouwuwd have
* weceived a copy of the wicense awong with the pwogwam.
@gboncoffee
gboncoffee / main.c
Created August 7, 2023 15:03
Example of crazy use of multiple calls to main() and cli args.
/*
* Maybe this should be illegal? This is a program that RETURNS the factorial of
* the number of cli args it receives, by recursivelly calling main.
*
* License: The Unlicense License
* Original author: Gabriel G. de Brito
*/
int main(int argc, char *argv[])
{
@gboncoffee
gboncoffee / rule110.clj
Last active August 31, 2023 01:08
Rule 110 in Clojure
(ns testapp.core
(:gen-class))
(defn rule110 [a b c]
(case [a b c]
[1 1 1] 0
[1 1 0] 1
[1 0 1] 1
[1 0 0] 0
[0 1 1] 1
@gboncoffee
gboncoffee / load-example.lua
Last active September 9, 2023 04:41
Example of evaluating untrusted code in Lua
local oldprint = print
print = function(a)
oldprint("load print: " .. a)
end
a = 1
local f = load "print(a)"
f() -- this will print 'load print: 1'
@gboncoffee
gboncoffee / rand.c
Created September 11, 2023 00:00
TCC script to generate random numbers.
#!/usr/bin/env -S tcc -run
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
/*
* Copyright (C) 2023 Gabriel de Brito
*
@gboncoffee
gboncoffee / stupid_sorting.c
Last active September 12, 2023 12:36
Collection of stupid sorting algorithms.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#define printarr(v, n) { \
for (int i = 0; i < n - 1; i++) \
printf("%d ", v[i]); \
printf("%d\n", v[n - 1]); \
@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)
@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: