Skip to content

Instantly share code, notes, and snippets.

View aw's full-sized avatar

Alex Williams aw

View GitHub Profile
@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 <license@unscramble.jp>
#
# 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 / 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 <pborelli@gnome.org>
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 / 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 / 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 / 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 / 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 / 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 / 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 / Makefile.patch
Created January 5, 2016 10:01
Compile 32-bit picolisp on ARM (RPi)
--- Makefile 2015-09-06 03:34:04.000000000 +0000
+++ Makefile.old 2015-09-06 03:34:33.000000000 +0000
@@ -19,10 +19,10 @@ CFLAGS = -c -O2 -pipe \
ifeq ($(shell uname), Linux)
OS = Linux
- CFLAGS += -m32
- PICOLISP-FLAGS = -m32 -rdynamic
+ #CFLAGS += -m32
+ PICOLISP-FLAGS = -rdynamic
@aw
aw / gist:6823356
Created October 4, 2013 09:29
[FIX] Amazon EC2 gateway NAT doesn't work?
# Had this crazy networking problem when trying to use an EC2 instance as a NAT gateway.
#
# Here's a fix I found buried in documentation here:
# http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html
#
Disabling Source/Destination Checks
Each EC2 instance performs source/destination checks by default. This means that the instance must be the source or destination of any traffic it sends or receives. However, a NAT instance must be able to send and receive traffic when the source or destination is not itself. Therefore, you must disable source/destination checks on the NAT instance.