Skip to content

Instantly share code, notes, and snippets.

View OhMeadhbh's full-sized avatar

Meadhbh Hamrick OhMeadhbh

View GitHub Profile
@OhMeadhbh
OhMeadhbh / 00_readme.txt
Last active July 28, 2023 12:22
Efficiently Calculating the Parity of a 32 Bit Integer
Read this file first.
Then read the comments at the top of parity_test.c
Then read the comments above each algorithm implementation in parity.c
So there I was talking about efficient implemetation of fundamental functions
with Palmer over at SiFive. Back in the day, I used to participate in informal
contests on rec.games.programmer to see who could craft the most efficient
implementations for population count or bit reversal or bit-blitting. For
programmer types, it's great fun.
@OhMeadhbh
OhMeadhbh / put_in_xresources.txt
Created July 11, 2023 00:50
Put these lines in your ~/.Xresources file to make xterm look like a VT240.
// I'm a fan of old-school VT220 & VT340 terminals. A
// while back I noticed Viacheslav Slavinsky created a
// TrueType typeface you could use with x/windows to
// make xterm look like a VT-whatever. You can download
// the original typeface from:
//
// https://github.com/svofski/glasstty
//
// And there's a web page describing its creation at:
//
@OhMeadhbh
OhMeadhbh / combining.sh
Last active June 15, 2023 18:48
Print out latin characters combined with unicode combining characters
# This *should* print out lower case latin characters along with various
# unicode combining characters. It's somewhat interesting to see how different
# terminals and typefaces handle this.
# Combining Diacritical Marks 0300-036F
for k in 0 1 2 3 4 5 6
do
for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do
@OhMeadhbh
OhMeadhbh / readme.txt
Last active June 1, 2023 21:48
Print something like a completion bar on terminals that support SIXEL graphics
This is a simple utility that prints a bar on a
terminal screen. It's no different than a thousand
other such utilities except it's output doesn't look
like crap. It uses SIXEL mode, so you'll have to
have a terminal (or terminal emulator) that supports
it. (if you start xterm with `xterm -ti vt340` it
should work.)
This is useful if, like me, you SSH into remote *nix
systems (like on AWS) and you want to get a graphical
@OhMeadhbh
OhMeadhbh / gssc
Last active January 15, 2023 18:56
This is the script I made a long time ago to generate self-signed certificates. While I was using it recently I realized other people might find it useful. Standard disclaimers apply: never use a self signed cert unless you know what you're doing; use at your own risk -- if it causes any damage, it's not my fault; feel free to use & copy it, jus…
#!/bin/bash
# Copyright (c) 2003-2013, Meadhbh S. Hamrick. All Rights Reserved.
# Released under a BSD License. See http://opensource.org/licenses/BSD-2-Clause
#
# This script uses openssl to generate a self-signed certificate. Usage is
# like this:
# gssc <host name> [-p password] [-s subject] [-b bitlength]
# The host name parameter is the subject name of the certificate; i.e. - the
# FQDN of the host you're generating a certificate for. This is also the base
# name for the key, certificate signing request and certificate files. If you
@OhMeadhbh
OhMeadhbh / path_patch.diff
Last active August 16, 2020 20:41
Update xace emulator to look for rom file at $XACEROM
112c112
< main(argc,argv)
---
> main(argc,argv,envp)
114a115
> char **envp;
128,129c129,130
<      
<   loadrom(mem);
---
@OhMeadhbh
OhMeadhbh / test_002.six
Created June 4, 2020 17:11
Random Sixel File

┌────────────────────────────────────────────┐
│ Through the Looking Glass (TTY Edition) │
├────────────────────────────────────────────┤
│ Alice did not feel encouraged to │
│ ask questions about it so she │
│ turned to the mock turtle and │
│ said "what else had you to learn │
│ when you were in school?" │
└────────────────────────────────────────────┘
@OhMeadhbh
OhMeadhbh / interval.c
Last active April 9, 2020 23:01
Talking Through A Coding Task
/* interval.c
**
** From a coding interview I (OhMeadhbh@gmail.com)
** recently participated in:
**
** Write a function that finds the intersection of two
** intervals. So if you had the intervals 2 - 8 and 5 -
** 12, the intersection would be 5 - 8. */
/* Let's start by defining the function that will
@OhMeadhbh
OhMeadhbh / whatever.txt
Created January 8, 2020 18:49
Hosting a Remote FileSystem that can do Links over CIFS
Hosting a Remote FileSystem that can do Links over CIFS
I’m in the process of migrating from one machine to another and it turns out that my home directory has exploded past the size of my largest external drive.
But I have a commercial NAS box that I rather like. But it’s setup to export a CIFS / SMB file system. I sort of like this since Linux, Mac and Windows all have decent support for SMB. But… it has one problem: links. CIFS *does not* like symbolic links.
So the solution I came up with was to create an image file on the NAS and mount it with losetup. Believe it or not, you can actually do this. Losetup will mount an image that’s hosted on a remote filesystem.
First, create an image file on the remote filesystem. You’ll need to know how big you want it. In this example, I’m making it about 370G, and the remote filesystem is mounted on /mnt/remote:
In Defense of Two Spaces After a Period
I spend more time than is healthy worrying about software documentation. Don't get me wrong, I enjoy coding. I enjoy the process of investigating problems, possibly breaking them down into sub-problems and then searching my toolbox of conceptual solutions to find the one that's *just right*. But communicating a developer's intent clearly is an important part of constructing a solution. If you work in a team with other software developers, communicating intent is of vital importance. Even if you work in isolation, documenting your intent is important so that when you eventually come back to your code several years later, you have a chance of understanding what you were trying to do.
And it was while I was in deep thought about documenting software that I thought that maybe, just maybe, there's justification for two spaces after a period in the modern world.
I frequently use EMACS to edit files; sometimes I use VI, I'm not a zealot. So I like to see text files as