Skip to content

Instantly share code, notes, and snippets.

View Stupremee's full-sized avatar
🐳
rusty things

Justus K Stupremee

🐳
rusty things
View GitHub Profile

Keybase proof

I hereby claim:

  • I am Stupremee on github.
  • I am stupremee (https://keybase.io/stupremee) on keybase.
  • I have a public key whose fingerprint is 5AB7 076A F80B 4337 FB20 968C D54A 1CD5 1376 F46C

To claim this, I am signing this object:

@Stupremee
Stupremee / Makefile
Last active November 15, 2020 19:00
C Makefile template
CC := cc
CCFLAGS := -fdiagnostics-color=always -Wall -Werror -Wextra
CCOBJFLAGS := $(CCFLAGS) -c
BIN_PATH := bin
OBJ_PATH := obj
SRC_PATH := src
TARGET_NAME := chat
TARGET := $(BIN_PATH)/$(TARGET_NAME)
@Stupremee
Stupremee / list.c
Created October 26, 2020 20:19
List implementation in C
#include "testlib.h"
#include <stdlib.h>
#include <stddef.h>
#include <inttypes.h>
typedef struct vec {
void **data;
uint32_t len;
uint32_t cap;
} vec;
@Stupremee
Stupremee / crab.rs
Created August 5, 2020 07:31
Track thread spawning using ptrace syscall and Rust
// The source code for `/tmp/crab` which is used to test the code.
use std::thread;
use std::time::Duration;
fn main() {
let t1 = thread::spawn(|| {
println!("[1] Thread started working");
thread::sleep(Durtaion::from_millis(5000));
println!("[1] Thread finished working");
};
@Stupremee
Stupremee / GrandPanda-Talk.md
Created March 30, 2019 20:58
A "talk" from GrandPanda

@Dannie well yes but actually no. The problem is still that when the body of a lambda is executed, a stack frame is allocated. The point of trampoling is to not do that essentially you have some run method of Trampoline which is iterative or tail recursive and by suspending all of your functions in that Trampoline type (rather than executing them in place), you can make the execution of the original function only take one stack frame it's all very roundabout and actaully something I didnt really think about is that you can manually write run to be iterative, not relying on there being tail call optimization. That means it's possible in java as well @tterrag

yeah here we go

interface Trampoline<T> {
    default T run() {
@Stupremee
Stupremee / QuickSort.java
Created February 19, 2019 16:11
Generic QuickSort Java
import java.util.Arrays;
public class QuickSort {
public int[] sort(int[] array) {
return Arrays.stream(sort(Arrays.stream(array).boxed().toArray(Integer[]::new)))
.mapToInt(Integer::intValue)
.toArray();
}