A common complaint I hear from people coming to Go from another language, is that Go is “missing features” and requires “a lot of boilerplate”. I’d argue that this is a misconception stemming from the trend of languages becoming more prescriptive and bloated in the name of being “expressive”.
The Go programming language stands out from other modern mainstream languages because of the simplicity of its instruction set. Understanding the why of Go is key to understanding the how.
Sometimes it’s handy to be able toggle programs or services on and off. Here’s one way to do that:
#!/bin/sh
prog="myprogram"
# See if program has an active process IDif pidof -x "${prog}";then# if so, kill it and exit cleanly
killall "${prog}"exit0fi# Otherwise start the program"${prog}"&
If you use a launcher like dmenu or hotkeys to launch scripts, anything you invoke will have a $TERM of “linux”.
By adding a guard for this value, you can tell whether or not you’re running inside of a terminal, and if not, run the script inside your terminal of choice:
#!/bin/sh
if["$TERM"='linux'];then
st -e "$0"elsedo stuff ...
fi
If you’re using a minimal Linux distro, you’ve probably noticed that your fonts are pretty wonky out of the box.
Override default monospace font
The fallback for pretty much everything that displays code or terminal output is “monospace”. Instead of setting up overrides in individual applications, you can just override it globally (for your user) in fontconfig.
In this example we return “Source Code Pro” whenever we match mono.
Surf has an external media player function called clickexternplayer. This function invokes a macro called VIDEOPLAY that’s defined in the config.def.h file.
Here, I’ve edited the macro to use the mmq script from this post:
I was in a weird situation where I had to export some data from a device attached to a non-encrypted (but otherwise trusted) system,
to an encrypted system that was incompatible with the device. I wanted to transfer this data without an intermediary writes on unencrypted disks.
The first thing that came to mind actually worked really well:
I am a big fan of the semantic web, POSH markup and microformats. Now that I’m self-publishing again, one of my first tasks is ensuring my site generation templates produce well structured, and semantically rich documents.
The DIY ethos of the 80s & 90s Punk/Hardcore scenes was the basis of my formative values. DIY taught me that everything we depend on is made and maintained by regular people. There was nothing mysterious about fixing a car, building a house, or machining precision gears. With access to knowledge, and the will to apply it, ordinary people are capable of just about anything. You don’t need a degree, certification, or even permission. You can just “Do It Yourself”.
I consume all my video (and a lot of my audio) through mpv. I used to queue up media in mpv using taskspooler, but that lacks the ability to go back to a previous video. The native playlist functionality solves this problem, so I decided to use that. The easiest way I could see to do this was leveraging the FIFO command input option in mpv.
I kill and create the fifo whenever I start X by adding this line to my .
By default, mutt runs external commands in the foreground of your mutt window. For long running tasks this can get kind of annoying.
I wrote a quick shell script to detect whether or not I’m in a tmux session, and if so, spawn an auto-closing background window to run offlineimap:
#!/usr/bin/sh # Are we in tmux? if [ -z "${TMUX}" ]; then # Did we pass in an account? if [ -z "${1}" ]; then offlineimap else offlineimap -a "$1" fi else # Did we pass in an account?
There was a bug in Overwatch that made the game fun. Blizzard just uninstalled the fun, so now I can probably post this without getting banned.
The bug was a race condition in the custom games UI, that would allow for moving AI players into teams that were already full. Exploiting the bug was pretty simple, you just had to click quickly enough to cause the collision.
Example:
I’m lazy and I cheat at cookie clicker, so I decided to write a thing to automate the exploit.