Skip to content

Instantly share code, notes, and snippets.

View DanielAugusto191's full-sized avatar
💭
Yep

Daniel DanielAugusto191

💭
Yep
View GitHub Profile
@DanielAugusto191
DanielAugusto191 / main.ml
Created September 6, 2024 21:02
Graphs and a DFS in OCaml
type 'a graph =
| Empty
| G of {
la: 'a list list;
size: int
}
let init_graph = Empty
let add_node = function
| Empty -> G {la = [[]]; size=1}
@DanielAugusto191
DanielAugusto191 / main.ml
Created September 6, 2024 18:08
binary search tree
(* open Fmt *)
type 'a bst =
| Empty
| Node of {
left : 'a bst;
value : 'a;
right: 'a bst;
}
[@@deriving show]
@DanielAugusto191
DanielAugusto191 / conn.ml
Created August 21, 2024 20:24
mysql connection Ocaml
open Mysql
let () =
let db =
quick_connect ~host:"localhost" ~user:"root" ~password:"{password}"
~database:"{database_name}" ()
in
let result = exec db "SELECT id, name FROM {table_name} LIMIT 5;" in
(* (λx.x)a→a *)
(* (λx.λy.x)ab→(λy.a)b→a *)
(* (λx.xx)a→aa *)
(* (λx.λy.xy)a→λy.ay *)
datatype Term
= Var of string
| Abs of string*Term
| App of Term*Term
@DanielAugusto191
DanielAugusto191 / ifgates.cpp
Last active May 31, 2024 12:22
Bitwise Rock-Paper-Scissor
#include <cstdint>
#include <iostream>
#include <bitset>
using namespace std;
void use_bitset(void){
bitset<3> p1b{"001"}; // Player 1 Hand
bitset<3> p2b{"010"}; // Player 2 Hand
bitset<9> game;
@DanielAugusto191
DanielAugusto191 / mine_click.sh
Created May 15, 2024 08:46
Use scroll lock as auto clicker
#!/bin/bash
while true; do
scroll_lock=$(xset q | grep "Scroll Lock:" | awk '{print $NF}')
echo $scroll_lock
if [ "$scroll_lock" == "on" ]; then
xdotool mousedown 1
else
xdotool mouseup 1
fi
@DanielAugusto191
DanielAugusto191 / ConwayGameOfLifeMinecraft.md
Last active November 8, 2023 23:12
Conway's Game of Life on Minecraft in lua with ComputerCraft

My implementation of conways game of life on minecraft

Made with Computer Craft Mod, with allows write lua scripts in minecraft.

A

#SSA

Definição

SSA - É uma propriedade de IR, em que cada variavel é atribuida apenas uma vez, pro exemplo: y := 1 y := 2 x := y Será representada como:

@DanielAugusto191
DanielAugusto191 / Value Numbering.md
Created November 8, 2023 22:28
Value Numbering.md

Value Numbering é uma tecnica para determinas se duas computações no programa são equivalentes e eliminar uma delas, preservando a semantica do programa.

Global Value Numbering (GVN)

GVN é uma tecnica de otimização de compiladores basiado na IR SSA. Global porque o mapeamento é feito entre basic blocks boundaries também. Funciona atribuindo valores numericos para variaveis e expressões, e o mesmo valor é atribuido para variaveis e expressoes equivalentes. Por exemplo:

:= 3:= 3
@DanielAugusto191
DanielAugusto191 / Graphs.md
Created November 8, 2023 22:18
Graphs.md

A set of vertices and edges. It can be represented like an adjacent list.

	const int N = 5;
	vector<int> G[N];
	int vis[N];

DFS