Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Jour musteresel

View GitHub Profile
@musteresel
musteresel / Coop-Scheduler README
Last active Sep 30, 2019
Cooperative multitasking / green threads in C; MIT licence and let me know with a comment if you're using this
View Coop-Scheduler README
How to build on an x86-64 linux system:
nasm -f elf64 hal.s
gcc -Wall -Wextra -c coop-sched.c
gcc -o tryit *.o
./tryit
There's still one bug, more in the comments of the source file(s)!
@musteresel
musteresel / last-n.mk
Last active Apr 3, 2017
Get the last N items of a list with make
View last-n.mk
# Copyright 2017 Daniel Jour <musteresel@gmail.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
@musteresel
musteresel / promote.h
Created Mar 14, 2017
Promote some value to an unsigned integer type
View promote.h
/*
uint32_t a = (...);
uint32_t b = a << 31;
When uint32_t is defined as a short type, then both operands of the
shift will get promoted to int. Thus above code is then equivalent to:
unsigned short a = (...);
unsigned short b = (unsigned short)((int)a << 31);
@musteresel
musteresel / enum-class-indent.el
Last active Oct 24, 2016 — forked from nschum/gist:2626303
better "enum class" indent in Emacs
View enum-class-indent.el
;;; enum-class-indent.el --- Fixing enum class indentation -*- lexical-binding: t; -*-
;; Keywords: c++
;; Version: 0.0.1
;;; Commentary:
;; This hack fixes indentation for C++11's "enum class" in Emacs.
;; http://stackoverflow.com/questions/6497374/emacs-cc-mode-indentation-problem-with-c0x-enum-class/6550361#6550361
@musteresel
musteresel / Makefile
Created Aug 25, 2016
WIP libmagic module for CLISP
View Makefile
#CLISP_LINKKIT = $$($(CLISP) -b)/linkkit
srcdir = .
CC = gcc
CPPFLAGS =
CFLAGS = -Wall -O2
CLISP = clisp -q -norc
CLISP_LINKKIT = $(shell $(CLISP) -b)/linkkit
@musteresel
musteresel / wip-autotools-export
Created Aug 25, 2016
WIP changes for autotoolizing CLISP
View wip-autotools-export
# HG changeset patch
# User Daniel Jour <daniel.oertwig@gmail.com>
# Date 1472150146 -7200
# Thu Aug 25 20:35:46 2016 +0200
# Node ID 62249532accb9fb9f7df2687cb86532193d953e0
# Parent f51a5bd170dcff8977bfb55af7f1e39a6d5a3d2f
WIP: autotoolizing the build system and configuration
diff -r f51a5bd170dc -r 62249532accb Makefile.am
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
@musteresel
musteresel / citites.cc
Created Jun 16, 2015
stackoverflow - cities and states
View citites.cc
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <limits>
using std::string;
using std::vector;
using std::map;
You can’t perform that action at this time.