Skip to content

Instantly share code, notes, and snippets.

View loreb's full-sized avatar

Lorenzo Beretta loreb

View GitHub Profile
@loreb
loreb / Spritz.sh
Created December 17, 2014 20:19
abomination: Spritz/RS14 in portable /bin/sh
#! /bin/sh
# "Spritz - a spongy RC4-like stream cipher and hash function"
# http://people.csail.mit.edu/rivest/pubs/RS14.bib.txt
# In case you're insane enough to use it, keep in mind that the registers
# (i,j,...) have NO PREFIX, so you'll have to add it(_spritz_i, ...).
# This script is meant to run on any POSIX shell with local variables
# ("local" is not included in POSIX. Idiots!) and POSIX commands (printf(1)).
# Bash,dash,mksh,zsh: see how fast they Absorb()/Drip() compared to vim...
@loreb
loreb / getarc4random
Created December 17, 2014 20:22
get arc4random*.c from libressl - quick hack
#! /bin/sh
# Self-contained - get arc4random for emergencies.
set -e # Not in "#!" to test different shells.
# TODO figure out the source files automagically?
test 0 -eq $(ls|wc -l) || { echo>&2 "run $0 in an empty directory"; exit 100; }
# Fix $OS if needed (eg "win")
if [ x = x"$OS" ] ; then
OS=$(uname -s)
@loreb
loreb / .Xresources
Created April 8, 2015 19:35
My *horrible* ~/.Xresources, (ab)using cpp to select themes and with every possible idea dumped in (and commented out); I'm switching to something saner (see line 75).
!!!!!!!!!!!!!!!!!!!!!!!!!!
! /etc/X11/app-defaults/ !
!!!!!!!!!!!!!!!!!!!!!!!!!!
xvt*background: #000000
xvt*foreground: #fefefe
yeahconsole*restart: 1
yeahconsole*toggleKey: Alt+y
@loreb
loreb / shuf.go
Created March 8, 2016 16:24
GNU shuf in go, out of boredom during a stupid accident
// A reimplementation of GNU shuf (think *BSD)
// -- there was a shuffle(1) ages ago, but it got deleted.
// GNU shuf goes out of its way to optimize anything it can
// -- just see its treatment of --random-source!
// this is *much* more simple minded - TLDR: use GNU shuf.
// Seriously, its inspiration comes from:
// 1. shuf on *BSD without installing coreutils;
// 2. my router abandoning me for >30 minutes.
package main
@loreb
loreb / manpage-compression-worth-it.sh
Created May 17, 2021 15:43
Script to check if it's worth it to compress man pages
#! /bin/sh
# https://paludis.exherbo.org/faq/misfunctionality.html#wgetresume
# true<<TIL => shellcheck usefully complains...
til() { : ; }
til<<TIL
No Automatic Documentation Compression
Non-Problem: Paludis doesn't compress documentation or man pages with gzip/bzip/whatever.
Rationale: The space savings on an average system are very small, to non-existent for most filesystems. Most documentation and man pages are only about one block in size, so compression won't gain you anything except for wasted CPU cycles.
@loreb
loreb / wtf.txt
Created August 25, 2021 19:01
prompt may be given but -n given
Just in case this happens to somebody else in the future, since search engines were not terribly helpful...
if you run "sudo -n (whatever)" and get back
error: prompt may be needed but -n given
... and search sudo's sources, and the message is not there...
try "type sudo", chances are you're using UserLAnd on Android and they have
nosudo installed as /usr/local/bin/sudo for some reason;
running /usr/bin/sudo does what you wanted.