Skip to content

Instantly share code, notes, and snippets.

View Alhadis's full-sized avatar

John Gardner Alhadis

View GitHub Profile
@Alhadis
Alhadis / match-url.pl
Created April 6, 2019 22:41
Match URL
#!/usr/bin/env perl
# Adopted from https://github.com/atom/language-hyperlink
use strict;
use warnings;
use v5.14;
my $matchURL = qr~ \b
# Protocol
( https?
| s?ftp
@Alhadis
Alhadis / blend-modes.c
Created February 24, 2019 03:48
blend-modes.c
/* From: http://web.archive.org/web/20090222030436/http://www.nathanm.com/photoshop-blending-math/ */
#define ChannelBlend_Normal(B,L) ((uint8)(B))
#define ChannelBlend_Lighten(B,L) ((uint8)((L > B) ? L:B))
#define ChannelBlend_Darken(B,L) ((uint8)((L > B) ? B:L))
#define ChannelBlend_Multiply(B,L) ((uint8)((B * L) / 255))
#define ChannelBlend_Average(B,L) ((uint8)((B + L) / 2))
#define ChannelBlend_Add(B,L) ((uint8)(min(255, (B + L))))
#define ChannelBlend_Subtract(B,L) ((uint8)((B + L < 255) ? 0:(B + L - 255)))
#define ChannelBlend_Difference(B,L) ((uint8)(abs(B - L)))
#define ChannelBlend_Negation(B,L) ((uint8)(255 - abs(255 - B - L)))
@Alhadis
Alhadis / dwb-darwin.patch
Last active September 11, 2018 13:16
Patches to compile DWB3.3 on macOS 10.13.6
diff --git a/text/eqn/e.h b/text/eqn/e.h
index 881354b..bf5ad3c 100644
--- a/text/eqn/e.h
+++ b/text/eqn/e.h
@@ -21,6 +21,7 @@ extern int class[LAST][LAST];
extern char errbuf[200];
extern char *cmdname;
+#undef sprintf
#define ERROR sprintf(errbuf,
@Alhadis
Alhadis / macro-packages.json
Last active August 31, 2018 10:05
Troff macros organised by package
{
"macros": {
"man": [
"AT", "B", "BI", "BR", "BT", "DT", "EE", "EX", "HP", "I", "IB", "IP",
"IR", "LP", "ME", "MT", "OP", "P", "PD", "PP", "PT", "R", "RB", "RE",
"RI", "RS", "SB", "SH", "SM", "SS", "TH", "TP", "UC", "UE", "UR"
],
"mdoc": [
"%A", "%B", "%C", "%D", "%I", "%J", "%N", "%O", "%P", "%Q", "%R", "%T",
@Alhadis
Alhadis / atom.1.html
Last active December 6, 2018 13:28
Manpage previews
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><title>Preview</title><style> html{ background: black; color: white } a{ color: inherit; text-decoration: none } pre{ font: 10px Menloco, Monaco, Menlo, monospace; font-variant-ligatures: none }</style></head><body><pre>
ATOM(1) General Commands Manual ATOM(1)
<b>NAME</b>
atom — a hackable text editor for the 21st century
<b>SYNOPSIS</b>
<b>atom</b> [<u>options</u>] [<u>paths...</u>]
@Alhadis
Alhadis / after.html
Last active February 16, 2018 04:15
node(1) mdoc/man comparison
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><title>After</title><style> html{ background: black; color: white } a{ color: inherit; text-decoration: none } pre{ font: 1rem "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; font-variant-ligatures: none }</style></head><body><pre>
NODE(1) BSD General Commands Manual NODE(1)
<b>NAME</b>
<b>node</b> — server-side JavaScript runtime
<b>SYNOPSIS</b>
<b>node</b> [<u>options</u>] [<u>v8-options</u>] [<b>-e</b> <u>string</u> | <u>script.js</u> | <b>-</b>] [<b>--</b>]
[<u>arguments</u> <u>...</u>]
<b>node debug</b> [<b>-e</b> <u>string</u> | <u>script.js</u> | <b>-</b> | <u>&lt;host&gt;:&lt;port&gt;</u>] <u>...</u>
@Alhadis
Alhadis / Annulus-3pt.svg
Created October 10, 2017 13:51
Glyph-Clipping-Demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Alhadis
Alhadis / README.md
Last active April 7, 2018 19:55
Harvester
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Alhadis
Alhadis / ba.sh
Last active August 6, 2020 13:27
Self-reminders
# Tell a program to completely shut the fuck up
(npm install get-options) >/dev/null 2>&1
# Repeat a character a certain number of times
printf %100s | tr ' ' '='
# Hide/show files or directories in Finder
chflags hidden /path/to
chflags nohidden /path/to