Skip to content

Instantly share code, notes, and snippets.

💵
I will code golang, C, C++, etc, for money.

Steve Kemp skx

💵
I will code golang, C, C++, etc, for money.
Block or report user

Report or block skx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View calc.go
// calc.go
//
// Assume the user gives you input like this:
//
// 1 2 3 * +
//
// What does that mean? Well the input is written in "reverse-polish",
// which means the numbers come first, then the operations. This is a bit
// weird if you're new to it, but it makes processing the input
// much simpler, because you don't have to worry about "precedence", or
@skx
skx / Input
Last active May 4, 2018
m4 for overseer test definitions
View Input
#!/usr/bin/m4
# Define a macro for a tinc-protocol test
define(`tinc', `$1 must run tcp with port 655 with banner "^0 \S+ 17$"')
# builder.steve.org.uk
tinc(`176.9.183.97')
# master.steve.org.uk
tinc(`176.9.183.98')
@skx
skx / hashcheck_lsm.c
Created Jun 26, 2017
Linux Security Module - hashcheck - which checks that files have known-good hashes prior to command execution.
View hashcheck_lsm.c
/*
* hashcheck_lsm.c - Steve Kemp
*
* This is a security module which is designed to prevent
* the execution of unknown or (maliciously) altered binaries.
*
* This is achieved by computing an SHA1 digest of every
* binary before it is executed, then comparing that to the
* (assumed) known-good value which is stored as an extended
* attribute alongside the binary.
View Osram.pm
package Power::Outlet::Osram;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP};
use Device::Osram::Lightify::Hub;
our $VERSION='0.16';
View redis-set-test
#!/usr/bin/perl -w
#
# This is a simple perl-script which demonstrates adding jobs to
# a pretend redis-based work-queue.
#
# The intention is that we'll add jobs, and they'll be added to sets
# such that we don't need to worry about unbound-growth.
#
# This program demonstrates that using a sorted-set results in .. a sorted
# set with guaranteed ordering when items are removed.
@skx
skx / ctrl-alt-t.c
Created Dec 7, 2014
Run a terminal when ctrl-alt-t is pressed.
View ctrl-alt-t.c
/**
* Launch a terminal when Ctrl-Alt-T is pressed.
*
* gcc -o ctrl-alt-t ctrl-alt-t.c -lX11
*
* Steve
* --
*
* PS. Use xbindkeys like a normal person ;)
*
@skx
skx / Makefile
Last active Aug 29, 2015
Proof of concept binding for lumail 2.x
View Makefile
#
# Build the driver.
#
all: driver
clean:
rm -f *.o core driver || true
@skx
skx / dock-run
Created Nov 8, 2014
Wrapper to allow post-creation hooks for docker guests.
View dock-run
#!/bin/sh
#
# Launch a new docker container.
#
# Execute run-parts against a creation directory, and make both the ID
# and the NAME of the new container availalbe to those scripts via the
# environment.
#
# Steve
# --
@skx
skx / docker-watch
Created Nov 8, 2014
Run commands when docker containers are started/terminated.
View docker-watch
#!/usr/bin/perl -w
#
# This script watches for docker containers to be launched/stopped
# and lets you invoke scripts.
#
use strict;
use warnings;
#
@skx
skx / StaticPages.pm
Created Oct 3, 2014
Proof of concept static-page generator for chronicle2
View StaticPages.pm
package Chronicle::Plugin::Generate::StaticPages;
use strict;
use warnings;
=begin doc
Create a table for the static-pages.
You can’t perform that action at this time.