Skip to content

Instantly share code, notes, and snippets.

(defun emacs-ime (&optional close-frame)
(interactive)
(let ((char (with-temp-buffer
(call-interactively 'insert-char)
(buffer-string))))
(when close-frame
(delete-frame))
(gui-set-selection 'CLIPBOARD char)
(start-process "xdotool"
"*emacs-ime*"
@jeeger
jeeger / main.rs
Created January 10, 2023 08:04
Print current kubernetes context or '?'
use anyhow::{Error, Result};
use std::env;
use std::fs::read_to_string;
use std::io::{stderr, stdout, Write};
use yaml_rust::YamlLoader;
fn kube_config_path() -> String {
let mut home = dirs::home_dir().expect("No home directory found");
home.extend(vec![".kube", "config"]);
env::var("KUBECONFIG").unwrap_or(
@jeeger
jeeger / get-input.clj
Created December 14, 2022 14:04
Get Advent of Code input in babashka.
#!/bin/env bb
(require '[babashka.fs :as fs])
(require '[babashka.curl :as curl])
(defn get-day-component []
(let [components (fs/components (fs/cwd))]
(-> (filter #(str/starts-with? % "day") components)
first)))
(defn get-day-number [day-name]
@jeeger
jeeger / bookstats.clj
Last active November 26, 2022 15:37
Sum up page counts of books from Calibre library with babashka
#!/usr/bin/env bb
(ns bookstats
(:require [babashka.pods :as pods]
[clojure.pprint :as pprint]))
(pods/load-pod 'org.babashka/go-sqlite3 "0.1.0")
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.babashka.go-sqlite3 :as sqlite]
'[pod.retrogradeorbit.hickory.select :as s]
'[pod.retrogradeorbit.bootleg.utils :as utils])
(import [java.net URLEncoder]
@jeeger
jeeger / burdapattern.sh
Created August 30, 2020 12:09
Tile Burda pattern
#!/bin/bash
NUPX="${1%%x*}"
NUPY="${1##*x}"
PAGESTART="${2%%-*}"
PAGEEND="${2##*-}"
FILE="$3"
# TODO: Check file and values.
PAGESIZES="$(pdfinfo -box -f "$PAGESTART" -l "$PAGEEND" "$FILE" | awk '/[0-9]+ size:/ {print $4 "x" $6}')"
PAGESIZEX="${PAGESIZES%%x*}"
@jeeger
jeeger / .zsh
Last active July 31, 2020 07:32
ZSH persistent directory aliases
if which sponge &>/dev/null; then
qjc() {
ALIAS="$1"
DIR="$(pwd)"
hash -d "$1"="$DIR"
echo "hash -d \"$1\"=\"$DIR\"" >> ~/.zsh/dirhashes
}
qjd() {
@jeeger
jeeger / engines.ipynb
Created July 11, 2019 09:19
Engine allocation with ILP
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeeger
jeeger / emacs-keys.ahk
Created December 6, 2018 14:32
Emacs keys for Firefox and some Office products (Word, Outlook, Powerpoint)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
markSet = 0
cxPrefix = 0
GroupAdd, EmacsControls, ahk_exe firefox.exe
GroupAdd, EmacsControls, ahk_exe WINWORD.EXE
@jeeger
jeeger / sh
Created July 13, 2018 12:10
SCP alias that warns on local copy
scp() {
totalcolons=$(echo "$*" | tr -cd ':' | wc -c)
if [[ totalcolons -lt 1 ]]; then
echo "Less than 1 colon in scp command."
else
/usr/bin/scp $@
fi
}
@jeeger
jeeger / AlternativeDoiResolver.js
Last active November 13, 2020 09:41
Custom DOI resolver (tested for Springerlink and ScienceDirect), compatible with TUM eaccess proxy.
// ==UserScript==
// @name AlternativeDoiResolver
// @version 1
// @grant GM.xmlHttpRequest
// @description Converts the pretty useless DOI links to clickable links ot a custom resolver.
// @include *sciencedirect*
// @include *springer*
// @include *ieeexplore*
// @include *acm.org*
// @require https://code.jquery.com/jquery-3.5.1.min.js