Skip to content

Instantly share code, notes, and snippets.

@corpit
corpit / upc_check_digit.py
Created January 1, 2014 02:59
Calculate UPC-A check digit in Python
def add_check_digit(upc_str):
"""
Returns a 12 digit upc-a string from an 11-digit upc-a string by adding
a check digit
>>> add_check_digit('02345600007')
'023456000073'
>>> add_check_digit('21234567899')
'212345678992'
>>> add_check_digit('04210000526')
@christophergandrud
christophergandrud / leg_violence_predict.R
Created April 26, 2012 21:29
Predict probability graphs with zelig and ggplot2
####################
# Create relogit predicted probabilities using Zelig and ggplot2
# Two Sword Lengths: Losers' Consent and Violence in National Legislatures (Working Paper 2012)
# Christopher Gandrud
# Updated 26 April 2012
###################
## Load required packages
library(RCurl)
library(Zelig)