Skip to content

Instantly share code, notes, and snippets.

case_search.py

There is a body of caselaw around TSA claims, such as George v. Rehiel (TSA). Using the PDF of this case, write a program that:

  • takes an string from the user [1]
  • searches the George v. Rehiel PDF for the string
  • prints the number of times the string occurs

[1] For full credit, you only need to accept unigrams (single words). If your program accepts bigrams (two word phrases) and trigrams (three word phrases), you will receive ten (10) points of extra credit.

tsa_claims.py

The TSA tracks passanger claims for things like lost property, personal injury, and damaged items. Using this spreadsheet of claims from 2014, write a program that prints out the total dollar value (the "Close Amount") of claims by each airline. You can style your output any way you'd like, but please make it as human readable as possible (e.g. don't just print out a big dictionary).

@batemapf
batemapf / scraping.py
Created March 29, 2018 01:54
Link Scraper
import requests
from bs4 import BeautifulSoup
# Set the variable `url` to a URL of your choice.
url = 'https://www.crummy.com/software/BeautifulSoup/bs4/doc/'
# Send a request to the URL and save what we get back in the variable `response`
response = requests.get(url)
# Get the raw text of the response. This will be a whole bunch of HTML.

Capstone project

Goal

To do something useful and/or fun with Python with a legal tie-in that demonstrates you have learned something and have the tools to continue your coding journey. For example:

  • Make your own functions
  • Choose your own legal adventure
  • Memo generator
@batemapf
batemapf / phillymapy.py
Created February 22, 2018 21:22
Philly Ward Mapper
import geojson
import geojsonio
import csv, os
# Requires mapshaper, a Node package. See https://github.com/mbloch/mapshaper/wiki/Introduction-to-the-Command-Line-Tool.
def load_map_data(filename):
with open(filename) as infile:
return geojson.loads(infile.read())
# Let's say we wanted to print an array of the strings "p" and "q" that is
# 10 wide by 10 tall that looks like this:
"""
p q q q q q q q q q
p q q q q q q q q q
p q q q q q q q q q
p q q q q q q q q q
p q q q q q q q q q
p q q q q q q q q q
p q q q q q q q q q
#! /usr/bin/env python
import requests
import os, json
import datetime as dt
class DataSet:
def __init__(self):
self.created = dt.datetime.now()
self.data = []
@batemapf
batemapf / GS_for_Holden.gs
Last active October 14, 2017 14:00
Holden's GAS
// The route to Holden.
var holden_route = 'https://yourdomain/api/_incoming'
// The URL location of the source workbook, as a string.
var source_wb_url = 'https://docs.google.com/spreadsheets/...'
// The SheetID value of the sheet within the source workbook that holds
// additional execution information, as a string.
var exec_sheet_id = '123456778'
// For testing purposes, an integer <= that represents the percentage of each workbook
// you wish to consume. 1 == 100%.
var hunger_level = 1
@batemapf
batemapf / API_Projects.md
Last active September 23, 2016 16:35 — forked from iros/API.md
Tock API Documentation Sample

Projects

To fetch a list of projects information.

  • URL

    /projects.json

  • Method:

import os
import json
from projects.models import Project
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
"""
For data structure:
[
{