Skip to content

Instantly share code, notes, and snippets.

View iK4tsu's full-sized avatar
👀
Trapped at home

João Lourenço iK4tsu

👀
Trapped at home
  • Siemens Mobility
  • Portugal
View GitHub Profile
@iK4tsu
iK4tsu / app.d
Last active September 23, 2023 14:02
Run-time generics in D
module app;
pure @nogc unittest
{
/// API
extern(C++)
interface IAllocatorNogc
{
extern(D):
void* alloc(size_t) pure @nogc;
module setmem;
version(unittest)
{
import std.range : repeat;
import std.algorithm : equal;
}
version (LDC)
{
@iK4tsu
iK4tsu / app.d
Last active February 26, 2024 19:03
LLVM-C 'Hello World' using D Programming Language
module app;
import llvm;
int main()
{
// module preparation
LLVMModuleRef mod = LLVMModuleCreateWithName("main".ptr);
// build a main function
@iK4tsu
iK4tsu / main.rs
Created May 5, 2021 17:57
Simple arithmetic parser and interpreter
#[derive(Debug, Clone)]
enum Token {
PRODUCT,
SUM,
NUMBER(i64),
}
#[derive(Debug, Clone)]
struct Node {
pub children: Vec<Node>,
@iK4tsu
iK4tsu / result.d
Last active May 1, 2021 22:21
Rust Result type implemented in D
module result;
import std.algorithm : cumulativeFold, each, map, sum;
import std.conv : to;
import std.exception : assumeWontThrow;
import std.range : chain, enumerate, iota, only, take, walkLength, zip;
import std.traits : isInstanceOf, ReturnType, Unqual;
import core.memory : pureMalloc;
@iK4tsu
iK4tsu / main.c
Last active October 8, 2020 11:37
Koch snowflake algorithm implementation in C
#include <stdio.h>
#include <math.h>
#define WINDOW_SIZE 500
#define SHIFT_X (0.075 * WINDOW_SIZE)
#define SHIFT_Y (0.25 * WINDOW_SIZE)
#define LINE_LENGTH (WINDOW_SIZE - 0.15 * WINDOW_SIZE)