Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Miller millerdev

  • Dimagi, Inc.
View GitHub Profile
@millerdev
millerdev / gtk.css
Created March 15, 2021 14:43
Gnome CSS customizations - mainly narrower titlebar
View gtk.css
/*
Gnome 3 - based on https://blog.samalik.com/make-your-gnome-title-bars-smaller/
https://securitronlinux.com/bejiitaswrath/how-to-make-the-title-bars-in-gnome-shell-much-thinner-than-the-default/
sizes tweaked to make the close button bigger on 20.04 (not tested on earlier versions)
Copy or symlink to ~/.config/gtk-3.0/gtk.css
To change titlebar font from Bold to normal (maybe there is CSS for this too?):
$ gsettings get org.gnome.desktop.wm.preferences titlebar-font
'Ubuntu Bold 12'
View sentry-events.py
#! /usr/bin/env python
"""Download events form Sentry as CSV
https://gist.github.com/millerdev/3d0a541f90b9817c3be5dd9bffed288e
"""
import sys
import csv
from argparse import ArgumentParser
import requests
@millerdev
millerdev / rm-future.py
Last active August 23, 2019 15:44
Remove __future__ imports from Python files
View rm-future.py
#! /usr/bin/env python
"""Remove __future__ imports from Python files
Acts on *.py files in the current directory and all subdirectories.
Only removes lines in which all imported names are in KNOWN_FUTURES.
Public URL of this script:
https://gist.github.com/millerdev/f71648c1a9690cfca7c8b7c049867cfc
"""
@millerdev
millerdev / bucket_domains.py
Last active March 19, 2020 20:21
Categorize CommCare HQ domains needing couch -> sql migration of forms and cases
View bucket_domains.py
#!/usr/bin/env python
# coding: utf-8
"""
DEPRECATED moved to
https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/couch_sql_migration/management/commands/couch_domain_report.py
Categorize CommCare HQ domains needing couch -> sql migration of forms and cases
This script requires a domains.csv file, which can be obtained by following
these steps:
@millerdev
millerdev / delete_gmail.py
Last active July 1, 2019 17:40
Permanently bulk-delete messages from gmail
View delete_gmail.py
#! /usr/bin/env python3
"""Permanently delete messages from Gmail
WARNING: THIS SCRIPT CAN DO GREAT DAMAGE TO YOUR GMAIL ACCOUNT.
USE AT YOUR OWN RISK!
Setup guide:
1. Create and activate a new virtualenv with Python 3
@millerdev
millerdev / steps.md
Last active September 19, 2022 19:53
Upgrade to new version of PostgreSQL in docker
View steps.md

Upgrade to new version of Postgres in Docker

This example upgrades PostgreSQL 9.4 to 9.6. Substitute the versions you're upgrading to/from as needed below.

Dump all databases to a file

Run the following command to make a backup of all postgres data in a local file:

docker exec -i hqservice_postgres_1 pg_dumpall -U commcarehq | gzip > pg-backup.sql.gz
@millerdev
millerdev / generate-locations.py
Last active July 6, 2018 14:37
Generate XLSX file containing CommCare locations
View generate-locations.py
#! /usr/bin/env python
"""Generate XLSX file containing CommCare locations
Requires: pip install openpyxl==2.2.5
https://gist.github.com/millerdev/57a5c1363773a92d9ee6332e79789cd3
"""
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
@millerdev
millerdev / riak-vnode-check.py
Last active January 3, 2018 20:22
Check for distinct replicas on riak cluster nodes for a given n_val
View riak-vnode-check.py
#! /usr/bin/env python
"""
Check for replicas on distinct nodes within a riak cluster for a given n_val
https://gist.github.com/millerdev/b6f50640d5fc2519ae8c9c2de3c64af2
"""
import re
from argparse import ArgumentParser
from subprocess import check_output
View pglogslim.py
#! /usr/bin/env python3
# filter postgres logs to remove parameters of very large queries
#
# https://gist.github.com/millerdev/def20a42d78717174cd5722a9de2055a
import gzip
import re
import signal
import sys
# HACK prevent "BrokenPipeError: [Errno 32] Broken pipe" output on stderr
@millerdev
millerdev / git-flake8
Last active September 15, 2020 05:38
Run fake8 on lines changed in current branch
View git-flake8
#! /bin/bash
# https://gist.github.com/millerdev/e25014e4b886a5c619419d56b778a423
#
# Usage: git flake8 [refname] [flake8 options]
if [ "${1:0:1}" = "-" ]; then
BRANCH=origin/master
else
BRANCH=${1:-origin/master}
shift
fi