Skip to content

Instantly share code, notes, and snippets.

View gamesbook's full-sized avatar

Derek Hohls gamesbook

  • Independant Contractor
  • South Africa
View GitHub Profile
@gamesbook
gamesbook / mysql-docker.sh
Last active May 8, 2022 06:28 — forked from spalladino/mysql-docker.sh
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
gamesbook / covid19.py
Last active April 20, 2020 13:51
Python script to access Corona / COVID-19 data from worldometers as Excel or plain text
# coding: utf-8
"""Command-line access to stats from https://www.worldometers.info/coronavirus/
Created: 2020-04-05
Author: Derek <[email protected]>
Requires:
chromedriver - https://chromedriver.chromium.org/
xlsxwriter - https://xlsxwriter.readthedocs.io/
@gamesbook
gamesbook / ticks.py
Last active July 2, 2024 08:31
Convert C# tick dates into a Python / readable date
# -*- coding: utf-8 -*-
"""
Purpose: Convert .NET ticks to formatted ISO8601 time
Author: D Hohls < [email protected]>
"""
from __future__ import print_function
import datetime
import sys
import io
import selectors
import subprocess
import sys
def capture_subprocess_output(subprocess_args):
# Start subprocess
# bufsize = 1 means output is line buffered
# universal_newlines = True is required for line buffering
process = subprocess.Popen(subprocess_args,
@mariocesar
mariocesar / admin.py
Last active December 28, 2023 19:17
Django admin decorator to create a confirmation form action, like the default delete action works
from .models import Post, Category
from .decorators import action_form
class PostCategoryForm(forms.Form):
title = 'Update category for the selected posts'
myfile = forms.FileField()
category = forms.ModelChoiceField(queryset=Category.objects.all())
@ankurk91
ankurk91 / install-node-js.sh
Last active November 4, 2024 05:29
Install node-js, npm and yarn on Ubuntu/Mac using nvm
#!/bin/sh
# Install node and npm via nvm - https://github.com/nvm-sh/nvm
# Run this script like - bash script-name.sh
# Define versions
INSTALL_NODE_VER=22
INSTALL_NVM_VER=0.40.1
#!/usr/bin/python
#Kwh per weekday
import time
import logging
import calendar
from datetime import datetime
import redis
@palewire
palewire / settings.py
Created February 4, 2012 21:50
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',