Skip to content

Instantly share code, notes, and snippets.

@skx
skx / gist:6206622
Created August 11, 2013 20:01
Open a simple message, add attachments, and format it with GMime.
#include <string>
#include <string.h>
#include <fcntl.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <stdint.h>
#include <vector>
#include <glib.h>
@skx
skx / ad.c
Last active August 29, 2015 14:06
Simple utility script to dump attachments, via GMIME
/**
* AD.c - Attachment dumper.
***
*
* This is a simple script which is designed to write out the attachments
* from an email to disk.
*
* Compile like so:
*
* $ gcc -Wall -O2 ad.c -o ad $(pkg-config --libs --cflags gmime-2.6)
@skx
skx / lsb_release
Last active August 20, 2023 14:31
Simple alternative to /usr/bin/lsb_release
#!/bin/sh
#
# This is a simple alternative to /usr/bin/lsb_release which
# doesn't require python.
#
# If /etc/os-release exists then we use that to output data
# in a compatible format to the original lsb_release utility.
#
# I consider this script trivial enough to be in the public-domain,
# but any patches or suggestsions will be welcome.
@skx
skx / StaticPages.pm
Created October 3, 2014 14:19
Proof of concept static-page generator for chronicle2
package Chronicle::Plugin::Generate::StaticPages;
use strict;
use warnings;
=begin doc
Create a table for the static-pages.
@skx
skx / Makefile
Last active August 29, 2015 14:10
Proof of concept binding for lumail 2.x
#
# Build the driver.
#
all: driver
clean:
rm -f *.o core driver || true
@skx
skx / ctrl-alt-t.c
Created December 7, 2014 16:23
Run a terminal when ctrl-alt-t is pressed.
/**
* 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 ;)
*
package Power::Outlet::Osram;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP};
use Device::Osram::Lightify::Hub;
our $VERSION='0.16';
@skx
skx / hashcheck_lsm.c
Created June 26, 2017 18:09
Linux Security Module - hashcheck - which checks that files have known-good hashes prior to command execution.
/*
* 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.
@skx
skx / Input
Last active May 4, 2018 10:25
m4 for overseer test definitions
#!/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 / README.md
Last active March 14, 2024 06:58
Overview of catching yaml issues for kubernetes

Automating the use of Linting Tools

With a custom YAML check

Many linters are external (shell) commands you can invoke with a filename, and which exit with non-zero status-codes on failure.

The problems a given linter will report upon will obviously vary, but actually executing a linter automatically is broadly tool-agnostic, so automating is pretty simple:

  • When you save a file, and it is of a type which has a linter associated with it:
  • Run the external linter command passing the filename as an argument.