Skip to content

Instantly share code, notes, and snippets.


Derek Hohls gamesbook

  • GeoInt
  • South Africa
View GitHub Profile
gamesbook /
Last active May 22, 2022 — forked from wojteklu/
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.

General rules

  1. Follow standard conventions. Python: PEP-8 and black.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

gamesbook /
Last active May 8, 2022 — forked from spalladino/
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec $CONTAINERID /usr/bin/mysqldump -u root -proot $DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i $CONTAINERID /usr/bin/mysql -u root -proot $DATABASE
gamesbook /
Created May 11, 2021
Generate techno babble for marketing content
Purpose: generate management buzzphrases from buzzwords
BUZZ_WORDS are from
import random
BUZZ_WORDS = """# verb
<option value='Aggregate'>aggregate</option>
<option value='architect'>architect</option>
gamesbook /
Created Apr 19, 2021
Copy files from source directory if they already exist in destination
for file in /src/*; do
if [ -f "/dest/${cfile}" ]
echo "${cfile}"
cp "/src/${cfile}" "/dest/${cfile}"
touch "/dest/${cfile}"
gamesbook /
Created Mar 28, 2021
Log time for process
import time
import logging
logger = logging.getLogger(__name__)
t0 = time.process_time()
logger.warning("Time elapsed: %3.6f", (time.process_time() - t0))
gamesbook /
Created Mar 12, 2021
Load and store settings via JSON or ENV variables #dataclasses
from dataclasses import dataclass, InitVar, asdict
import orjson
import os
class Config:
"""Track config/settings"""
id: int = None
name: str = None
gamesbook /
Created Mar 7, 2021
Example of dataclass with property
from dataclasses import dataclass
from typing import List, Tuple
class Position:
name: str
dates: List[int]
items: Tuple
lon: float = 0.0
lat: float = 0.0
gamesbook /
Created Mar 7, 2021
Example of singleton class
Is this a good idea?
class Singleton:
__instance = None
gamesbook /
Last active Apr 20, 2020
Python script to access Corona / COVID-19 data from worldometers as Excel or plain text
# coding: utf-8
"""Command-line access to stats from
Created: 2020-04-05
Author: Derek <>
chromedriver -
xlsxwriter -
gamesbook /
Created Sep 6, 2019
Create reStructuredText complex table from list of dictionaries
# coding: utf-8
"""Purpose: Create reStructuredText complex table from list of dictionaries
Created: 2019-09-05
Authors: dhohls <> Derek Hohls