Skip to content

Instantly share code, notes, and snippets.

View crater2150's full-sized avatar

Alexander Gehrke crater2150

  • Informatik VI, Universität Würzburg
  • Germany
View GitHub Profile
@crater2150
crater2150 / init.vim
Created October 13, 2021 21:37
minimal config for bug repro
call plug#begin(expand('<sfile>:p:h') . '/plugged')
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/nvim-cmp'
Plug 'nvim-lua/plenary.nvim'
Plug 'scalameta/nvim-metals'
" For vsnip user.
Plug 'hrsh7th/cmp-vsnip'
@crater2150
crater2150 / rotate.scala
Created March 12, 2020 14:05
find words with same rotation
def normalize(s: String) = (s + s).sliding(s.length).max
val words = scala.io.Source.fromFile("enable1.txt").getLines.toVector
val groupOfFour = words.toList.groupBy(normalize).filter(_._2.length == 4)
println(groupOfFour)
@crater2150
crater2150 / progress.zsh
Last active March 12, 2020 13:18
zsh: run operations on files while showing progress
files=(*.foo)
for i in {1..$#files}; do
file=$files[$i]
pad=${#${#files}}
printf "\e[2K\e[G ‣ %${pad}d / %${pad}d: %s" $i $#files $file
{
# do stuff with file here
} &>/dev/null
done
echo
@crater2150
crater2150 / handy.lua
Created February 26, 2020 16:04
Bug reproduction config for AwesomeWM
-- handy.lua - awesome module for popup clients
--
-- Usage:
-- handy = require("handy")
-- handy("console", "urxvt",
--
local awful = require("awful")
local inspect = inspect
local handy = {}
@crater2150
crater2150 / iceportal.zsh
Created August 26, 2019 18:24
Simple command line tool to show timetable of the ICE you're sitting in
#!/bin/zsh
tt_data=$(curl -s https://iceportal.de/api1/rs/tripInfo/trip)
if ! head -n 3 <<<"$tt_data" | grep -q '{'; then
echo "Invalid API response. Are you on the ICE Wifi?"
exit 1
fi
tt_data=$(
@crater2150
crater2150 / iceportal.zsh
Created August 26, 2019 18:23
Simple command line tool to show timetable of the ICE you're sitting in
#!/bin/zsh
tt_data=$(curl -s https://iceportal.de/api1/rs/tripInfo/trip)
if ! head -n 3 <<<"$tt_data" | grep -q '{'; then
echo "Invalid API response. Are you on the ICE Wifi?"
exit 1
fi
tt_data=$(
package model.attributes
import monocle.Iso
import monocle.macros.GenIso
final case class Stamina(value: Int) extends AnyVal
final case class Sanity(value: Int) extends AnyVal
final case class Speed(value: Int) extends AnyVal
final case class Sneak(value: Int) extends AnyVal
@crater2150
crater2150 / xbps-worldfile
Created January 11, 2018 09:34
Gentoo-like "world file" interface for xbps
#!/bin/zsh
zparseopts -D -E h=help -help=help d=desc -describe=desc
function not-in-left() {
awk 'NR==FNR{a[$0]=1;next}!a[$0]' "$@"
}
function first-col() {
cut -d$'\t' -f1
trait Element[+R]
class NullElement[+R] extends Element[R]
trait BugRepro {
def combineElements(actions: Element[_]*): Element[Unit]
def sequence[R, M[+_] <: TraversableOnce[_]](in: M[Element[R]]): Element[M[R]]
val mySeq = Seq(1,2,3)
@crater2150
crater2150 / accept-and-infer-ext.zsh
Last active December 8, 2016 10:51
accept and infer for people forgetting to use it before pressing enter
# if there is currently something typed, accept-and-infer-next-history like usual
# if the input line is empty, recall the last command and infer based on that
# needs deduplication of history disabled! (unsetopt HIST_SAVE_NO_DUPS HIST_IGNORE_ALL_DUPS)
local function accept-or-recall-then-infer-history() {
if [[ -z $PREBUFFER$BUFFER ]]; then
zle up-line-or-history
zle infer-next-history
else
zle accept-and-infer-next-history -- "$@"
fi