Skip to content

Instantly share code, notes, and snippets.

View thomasweitzel's full-sized avatar

Thomas Weitzel thomasweitzel

View GitHub Profile
@thomasweitzel
thomasweitzel / aoc_2022_day_12.rs
Created December 12, 2022 16:30
Advent of Code 2022, my solution for day 12
// See: https://adventofcode.com/2022/day/12
use std::collections::VecDeque;
#[derive(Debug, Copy, Clone)]
struct Point {
character: char,
elevation: usize,
distance: Option<usize>,
}
@thomasweitzel
thomasweitzel / aoc_2022_day_10.rs
Created December 10, 2022 21:01
Advent of Code 2022, my solution for day 10
// See: https://adventofcode.com/2022/day/10
#[derive(Debug, Copy, Clone)]
enum Cmd {
Noop,
Addx(isize),
}
#[derive(Debug, Copy, Clone)]
struct State {
@thomasweitzel
thomasweitzel / aoc_2022_day_08.rs
Created December 8, 2022 21:52
Advent of Code 2022, my solution for day 08
// See: https://adventofcode.com/2022/day/8
fn parse(input: &str) -> Vec<Vec<u32>> {
input
.lines()
.map(|line| {
line.chars().map(|c| c.to_digit(10).expect("NaN")).collect()
})
.collect()
}
@thomasweitzel
thomasweitzel / visibility-of-a-mastodon-toot.puml
Last active November 23, 2022 12:22
PlantUML activity diagram for visibility of a Mastodon toot
@startuml
<style>
diamond {
BackgroundColor #palegreen
LineColor #green
LineThickness 2.5
}
</style>
!$START = "Public toot by @name"
@thomasweitzel
thomasweitzel / kvdienstplan-sniper.sh
Created April 28, 2022 13:34
Script to book a shift as soon as booking opens. Parameters need to be exact matches. No error handling.
#!/bin/bash
# Copyright 2022 Thomas Weitzel
# This script has some dependencies:
# - needs bash compatible shell (https://www.gnu.org/software/bash/)
# - curl (https://curl.se/)
# - ripgrep (https://github.com/BurntSushi/ripgrep/)
# Install these tools before using it
# Login form parameters (example)
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Game of Fifteen</title>
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@^2.0/dist/tailwind.min.css">
</head>
<body class="m-4 bg-gray-100 antialiased">
<div id="board">

How to use Vue.js in a Tailwind CSS styled Hugo blog post

Since I don't want to include the Vue.js JavaScript code in every page, I control it with a parameter in the post's frontmatter.

---
vue: 2
---
@thomasweitzel
thomasweitzel / AkkaExample.kt
Last active January 8, 2018 19:52
Simple Kotlin Akka example (local and remote)
import akka.actor.AbstractActor
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
class Worker : AbstractActor() {
override fun createReceive(): Receive? {
return receiveBuilder()
@thomasweitzel
thomasweitzel / ObservableExample.kt
Created November 11, 2017 20:09
Simple example of how to implement the Observable pattern in Kotlin with kotlin.properties.Delegates and Delegates.observable
import kotlin.properties.Delegates
interface Publisher {
fun onNews(news: String)
}
class RadioChannel : Publisher {
override fun onNews(news: String) = println("Heard on radio: $news")
}
@thomasweitzel
thomasweitzel / Mavibot.kt
Created June 8, 2017 12:06
Simple Kotlin example of working with B-Trees with Apache Mavibot [btree, kotlin, mavibot]
import org.apache.directory.mavibot.btree.*
import org.apache.directory.mavibot.btree.exception.KeyNotFoundException
import org.apache.directory.mavibot.btree.serializer.*
import java.util.*
fun main(args: Array<String>) {
btreeExample()
}
/**