Skip to content

Instantly share code, notes, and snippets.

Avatar

Keith Bennett keith-bennett-gbg

View GitHub Profile
@keith-bennett-gbg
keith-bennett-gbg / CMakeLists.txt
Created Dec 11, 2019
Use cpack to install random data
View CMakeLists.txt
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)
View beautifulsoup_tornado_example.py
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 Apr 10, 2019
X11-based Firefox in a Docker container
View Firefox.Dockerfile
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 Feb 6, 2019
Poll rabbitmq:3-management in Docker for liveliness
View liveliness-poll-docker-rmq.bash
#!/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.
View cloexec-does-not-close-in-parent.cpp
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
View file descriptors example.c
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
View yaml-cpp.address-sanitizer.diff
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")
View sshi.bash
sshi() {
if [ $# -eq 0 ]
then
ssh
return $?
fi
username=$(echo -n "${1}" | grep -oP "^.*@")
if [ "${username}" == "" ]
then