Skip to content

Instantly share code, notes, and snippets.

View MM1212's full-sized avatar

Martim MM1212

  • 42 Lisboa
View GitHub Profile
@MM1212
MM1212 / nostdlink.md
Last active March 29, 2024 23:34
[42] check against system library calls usage to find forbidden functions
@MM1212
MM1212 / malloc.c
Created February 19, 2024 14:03
[C] Malloc with a russian roulette
#include <stdlib.h>
#include <time.h>
extern void *__real_malloc(size_t size);
void *__wrap_malloc(size_t size)
{
srand(time(NULL));
if (rand() % 5)
return NULL;
@MM1212
MM1212 / InheritClasses.ts
Created December 20, 2023 19:47
Inherit any number of classes with some type-safety
type GrabConstructorParameters<T> = {
[K in keyof T]: T[K] extends new (...args: infer P) => any ? P : never;
}
// https://stackoverflow.com/a/50375286
type UnionToIntersection<U> =
(U extends any ? (x: U)=>void : never) extends ((x: infer I)=>void) ? I : never
type JoinConstructors<T extends (new (...args:any[]) => any)[]> =
new (...args: GrabConstructorParameters<T>) => UnionToIntersection<InstanceType<T[number]>>
@MM1212
MM1212 / private_fork.md
Created January 13, 2022 10:16 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git