Skip to content

Instantly share code, notes, and snippets.

View honi's full-sized avatar

Joni Bekenstein honi

View GitHub Profile
@honi
honi / n_sum.s
Created November 10, 2023 12:47
Implementación recursiva en assembler RISC-V de una sumatoria
# n_sum(n) = sum_{i=0}^n i
# n_sum(n) = n + n_sum(n-1)
# n_sum(n) = n + n-1 + n_sum(n-2)
# n_sum(n) = n + n-1 + ... + 0
.text:
main:
# Por convención, en RISC-V el stack pointer (sp) apunta al dato que está
.text:
# Inicializamos t1 con la dirección donde están guardados los pixeles.
la t1, pixels
# Cantidad de pixels.
li t3, 5
# Inicializamos el valor máximo de rojo en 0.
li t4, 0
@honi
honi / Makefile
Created September 30, 2023 13:59
Makefile to compile cpp files in src/ as individual programs in bin/
CXX := g++
CXX_FLAGS := -pthread --std=c++2a
VPATH := bin/
SRCS := $(shell find src -name '*.cpp')
BINS := $(patsubst src/%.cpp,%,$(SRCS))
RUNS := $(addprefix run-,$(BINS))
all: $(BINS)
template<typename T>
vector<string> string_map<T>::keys() const {
vector<string> keys;
keys.reserve(_size);
_root->collectKeys("", &keys);
return keys;
}
template<typename T>
void string_map<T>::Node::collectKeys(const string& prefix, vector<string>* keys) {
@honi
honi / devrqworker.py
Last active February 1, 2022 15:57
RQ worker wrapper that autoreloads - use only during development
import os
import shlex
import subprocess
from django.core.management.base import BaseCommand
from django.utils import autoreload
class Command(BaseCommand):
def add_arguments(self, parser):
@honi
honi / watchless.py
Last active August 29, 2015 14:02
Hack for django-compressor to recompile less files when imported less files (not referenced in html) are changed. See: https://github.com/django-compressor/django-compressor/issues/226
import time
from subprocess import call
from os.path import join
from django.conf import settings
from django.core.management.base import BaseCommand
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler