Skip to content

Instantly share code, notes, and snippets.

@lmas
lmas / icmp_ping.go
Last active April 18, 2024 11:45
Simple utility package to send ICMP pings with Go
// Copyright © 2016 Alex
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
@lmas
lmas / rerun.go
Last active April 3, 2024 18:47
Rerun - Run a command, watch for file changes in a directory and then rerun the command again
// Copyright © 2021 Alex
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU Affero General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
@lmas
lmas / crt.css
Created March 24, 2019 18:45
Add CRT scanlines, screen flicker and color separation effects
/*Stolen from http://aleclownes.com/2017/02/01/crt-display.html*/
/*This adds a "crt scanlines" effect to the screen*/
.crt-scanlines::before {
content: " ";
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
@lmas
lmas / refreshmonitor.sh
Created November 1, 2023 21:55
Switch between monitors using xrandr, while running bspwm
#!/bin/sh
# This script tries to automatically switch to a plugged in monitor
# and handles any quirks or issues while doing so.
# Stores current desktop (bspwm switches to some other empty desktop after switch)
desk=$(bspc wm -d | jq ".monitors[].focusedDesktopId")
# Switch active monitor
if xrandr -q | grep -q "HDMI-2 connected"; then
@lmas
lmas / justfile
Created August 28, 2023 10:23
Justfile for Go projects
COVER := ".cover"
TARGETS := "$(go list ./... | grep -v /tmp)"
# Touch go.mod in any dirs you want to "exclude" from go mod tidy,
# for example inside tmp.
# Show available recipes by default
default:
@just --list
# Run tests and log the test coverage
@lmas
lmas / cbr2cbz.sh
Created August 5, 2023 18:26
Convert CBR files to CBZ
#!/bin/sh
set -e pipefail
# Converts all CBR files in current dir to CBZ
# Source:
# https://ubuntuforums.org/showthread.php?t=1273762&s=a388d691ed1d259329dc26304528a056&p=8676006#post8676006
convert() {
dir=$(pwd)
cbr="$1"
@lmas
lmas / divider.go
Last active July 3, 2023 15:10 — forked from peterbourgon/golf.go
Separate chunks of live log output (like spaceror tailer)
package main
import (
"fmt"
"io"
"os"
"strings"
"time"
)
@lmas
lmas / unbound_blocklist.sh
Last active June 25, 2023 15:45
Script to generate a blocklist zone file for unbound DNS server
#!/bin/sh
# Inspired by:
# https://old.reddit.com/r/PFSENSE/comments/9mipe0/unboundbased_dnsblacklisting/
# https://news.ycombinator.com/item?id=22854209
#
# With lotsa code stolen from:
# https://www.tumfatig.net/20190405/blocking-ads-using-unbound8-on-openbsd/
#
# Comment filter syntax from:
@lmas
lmas / windows1252-decoder.go
Created February 20, 2016 19:04
Decode Windows-1252 encoded strings.
package main
import (
"fmt"
"io/ioutil"
"strings"
"golang.org/x/text/encoding/charmap"
)
@lmas
lmas / oblique_strategies.md
Created April 2, 2023 17:23
List of "cards" from Oblique Strategies

List of "cards" from Oblique Strategies

(Stolen from David Wicks, who didn't specify any source license)

  • Turn it over.
  • Switch the axes.
  • Think about color.
  • Make it black and white.
  • Use the tangents.