Skip to content

Instantly share code, notes, and snippets.

Mara Bos m-ou-se

Block or report user

Report or block m-ou-se

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@m-ou-se
m-ou-se / floats.txt
Last active Nov 29, 2018
6-bit Floating point values
View floats.txt
The overview below shows all 6-bit floating point values using a sign bit, a 3-bit exponent and a 2-bit mantissa.
This should give you an idea of how floating point values work. The standard 32 bit and 64 bit floats
we all know are exactly the same, but just with more bits for both the exponent and mantissa.
S EEE MM
0 111 11 NaN
0 111 10 NaN
0 111 01 NaN
0 111 00 +Infinity
@m-ou-se
m-ou-se / Makefile
Created Aug 20, 2018
Makefile for CMake+Ninja
View Makefile
.PHONY: .always
all:
Makefile:
#
build/build.ninja:
mkdir -p build
cd build && CXX='clang++ -fdiagnostics-color' CC='clang -fdiagnostics-color' cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja
@m-ou-se
m-ou-se / CMakeLists.txt
Last active Aug 20, 2018
Automatically include git version in software.
View CMakeLists.txt
include_directories(${CMAKE_CURRENT_BINARY_DIR}/generated)
#...
add_custom_target(version
COMMAND ${CMAKE_COMMAND}
ARGS
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/generated/version.h
-P ${CMAKE_CURRENT_SOURCE_DIR}/gen-version.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@m-ou-se
m-ou-se / Makefile
Last active Sep 18, 2017
Automatically include git version in software.
View Makefile
ifeq (${VERBOSE},)
MAKEFLAGS += -s
endif
ifeq ($(OS),Windows_NT)
PY = py
else
PY =
endif
@m-ou-se
m-ou-se / instructions.txt
Created Sep 11, 2017
Compiling a cross compiler for armv7l-unknown-linux-gnueabihf (RPi3)
View instructions.txt
wget http://ftp.snt.utwente.nl/pub/software/gnu/binutils/binutils-2.29.tar.xz
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-7.2.0/gcc-7.2.0.tar.xz
wget http://ftp.gnu.org/gnu/glibc/glibc-2.26.tar.xz
tar xvf binutils-2.29.tar.xz
tar xvf gcc-7.2.0.tar.xz
cd binutils-2.29
./configure --target=armv7l-unknown-linux-gnueabihf --disable-multilib
make -j9
sudo make install
cd ..
@m-ou-se
m-ou-se / compositor.sh
Last active Aug 9, 2019
Translucent terminals. Works with any terminal emulator, as long as the background is black.
View compositor.sh
#!/bin/sh
# Runs compton with a shader that only applies the opacity property to black
# backgrounds, with small soft shadows around non-black parts to inprove
# readability.
exec compton --backend glx --vsync --glx-fshader-win '
uniform float opacity;
uniform sampler2D tex;
void main() {
@m-ou-se
m-ou-se / replace-debian-with-arch.txt
Last active Sep 13, 2019
Instructions to replace a live Debian installation with Arch
View replace-debian-with-arch.txt
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz'
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1
@m-ou-se
m-ou-se / ieee754.cpp
Created Sep 12, 2015
constexpr functions to encode and decode IEEE754 binary64 doubles.
View ieee754.cpp
#include <iostream>
#include <vector>
#include <cstdint>
constexpr double decode_double(std::uint64_t encoded) {
bool s = encoded >> 63;
std::int16_t e = encoded >> 52 & 0x7FF;
std::int64_t m = encoded & (1ULL << 52) - 1;
if (e == 2047) return m ? s ? 0/0.0 : -(0/0.0) : s ? -1/0.0 : 1/0.0;
double x = m | (e ? 1ULL << 52 : 0);
@m-ou-se
m-ou-se / font
Created Feb 18, 2015
Font for my whiteboard clock
View font
0
0 1.5
0 0.5
0.2 0.1
0.5 0
0.8 0.1
1 0.5
1 1.5
0.8 1.9
0.5 2
@m-ou-se
m-ou-se / clock.scad
Last active Dec 11, 2016
3D model for my whiteboard clock
View clock.scad
$fs=1;
$fa=1;
servo_l = 24;
servo_w = 13;
servo_h = 21;
bolt_hole_diameter = 4.5;
servo_axis_diameter = 4;
You can’t perform that action at this time.