Skip to content

Instantly share code, notes, and snippets.


Jackie Kazil jackiekazil

View GitHub Profile
jackiekazil /
Created Aug 21, 2012
Simple demo of map_xml feature of pymarc library & comparing country value in folder of marc xml to records in django db
Demo of an implementation of the pymarc library found here:
What does this script do?
Returns a list of country counts in a folder of Marc xml records &
coorsponding records that exist in the current database. This is used to help
understand how close the Marc xml records are to the existing ChronAm dataset.
To run this file: python $path_to_bib_folder
jackiekazil / pre-commit
Created Oct 15, 2012 — forked from spulec/pre-commit
Yipit Pre-commit Hook
View pre-commit
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
An alternative Django ``TEST_RUNNER`` which uses unittest2 test discovery from
a base path specified in settings, rather than requiring all tests to be in
``tests`` module of an app.
If you just run ``./ test``, it'll discover and run all tests
underneath the ``TEST_DISCOVERY_ROOT`` setting (a path). If you run
``./ test``, it'll run the tests in
that module (you can also pass multiple modules).
jackiekazil /
Last active Oct 31, 2021
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

jackiekazil /
Last active Jun 29, 2021
How do I identify what is on my python path (where python looks to import modules)?

What is on my python path?

Knowning where python is trying to find files is important.

Let's say try to import a module and you get an Import Error.

Like this:

>>>  import foo
jackiekazil /
Last active Dec 29, 2015
Python example on how to extract data from USDA.
import requests
import sys
key = sys.argv[1]
base = ''
url = '%s?api_key=%s' % (base, key)
response = requests.get(url)
print response.json()
jackiekazil / postgis_hb_error
Created Apr 5, 2014
Problem installing gdal & postgis with homebrew -- configure: error: could not find proj_api.h
View postgis_hb_error
jkazil@jlk:~ $ brew install postgis
==> Installing dependencies for postgis: liblwgeom, gdal
==> Installing postgis dependency: liblwgeom
==> Downloading
Already downloaded: /Library/Caches/Homebrew/liblwgeom-2.1.1.tar.gz
==> Downloading
Already downloaded: /Library/Caches/Homebrew/liblwgeom--patch-3d93c9ede79439f1c683a604f9d906f5c788c690.diff
==> Patching
patching file
==> ./
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
import csv
import sys
import requests
jackiekazil / foia-core-setup
Last active Aug 29, 2015
foia-core setup
View foia-core-setup
Project setup
clone repo
brew install python3
mkvirtualenv --python=/usr/local/bin/python3 foia-core
cd ~/Project/code/foia/foia-core
View gist:46c27fd2e73228322078