Skip to content

Instantly share code, notes, and snippets.

@xentec
xentec / slight.fish
Last active September 21, 2023 11:15
Highlight syntax of input
#!/usr/bin/env fish
# Example: cat index.html | ./slight.fish html
# cat main.c | ./slight.fish c
set -l syntax $argv[1]
exec kate-syntax-highlighter /dev/stdin \
--syntax $syntax \
--output-format ansi256Colors \
@xentec
xentec / oth-mensa.nu
Last active August 23, 2023 10:20
CLI mensa plan for OTH Regensburg. Requires Nushell to run.
#!/usr/bin/env nu
let now = (date now)
let week = ($now | format date '%V' | str trim -l -c '0')
let url = $"https://www.stwno.de/infomax/daten-extern/csv/HS-R-tag/($week).csv"
(
http get --raw $url |
decode "iso-8859-1" |
str replace -a "\n(\n|(;|\\())" "$2" | # fix bullshit
@xentec
xentec / scr-lock.fish
Created October 21, 2021 17:12
Screen locking script for swaylock.
#!/usr/bin/env fish
# You need sway, swaylock, grim, imagemagick, jq and parallel.
set SCREEN (swaymsg -t get_outputs | jq -r .[].name)
for s in $SCREEN;
set -l img /tmp/lock-$s.jpg
set -a IMG $img
set -a PARAMS "-i $s:$img"
end
use reqwest;
use scraper::{Html, Selector};
use structopt::{self, StructOpt};
#[derive(StructOpt)]
#[structopt(name = "w0bm-sav0r")]
struct Opt
{
#[structopt()]
username: String,
#!/bin/env fish
set file_name_base (date "+%Y-%m-%d_%H-%M-%S")
#set url "http://example.com"
#set uploader "rsync"
#set uploader_target "server:/srv/http/"
if [ $WAYLAND_DISPLAY ];
set IS_WAYLAND 1
set SEL_CMD 'slurp' -d
@xentec
xentec / at-mock.ino
Created August 15, 2018 15:33
Arduino AT command mock
#ifndef __AVR_ATmega328P__
# define __AVR_ATmega328P__ // IDE helper
#endif
#include <Arduino.h>
struct cmd_pair
{
const char *query, *response, *err;
};
@xentec
xentec / range.hpp
Last active November 3, 2017 07:47
Slices, C++ style. Helper class to retain sanity
#pragma once
#include <iterator>
template<class Iter>
struct Range
{
using value_type = typename std::iterator_traits<Iter>::value_type;
Range(Iter b): b(b) {}
#!/bin/bash
# general dependencies:
# bash (to run this script)
# util-linux (for getopt)
# procps or procps-ng
# hostapd
# iproute2
# iw
# iwconfig (you only need this if 'iw' can not recognize your adapter)
#include <cstdint>
#include <fmt/format.h>
int main()
{
union {
uint32_t i;
uint8_t a[4];
struct { uint32_t lsb:6, m:20, msb:6; } b;
};
@xentec
xentec / enum.hpp
Last active October 4, 2017 07:02
#pragma once
#include <optional>
#include <map>
/*
#define <GENERATOR>(XX) \
XX(OK, 0) \
XX(ERROR, 1) \
XX(..., ...) \