Skip to content

Instantly share code, notes, and snippets.

@Dietr1ch
Dietr1ch / .envrc
Last active December 24, 2022 01:14
Secret santa assignment
use_nix
@Dietr1ch
Dietr1ch / gc.c
Last active August 10, 2022 06:31
Baby’s First Garbage Collector - Sweep
void sweep(VM* vm) {
Object* object = vm->firstObject; // vm->firstObject might be a dangling pointer after this :/
while (object) {
if (!object->marked) {
/* This object wasn't reached, so remove it from the list
and free it. */
Object* unreached = object;
object = unreached->next;
free(unreached);
@Dietr1ch
Dietr1ch / starship.toml
Created November 6, 2020 16:17
Starship config
add_newline = true
format = "$jobs$battery$time$cmd_duration$line_break$username$hostname$directory$git_branch$git_commit$git_state$git_status$hg_branch$package$golang$haskell$python$ruby$rust$terraform$nix_shell$memory_usage$character\n\n"
[aws]
disabled = false
[character]
symbol = "❯\n"
[cmd_duration]
@Dietr1ch
Dietr1ch / fork.c
Last active August 29, 2015 14:27
IIC2333: 0 - forks
#include <stdio.h>
#include <unistd.h>
// Output posible para "./programName banner dame ramos"
/**
1234: Creando 3 subprocesos...
4444: ramos
5555: banner
6666: dame
1234: (=
#!/usr/bin/python
# monto: Cantidad de dinero que falta por juntar
# billetes: Es constante en la recursión. Define cuales son los billetes
# disponibles
# formas: Esta lista acompañará a toda la recursión, guardando las soluciones
# en caso de encontrarlas.
#
# forma_actual: Esta lista va a mantener los billetes que hemos usado hasta el
# momento. Describe las decisiones tomadas en árbol
@Dietr1ch
Dietr1ch / fImg.py
Last active August 29, 2015 14:13
Funciones como parámetros
# Probablemente encuentren que esto es algo extraño, pero
# luego se darán cuenta que permite expresar las ideas
# de manera muy clara y concisa.
# Usando funciones pueden lograr que su codigo separe la
# iteración sobre toda la imagen de lo que hay que hacer.
# Eso permite que escriban el loop que recorre la imagen una
# sola vez y que terminen simplificando el problema de cambiar
# toda la imagen por el de cambiar un solo pixel.
@Dietr1ch
Dietr1ch / stack-segfault.c
Created July 6, 2014 21:30
Small program to test how much memory was actually given. It crashes intentionally.
#include <stdio.h>
void fillArray(int* array){
int i=0;
while(1){
printf("Rewrote %d to %d\n", array[i], i);//This mem access should raise a SEGFAULT soon.
array[i] = i;
++i;
}
}
@Dietr1ch
Dietr1ch / cabeza_danae_tarea1.lp
Last active December 31, 2015 09:49
Versión corregida
color(C):- color(C,Y,X), fila(Y),columna(X).
casilla(C,Y,X):- color(C,Y,X).
vecinos(Y1,X1,Y2,X2):- 1{#abs(X1-X2)==1,#abs(Y1-Y2)==1}1, 1{#abs(X1-X2)==0,#abs(Y1-Y2)==0}1, fila(Y1;Y2), columna(X1;X2).
1{casilla(C,Y,X):color(C)}1:- fila(Y), columna(X).
1{camino(C,Y1,X1,Y2,X2):fila(Y2):columna(X2)}1:- color(C,Y1,X1), color(C), fila(Y1), columna(X1).