Skip to content

Instantly share code, notes, and snippets.

View jbothma's full-sized avatar

JD Bothma jbothma

View GitHub Profile
@jbothma
jbothma / dj-database-url.md
Last active April 25, 2025 17:42
Database Setup for django project using DJ-Database-URL

This is a short guide for common database setup for a django app using DJ-Database-URL. This is focused on setting up a development environment. Production will be similar but instead of using the default DB location and credentials, you should use the location of the actual DB server and you really ought to be using a secret password.

Find the DB name and credentials

@jbothma
jbothma / pg10-to-9.sh
Last active June 18, 2018 14:08
Load postgresql 10 dump into postgres 9.3
zcat dump.gz | egrep -v "(idle_in_transaction_session_timeout|row_security|AS integer)" | psql postgresql://...
@jbothma
jbothma / delete-resources.sh
Created March 9, 2018 14:03
Delete all resources for CKAN packages matching search criteria
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for resource in `curl 'localhost/api/3/action/package_search?q=+organization:"national-treasury"+vocab_financial_years:"2018-19"'|jq -r '.result.results[]|.resources[].id'`
do ckanapi -r http://localhost -a lalala action resource_delete id=$resource
done
IFS=$SAVEIFS
@jbothma
jbothma / Employment Status by Age.md
Created March 8, 2018 10:11
How to get South African Census Data in Excel or CSV
title: Estimates of National Expenditure of South Africa 2017-18-testy
dataset-name: estimates-of-national-expenditure-south-africa-2017-18-testy
resource-name: estimates-of-national-expenditure-south-africa-2017-18-testy
sources:
- url: "dupe-test.csv"
headers: 1
name: ene-2017-18
cache: True
@jbothma
jbothma / getting started programming.md
Last active November 9, 2017 10:39
Getting started with programming and web development for someone in a place like khayelitsha

This is the app to learn programming on your phone. I recommend you start with HTML, CSS and Javascript https://play.google.com/store/apps/details?id=com.sololearn

it teaches you stuff, then you have quizes where you can test what you've learned, and you can actually write some code and test it see it working

python is also a good one to learn after javascript

this can teach you basics of becoming a freelance website developer https://www.smashingmagazine.com/2009/07/the-roadmap-to-becoming-a-professional-freelance-web-designer/

some of it might not perfectly fit south africa or khayelitsha but you can imagine how it connects to the businesses around you

@jbothma
jbothma / loop.sh
Created September 30, 2017 10:24
save and change IFS to loop over filenames with spaces
SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for f in `ls */*/*.xlsm`; do echo soffice --headless --convert-to xlsx \"$f\" --outdir \"$(dirname $f)\"; done; IFS=$SAVEIFS
@jbothma
jbothma / keybase.md
Created August 14, 2017 09:07
keybase.md

Keybase proof

I hereby claim:

  • I am jbothma on github.
  • I am jbothma (https://keybase.io/jbothma) on keybase.
  • I have a public key whose fingerprint is 1016 1320 E0BC FDD7 5F5F 48C2 B410 8474 DEE2 7D69

To claim this, I am signing this object:

@jbothma
jbothma / pdf-ocr.sh
Last active October 3, 2020 10:26
Adding OCR text to a PDF (even a noisy one)
# usage: ocr-pdf scanned.pdf
set -euf -o pipefail -o xtrace
INFILE=$1
BASENAME=$(basename "$1" .pdf)
TIFFFILE=$BASENAME.tiff
OCRDPDFNOEXT=$BASENAME-OCRd-big
OCRDPDF=$OCRDPDFNOEXT.pdf
SMALLEROCRDPDF=$BASENAME-OCRd.pdf
@jbothma
jbothma / import voter turnout.sql
Created May 9, 2017 12:45
Import wazimap voter turnout for 2016 municipal elections from all-ward-turnout dump obtained directly from IEC tech department
CREATE TEMPORARY TABLE voter_turnout
(
province TEXT,
muni TEXT,
ward TEXT,
registeredvoters TEXT,
mec7votes TEXT,
voterturnout TEXT,
percentvoterturnout TEXT