Skip to content

Instantly share code, notes, and snippets.

View aw's full-sized avatar

Alex Williams aw

View GitHub Profile
@aw
aw / tc-config.patch
Created May 17, 2016 15:34
Patch for pre-boot script
diff --git a/etc/init.d/tc-config b/etc/init.d/tc-config
index f6002dd..c44876c 100755
--- a/etc/init.d/tc-config
+++ b/etc/init.d/tc-config
@@ -25,6 +25,8 @@ addUser(){
# Main
+[ -f "/opt/preboot.sh" ] && /opt/preboot.sh
+
@aw
aw / gist:79c7a7cc12e93e165d144ec5bb8fc844
Last active May 16, 2018 07:13
yum-downloadonly disappeared or missing from CentOS 6

Hopefully this can save someone else some time

If you get the error message: "No Package matching 'yum-downloadonly'"

Well it's because the package was renamed in RHEL6, but CentOS 6 only recently removed it, so now you must refer to yum-plugin-downloadonly instead.

Snippet from here: https://access.redhat.com/solutions/10154

(RHEL5)
@aw
aw / writesame.sh
Created February 10, 2017 12:56
Suppress WRITE SAME messages
# Suppress WRITE SAME messages
disks=`find /sys | grep max_write_same_blocks`
for i in $disks; do
[ -f "$i" ] && echo 0 > "$i"
done
@aw
aw / backcompat.md
Last active March 8, 2017 04:40
PicoLisp backwards compatibility hacks

This gist is meant to track backwards incompatible changes in PicoLisp, and provide simple hacks to ensure backwards compatibility with older versions.

PicoLisp v17.3.4 - March 2017

  • (local) syntax changes
  • (local) is now undefined in 32-bit
  • (local) [doesn't accept parameters in 64-bit]

HACK:

@aw
aw / mongodb-invariant-failure.md
Created March 30, 2017 06:42
[SOLUTION] MongoDB aborting after invariant() failure

I recently ran into an issue of MongoDB shell commands not working. The error message was:

Invariant failure !driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty() src/mongo/rpc/metadata/client_metadata.cpp

I ran an strace on the mongo command and saw it was trying (and failing) to open the following files:

@aw
aw / http-patch.l
Created November 5, 2017 09:43
Monkey-patch PicoLisp http.l
(patch _htHead
'(case (lowc (till " ^M^J" T)) @S)
(fill '(case (lowc (till " ^M^J" T))
("auth-hash:" (setq *AUTH_HASH (pack (cdr (line)))))
("auth-cookie:" (setq *AUTH_COOKIE (pack (cdr (line)))))
("auth-token:" (setq *AUTH_TOKEN (pack (cdr (line)))))
. @S) ) )
@aw
aw / picolisp.lang
Last active May 10, 2018 02:19
PicoLisp syntax highlighting for Pluma / gtksourceview
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of GtkSourceView
Author: Paolo Borelli <[email protected]>
Copyright (C) 2006-2007 Paolo Borelli
GtkSourceView is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@aw
aw / cidr-to-netmask.l
Created December 26, 2017 14:35
Convert a CIDR to Subnet Netmask address in PicoLisp
# MIT Licensed
#
#(c) 2017 Alexander Williams, Unscramble <[email protected]>
#
# IPv4 "24" -> "255.255.255.0"
[de cidr-to-netmask (Mask)
(let (Pos (- 5 (/ Mask 8))
Val (& (>> (- (- 8 (% Mask 8))) 255) 255) )
(glue "."
@aw
aw / uptime.l
Created January 5, 2018 10:16
Parse uptime in PicoLisp
# (MIT)
# v1
(setq *Mystr "09:56:51 up 6:46, 1 user, load average: 0.81, 0.45, 0.36")
(extract pack (mapcar clip (split (stem (chop *Mystr) "l" "o" "a" "d" "a" "v" "e" "r" "a" "g" "e" ":") ",")))
@aw
aw / picolisp-wildcard.md
Created February 3, 2018 13:41
PicoLisp glob/wildcard expansion in call and exec commands

In PicoLisp, there is often a situation where you want to execute a command with the * argument. Bash shell expands * to the list of filenames, but PicoLisp doesn't.

Here are two workarounds for this bash command:

grep -l "let" *

1. with (cons)