Skip to content

Instantly share code, notes, and snippets.

View musteresel's full-sized avatar

Daniel Jour musteresel

View GitHub Profile
@musteresel
musteresel / citites.cc
Created June 16, 2015 23:31
stackoverflow - cities and states
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <limits>
using std::string;
using std::vector;
using std::map;
@musteresel
musteresel / wip-autotools-export
Created August 25, 2016 18:45
WIP changes for autotoolizing CLISP
# HG changeset patch
# User Daniel Jour <[email protected]>
# 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 / Makefile
Created August 25, 2016 18:51
WIP libmagic module for CLISP
#CLISP_LINKKIT = $$($(CLISP) -b)/linkkit
srcdir = .
CC = gcc
CPPFLAGS =
CFLAGS = -Wall -O2
CLISP = clisp -q -norc
CLISP_LINKKIT = $(shell $(CLISP) -b)/linkkit
@musteresel
musteresel / enum-class-indent.el
Last active October 24, 2016 07:31 — forked from nschum/gist:2626303
better "enum class" indent in Emacs
;;; 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 / promote.h
Created March 14, 2017 21:16
Promote some value to an unsigned integer type
/*
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 / last-n.mk
Last active April 3, 2017 21:22
Get the last N items of a list with make
# Copyright 2017 Daniel Jour <[email protected]>
#
# 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 / Coop-Scheduler README
Last active August 24, 2024 21:27
Cooperative multitasking / green threads in C; MIT licence and let me know with a comment if you're using this
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 / decompress_lzf_file.py
Created March 15, 2021 17:02 — forked from dpanda/decompress_lzf_file.py
Using python-lzf module, decompress a whole LZF file
import argparse
import lzf
import os
import struct
def decompress(lzf_file, out_file):
chunk_number=1
while True:
@musteresel
musteresel / PySimpleGui-asyncio-tasks.py
Created March 15, 2021 23:44 — forked from ultrafunkamsterdam/PySimpleGui-asyncio-tasks.py
PySimpleGui Window loops as tasks in asyncio
import asyncio
import PySimpleGUI as sg
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
form = sg.FlexForm(
"Everything bagel", auto_size_text=True, default_element_size=(40, 1)
)