Skip to content

Instantly share code, notes, and snippets.

View LevitatingBusinessMan's full-sized avatar
🕴️
Ricing my polybar...

Rein Fernhout LevitatingBusinessMan

🕴️
Ricing my polybar...
View GitHub Profile
@LevitatingBusinessMan
LevitatingBusinessMan / wrap.fish
Created April 9, 2024 01:48
like rlwrap but in 10 lines of fish
#!/usr/bin/env fish
while true
read -P "" input
if test $status -ne 0
break
end
echo $input
end | $argv
@LevitatingBusinessMan
LevitatingBusinessMan / recipient_email.js
Last active March 23, 2024 01:39
Userscript to ensure that a recipients email address is shown when composing in roundcube
// ==UserScript==
// @name RecipientEmailFixerRoundcube
// @version 1
// @grant none
// ==/UserScript==
function on_mutation() {
document.querySelectorAll("body.action-compose li.recipient").forEach(recipient => {
if (!recipient.fixed) {
const [name, email] = recipient.children
#!/usr/bin/env fish
set packages (paclist core | cut -f1 -d' ')
set --erase IFS
set parallel 10
set mirror 'http:\/\/ftp.snt.utwente.nl\/pub\/os\/linux\/archlinux\/$repo\/os\/$arch'
# setup the config
set config (cat pacman.conf | sed \
-e "s/Include = \/etc\/pacman.d\/mirrorlist/Server = $mirror/" \
-e "s/\#ParallelDownloads = 5/ParallelDownloads = $parallel/"
@LevitatingBusinessMan
LevitatingBusinessMan / coroutine.c
Last active February 28, 2024 08:49
A totally sane implementation of a coroutine in C
#include <stdio.h>
#define COROUTINE static long ip = 0; if (ip) asm ("jmp *%0" : : "r" (ip + 7));
#define YIELD_32(i) asm volatile("movl %1, %%eax \n pop %%rbp \n call 1f\n 1: pop %0 \n ret" : "=m" (ip) : "r" (i));
int fibonacci() {
COROUTINE
YIELD_32(0);
YIELD_32(1);
YIELD_32(1);
@LevitatingBusinessMan
LevitatingBusinessMan / wallpapercycle.sh
Created October 23, 2023 21:12
Cycle through wallpapers
#!/bin/sh
file=`ls -dt ~/wallpapercycle/* | tail -n1`
touch $file
echo $file
feh --bg-tile $file
@LevitatingBusinessMan
LevitatingBusinessMan / subdomains.fish
Last active October 6, 2023 11:52
Bruteforce subdomains
#!/usr/bin/env fish
argparse n/nameserver= d/domain= w/wordlist= o/output= -- $argv
or exit
if test -z $_flag_n; or test -z $_flag_d; or test -z $_flag_w
echo "Required arguments: nameserver, domain, wordlist"
echo "You can find the nameserver with nslookup and querytype=soa"
exit
end
@LevitatingBusinessMan
LevitatingBusinessMan / tunnel.fish
Last active November 8, 2023 01:25
Reconfigure running wireguard interface to be used as a tunnel
#!/bin/fish
# Tunnel a wireguard interface
set dev $argv[1]
set peer $argv[2]
if test -z $dev
echo "No device specified"
exit
end
@LevitatingBusinessMan
LevitatingBusinessMan / hn-csv.rb
Created July 17, 2023 17:47
Hacker News one-liner scraper. Run with `ruby -rnet/http -rnokogiri hn.rb`
File.write 'hn.csv', Nokogiri(Net::HTTP.get(URI('https://news.ycombinator.com'))).css('.titleline > a', '.subline').each_slice(30).to_a.transpose.map {|a,l|[a.text, a.attr('href'), l.css('.score').first.text.chomp(' points').to_i, l.css('.hnuser').first.text, l.css('.age').first.attr('title')].to_csv}.join
require "httparty"
require "colorize"
# Possible values: ca1 usa10 usa11 usa13 usa14 uk3 uk5 germany4 germany5 germany6 france3
SERVER = "germany4"
PKGBUILD = File.read("PKGBUILD")
old_version = PKGBUILD.split(/\n/).find{|l| l.start_with? "pkgver="}.split("=").last
abort "Version detected as #{old_version.inspect.red} which does not match the format, quitting" if !/\d+\.\d+\.\d+/.match? old_version
#!/usr/bin/env ruby
FILENAME = ARGV[0]
abort "No filename given" if !FILENAME
clog = ""
STARTTIME = Time.now
File.write FILENAME, `date`, mode: 'a'