Skip to content

Instantly share code, notes, and snippets.

@hx
hx / PRIVACY.md
Created July 14, 2022 22:38
Neil E. Pearson Free Software Privacy Policy

Free Software Privacy Policy

Neil E. Pearson

My commitment to privacy

  1. This Privacy Policy has been created because I value your right to keep your personal information private, and to comply with the National Privacy Principles. This policy sets out how I gather and disseminate your personal information.
  2. In this Privacy Policy, "user" refers to any users of software that I have personally released in my own name.
@hx
hx / systemd-cheat-sheed.md
Created July 2, 2022 22:31
Systemd Cheat Sheet

I'm constantly forgetting how to write and install these. Here's my crib sheet.

Make a new service

$ sudo vim /lib/systemd/system/name_of_service.service
[Unit]
@hx
hx / cycle.js
Last active July 13, 2021 04:21
Google Meet single-button navigation
// I use this with the Shortkeys Chrome plugin to navigate meetings with a single button.
(() => {
const find = cond => () => document.querySelector(cond)
const findButton = text => () => [...document.querySelectorAll('button,[role=button]')].find(b => b.textContent === text)
const steps = [
// Unmute first
find('[aria-label*="Turn on mic"]'),

Keybase proof

I hereby claim:

  • I am hx on github.
  • I am hx84 (https://keybase.io/hx84) on keybase.
  • I have a public key ASCGiDi2x0TpodONgBNlkk6O1kNzG441gZZW0Pud_VlRaQo

To claim this, I am signing this object:

@hx
hx / appleraid.rb
Last active July 10, 2017 23:25
Create a software RAID set on macOS
#!/usr/bin/env ruby
# coding: utf-8
abort "This script needs Ruby 2 or later. You have #{RUBY_VERSION}." if RUBY_VERSION < '2.0.0'
require 'io/console'
require 'pathname'
require 'shellwords'
# Imitating ActiveSupport a bit here:
@hx
hx / daemon.rb
Created December 6, 2015 09:40
Ruby Daemons with DRb
require 'drb'
require 'pathname'
require 'shellwords'
require 'timeout'
module DRb
class Daemon
PATH_KEY = 'DRB_DAEMON_PATH'
PROTOCOL = 'drbunix:'
@hx
hx / OS.rb
Created November 5, 2015 02:58
OS detection and TIOCGWINSZ in Ruby
module OS
class << self
def windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
@hx
hx / README.md
Created October 26, 2015 10:04
Rebuilding a Fusion drive when all else is hopeless

Today, a poorly-timed tick of the "enable FileVault" box on El Capitan (OS X 10.11.1) resulted in a very dead hard drive that Disk Utility was unable to repair. Here's the basic command-line solution:

Show your CoreStorage volumes:

diskutil cs list

Delete CoreStorage logical volumes:

@hx
hx / README.md
Last active October 26, 2015 06:20
Bookmarks

Run a bunch of processes (e.g. Python-based web services), and bind an additional server to port 80 that encapsulates a list of "bookmark" urls.

@hx
hx / fixPathCase.php
Last active December 18, 2015 16:19
When you include() a file on a case-insensitive file system, XDebug can get confused about which file you're debugging. This function converts a path with incorrect case to correct case. To test, try var_dump(fixPathCase('/uSr/BiN'));
<?php
function fixPathCase($path) {
if(!file_exists($path)) {
return false;
}
if(file_exists(strtoupper($path)) && file_exists(strtolower($path))) {
$parts = explode('/', $path);
foreach($parts as $k => $i) {
if($i) {
foreach(scandir(dirname(implode('/', array_slice($parts, 0, $k + 1)))) as $file) {