Skip to content

Instantly share code, notes, and snippets.

Avatar

Derek Hohls gamesbook

  • CSIR
  • South Africa
View GitHub Profile
@gamesbook
gamesbook / covid19.py
Last active Apr 20, 2020
Python script to access Corona / COVID-19 data from worldometers as Excel or plain text
View covid19.py
# coding: utf-8
"""Command-line access to stats from https://www.worldometers.info/coronavirus/
Created: 2020-04-05
Author: Derek <gamesbook@gmail.com>
Requires:
chromedriver - https://chromedriver.chromium.org/
xlsxwriter - https://xlsxwriter.readthedocs.io/
@gamesbook
gamesbook / ticks.py
Last active Nov 21, 2020
Convert C# tick dates into a Python / readable date
View ticks.py
# -*- coding: utf-8 -*-
"""
Purpose: Convert .NET ticks to formatted ISO8601 time
Author: D Hohls < dhohls@csir.co.za>
"""
from __future__ import print_function
import datetime
import sys
@mariocesar
mariocesar / admin.py
Last active May 27, 2021
Django admin decorator to create a confirmation form action, like the default delete action works
View admin.py
from .models import Post, Category
from .decorators import action_form
class PostCategoryForm(forms.Form):
title = 'Update category for the selected posts'
category = forms.ModelChoiceField(queryset=Category.objects.all())
@admin.register(Post)
@ankurk91
ankurk91 / install-node-js.sh
Last active Jun 19, 2021
Install node-js, npm and yarn on Ubuntu/Mac using nvm
View install-node-js.sh
#!/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=14
INSTALL_NVM_VER=0.38.0
View MQTT to Redis
#!/usr/bin/python
#Kwh per weekday
import time
import logging
import calendar
from datetime import datetime
import redis
@palewire
palewire / settings.py
Created Feb 4, 2012
My current default Django LOGGING configuration
View settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',