Skip to content

Instantly share code, notes, and snippets.

View tralamazza's full-sized avatar

Daniel Tralamazza tralamazza

View GitHub Profile
//
// Copyright (c) 2022 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
//
// Usage
// #![feature(specialization)]
// #![allow(incomplete_features)]
#include <optional>
// unit/return
static constexpr auto some = [](auto x) { return std::make_optional(x); };
// >>= bind
template <typename T, typename F>
static constexpr std::optional<T> operator>>=(std::optional<T> input, F&& func) {
if (input) {
return func(*input);
@tralamazza
tralamazza / peano.rs
Last active January 25, 2022 11:29
Peano in (ugly) Rust
#![allow(unused)]
use std::ops;
/*
This example serves no purpose, it implements peano arithmetic both as types and values.
It's an excuse to overload the + operator.
*/
#[derive(Debug, Default, Clone, Copy)]
struct Zero;
@tralamazza
tralamazza / Makefile
Created March 2, 2019 13:13
simple way to compile ragel examples (one source per executable)
RAGELFILES:= $(wildcard *.rl)
EXECUTABLES:= $(patsubst %.rl, %, $(RAGELFILES))
LDFLAGS+= -lstdc++
%.cc : %.rl
ragel -G2 -C -o $@ $<
all: $(EXECUTABLES)
clean:
java -jar $HOME/tools/smc_7_0_0/bin/Smc.jar "$@"
@tralamazza
tralamazza / thinkpad_X230_post_install.md
Last active March 22, 2019 13:31
Fedora (29) post install

add the following 2 lines to /etc/dnf/dnf.conf

fastestmirror=True
deltarpm=True

vscode

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

tlp kernel modules

sudo dnf install http://repo.linrunner.de/fedora/tlp/repos/releases/tlp-release.fc$(rpm -E %fedora).noarch.rpm

FSM := source? start_state class_name header_file? include_file*
package_name* import* declare* access* map+
source := '%{' raw_code '%}'
start_state := '%start' word
class_name := '%class' word
header_file := '%header' raw_code_line
sudo ln -s `which python3` /usr/local/bin/python
@tralamazza
tralamazza / cemu.md
Last active February 7, 2018 22:29
CEMU install
@tralamazza
tralamazza / Dockerfile
Last active February 16, 2018 22:35
embedded dev container
FROM base/devel
ENV XTENSA_TOOLCHAIN xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0
# init
RUN pacman -Suy --noconfirm
RUN pacman-key --init && \
update-ca-trust && \
pacman-db-upgrade