Skip to content

Instantly share code, notes, and snippets.

View keith-bennett-gbg's full-sized avatar

Keith Bennett keith-bennett-gbg

View GitHub Profile
@keith-bennett-gbg
keith-bennett-gbg / CMakeLists.txt
Created December 11, 2019 23:10
Use cpack to install random data
CMAKE_MINIMUM_REQUIRED(VERSION 3.5) # not sure what the minimum actually is. this is locally installed.
PROJECT(example C) # C says to find C compilers. Ignore that.
# or from git or read from a file or whatever
SET(VERSION "1.0.0")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "koti")
set(CPACK_PACKAGE_RELEASE 1)
@keith-bennett-gbg
keith-bennett-gbg / beautifulsoup_tornado_example.py
Last active September 6, 2019 22:43
Generate HTML in Python
import tornado.ioloop
import tornado.web
#import htmlboilerplate as html
from bs4 import BeautifulSoup, Tag
import htmlboilerplate2 as html
class MainHandler(tornado.web.RequestHandler):
def get(self):
soup = BeautifulSoup('', 'html5lib')
@keith-bennett-gbg
keith-bennett-gbg / Firefox.Dockerfile
Created April 10, 2019 23:17
X11-based Firefox in a Docker container
FROM alpine
RUN true \
&& sed -i -e 's/v[[:digit:]]\.[[:digit:]]/edge/g' /etc/apk/repositories \
&& apk upgrade --update-cache --available \
#
# Add font, otherwise firefox draws garbage "tofu".
# Noto is a Google-created open source font (Open Font License)
&& apk add --no-cache font-noto \
#
# It seems only ESR is in alpine's package list.
@keith-bennett-gbg
keith-bennett-gbg / liveliness-poll-docker-rmq.bash
Last active February 6, 2019 19:37
Poll rabbitmq:3-management in Docker for liveliness
#!/usr/bin/env bash
# https://www.shellcheck.net/ || https://github.com/koalaman/shellcheck
# Use of undefined variables is an error.
set -u
# Any process in a pipeline reporting a failure is an error.
set -o pipefail
# Stop the script on errors.
@keith-bennett-gbg
keith-bennett-gbg / cloexec-does-not-close-in-parent.cpp
Created August 28, 2018 15:40
cloexec-does-not-close-in-parent
extern "C" {
#include <sys/types.h> // fork(), open()
#include <sys/stat.h> // open()
#include <sys/wait.h> // waitpid()
#include <unistd.h> // fork(), fcntl(), read(), execve()
#include <fcntl.h> // fcntl(), open()
#include <signal.h> // signal()
} // extern "C"
#include <iostream>// std::cerr
struct file_descriptor
{
// implementation goes here
int read(char * destination, int count);
int write(char * source, int count);
};
struct disk_file : public file_descriptor
{
// route requests to disk I/O functions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a082038..f4455c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,7 +124,7 @@ include_directories(${YAML_CPP_SOURCE_DIR}/include)
### General compilation settings
###
set(yaml_c_flags ${CMAKE_C_FLAGS})
-set(yaml_cxx_flags ${CMAKE_CXX_FLAGS})
+set(yaml_cxx_flags "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
sshi() {
if [ $# -eq 0 ]
then
ssh
return $?
fi
username=$(echo -n "${1}" | grep -oP "^.*@")
if [ "${username}" == "" ]
then