Skip to content

Instantly share code, notes, and snippets.

import requests
import os
select_url = raw_input("Which Tock API endpoint would you like to access? Type the number that corresponds with your choice:\n 1 = ...projects.json \n 2 = ...timecards_bulk.csv \n 3 = ...users.json \n \n >>>")
print "Gathering data..."
if select_url == "1":
url = "https://tock.18f.gov/api/projects.json"
fmt = "json"
elif select_url == "2":
url = "https://tock.18f.gov/api/timecards_bulk.csv"
fmt = "csv"

tock

We use Tock to track our time. You can read more about Tock in this blog post about its features.

Build Status

Screenshot of Tock

Getting Started

import json
import datetime
from random import randint
from django.contrib.auth.models import User
from employees.models import EmployeeGrade
def create_obj():
objects = User.objects.filter()
for o in objects:
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:
[
{
@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:

@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
#! /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 = []
# 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
@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())

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