Skip to content

Instantly share code, notes, and snippets.

View millerdev's full-sized avatar

Daniel Miller millerdev

  • Dimagi, Inc.
View GitHub Profile
@millerdev
millerdev / lis.txt
Last active August 29, 2015 14:00
Lis - lisp dialect with semantic whitespace
define sum term a next b
define iter a result
if
> a b
result
iter
next a
+
term a
result
@millerdev
millerdev / git-pr
Last active August 29, 2015 14:02
git pr - Fetch GitHub pull request to a new branch
#! /bin/bash
if [ -z "$1" ]; then
echo "Fetch GitHub pull request to a new branch"
echo ""
echo "usage: git pr PULL_REQUEST_NUMBER [BRANCH_NAME]"
exit;
fi
pr_num="$1"
if [ -z "$2" ]; then
from dimagi.ext.couchdbkit import (
Document,
DocumentSchema,
DictProperty,
IntegerProperty,
StringProperty,
)
class BlobMeta(DocumentSchema):
content_type = StringProperty()

error_on_load column loader strategy for marking column properties that should not be loaded.

It is similar to the deferred loader strategy, but causes an exception to be raised if a column would be loaded by a subsequent (deferred) query. Use error_on_load(k) instead of defer(k) to construct a query option that will cause an exception if an attempt is made to load column k.

This is handy when constructing a query with deferred columns (to optimize load time). It will cause an exception to be raised in your program instead of causing dramatic slowdown due to many deferred-load queries when you accidentally marked a column as deferred that should be loaded eagerly. Fail early.

@millerdev
millerdev / FogBugz_Timesheet_Hours.user.js
Last active May 31, 2017 18:27
A Greasemonkey script to calculate and display hours logged on FogBugz timesheet popup.
// ==UserScript==
// @name FogBugz Timesheet Hours
// @namespace fb-ts-hours
// @description Calculate and display hours worked on FogBugz timesheet popup.
// https://gist.github.com/millerdev/96c9b824b8902d4a5c19
// @include http://manage.dimagi.com/*
// @include https://manage.dimagi.com/*
// @version 1
// @grant none
// @run-at document-start
#! /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 / riak-vnode-check.py
Last active January 3, 2018 20:22
Check for distinct replicas on riak cluster nodes for a given n_val
#! /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
@millerdev
millerdev / generate-locations.py
Last active July 6, 2018 14:37
Generate XLSX file containing CommCare locations
#! /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 / delete_gmail.py
Last active July 1, 2019 17:40
Permanently bulk-delete messages from gmail
#! /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 / rm-future.py
Last active August 23, 2019 15:44
Remove __future__ imports from Python files
#! /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
"""