Skip to content

Instantly share code, notes, and snippets.

View s-macke's full-sized avatar

Sebastian Macke s-macke

View GitHub Profile
@lbruder
lbruder / lbForth.c
Created April 6, 2014 15:21
A minimal Forth compiler in ANSI C
/*******************************************************************************
*
* A minimal Forth compiler in C
* By Leif Bruder <leifbruder@gmail.com> http://defineanswer42.wordpress.com
* Release 2014-04-04
*
* Based on Richard W.M. Jones' excellent Jonesforth sources/tutorial
*
* PUBLIC DOMAIN
*
@jgilchrist
jgilchrist / einstein.pl
Last active December 10, 2022 20:33
A Prolog solution to Einstein's Riddle
right_of(X, Y) :- X is Y+1.
left_of(X, Y) :- right_of(Y, X).
next_to(X, Y) :- right_of(X, Y).
next_to(X, Y) :- left_of(X, Y).
solution(Street, FishOwner) :-
Street = [
house(1, Nationality1, Color1, Pet1, Drinks1, Smokes1),
house(2, Nationality2, Color2, Pet2, Drinks2, Smokes2),
@f3l1x
f3l1x / aliases
Last active January 29, 2024 19:21
Docker - installation, tips, commands, aliases
# ------------------------------------
# Docker alias and function
# ------------------------------------
# Get latest container ID
alias dl="docker ps -l -q"
# Get container process
alias dps="docker ps"
/**
* An approximate port of https://github.com/s-macke/VoxelSpace
* using static Groovy and JavaFX.
*
* Click on the panel to "fly".
*
* Run with : groovy voxel.groovy
*
* Twitter: @CedricChampeau
*/
/**
* An approximate port of https://github.com/s-macke/VoxelSpace
* using Kotlin and JavaFX.
*
* Run with : kotlinc -script voxel.kts
*
* Click on the panel to "fly".
*
* Twitter: @CedricChampeau
*/
use std::{
f32,
io
};
use minifb::{
Key,
WindowOptions,
Window,
};
use vek::*;
@s-macke
s-macke / hello.c
Last active August 28, 2023 06:30
Hello world example by using an headerless implementation of the WASI interface. The only dependency is clang
/*
* This code is a headerless implementation of the WASI interface in C and prints "Hello World!.
* You only need clang and the llvm linker.
*
* compile with
* clang -Os -nostdlib --target=wasm32 -Wl,--allow-undefined hello.c -o hello.wasm
*
* run with
* https://runno.dev/wasi
* Just upload hello.wasm
@s-macke
s-macke / main.go
Last active January 8, 2020 14:42
ASCIICinema: Show movie files on the console via "curl --compressed localhost:12345"
package main
import "C"
import (
"fmt"
"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avutil"
"github.com/giorgisio/goav/swscale"
"strconv"
"strings"
@s-macke
s-macke / http3.go
Last active April 6, 2022 21:12
QUIC HTTP/3 Parsing of the Initial Packet
/*
The HTTP/3 protocol is on the rise and brings huge improvements in terms of speed and security.
One of them is, that the so called "Server Name Identification" or SNI is mandatory and is sent
in the first packet by the client.
https://en.wikipedia.org/wiki/Server_Name_Indication
Parsing and retrieving the SNI should be easy, right?
Well, here is a complete code example to retrieve the SNI and other information from the
initial QUIC packet. The first packet is encrypted and protected. But the encryption keys
@s-macke
s-macke / contextperf.c
Last active May 9, 2022 19:40
The code measures the direct and indirect cost (L2 cache misses) of context switches
// compile with
// 'gcc -O2 main.c -o contextperf.c' -lpthread
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <sched.h>
#include <unistd.h>