Skip to content

Instantly share code, notes, and snippets.

We can't make this file beautiful and searchable because it's too large.
name,titles,roles,locations,email
Whistleblower Hotline,hotline@rvaschools.net,Faculty & Staff,,hotline@rvaschools.net
Kayla Aaron,Teacher,Faculty & Staff,Ginter Park Elementary,kaaron@rvaschools.net
Tania Abayomi,,Faculty & Staff,Linwood Holton Elementary,tabayomi@rvaschools.net
Hannah Abbey,Mental Health Contractor,Faculty & Staff,Huguenot High School,habbey.contractor@rvaschools.net
Kiera Abdelkader,Coach,Faculty & Staff,"Boushall Middle School, River City Middle School",kriddick@rvaschools.net
Mohammed Fahmy Abdelrazele,HS English Teacher,Faculty & Staff,Rich Academy formerly CCP,mabdelraze.contractor@rvaschools.net
Juvenal Abrego meneses,Principal Iii,Faculty & Staff,Cardinal Elementary School,jabrego@rvaschools.net
Elena Acevedo,Teacher,Faculty & Staff,George W. Carver Elementary,eacevedo@rvaschools.net
Mary Ackerly,Teacher 200 Days - Henry Marsh,Faculty & Staff,,mackerly@rvaschools.net
@jmcarp
jmcarp / postgres_count_estimate.py
Last active July 13, 2023 19:24
Approximate query count with PostgreSQL and SQLAlchemy
"""Approximate query count based on ANALYZE output for PostgreSQL and SQLAlchemy.
Count logic borrowed from https://wiki.postgresql.org/wiki/Count_estimate
ANALYZE borrowed from https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Explain
"""
import re
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement, _literal_as_text
@jmcarp
jmcarp / pdfxtract.py
Last active March 30, 2023 03:07
Extract text from PDF document using PDFMiner
"""
Extract PDF text using PDFMiner. Adapted from
http://stackoverflow.com/questions/5725278/python-help-using-pdfminer-as-a-library
"""
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter#process_pdf
from pdfminer.pdfpage import PDFPage
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
@jmcarp
jmcarp / forceDownload.js
Created March 1, 2014 15:35
Forcing a file download in JavaScript
function forceDownload(href) {
var anchor = document.createElement('a');
anchor.href = href;
anchor.download = href;
document.body.appendChild(anchor);
anchor.click();
}
@jmcarp
jmcarp / prepare.sh
Last active May 24, 2020 20:10
every-lot-cville
#!/bin/bash
set -euo pipefail
rm -f parcels.db
curl -O https://widget.charlottesville.org/gis/zip_download/parcel_area.zip
unzip parcel_area.zip
layer=$(ogrinfo parcel_area_*.shp | grep '1: ' | awk '{print $2}')
@jmcarp
jmcarp / gisweb.py
Last active May 23, 2020 23:09
gisweb-screenshots
import json
import fiona
import requests
def get_map(base_url, parcel_id, out_path, bbox_scale_factor=1.25):
parcel_id_clean = parcel_id.replace("-", "")
state = {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import datetime
import collections
import pytest

Optimizing badge performance

Before proposing possible solutions, here are a few questions I would ask if this were more than an exercise:

  • The badge endpoint uses the pyramid app, the sql backend (authorization, block list), and the elastic backend (search). Which commponent(s) take up the most time or are most challenging to scale?
    • For the purpose of the exercise, I'll assume the slowest/most expensive comopnent is elastic.
  • What are the current and anticipated costs of the badge endpoint under the status quo? Would the cost of additional complexity (e.g. learning a new database, web framework, or programming paradigm) outweigh the savings from buying more servers?
    • I'll assume that cloud infrastructure is cheap and developer time expensive, and lean toward keeping things simple rather than maximizing performance.
  • What's the hypothesized value-add of the badge feature, and how can we test that hypothesis?
    • Does the badge make users more likely to view or create annotations?
  • Does A/B tes
@jmcarp
jmcarp / marshmodel.py
Last active March 5, 2018 01:45
marshmallow-models
import six
import inflection
import marshmallow as ma
class Model(object):
def __init__(self, **kwargs):
self._schema = self.Schema()
self.load(**kwargs)
@jmcarp
jmcarp / merge.rb
Created March 8, 2017 00:18
template-pipeline
#!/usr/bin/env ruby
require 'erb'
require 'yaml'
inputs = ARGV
template = ERB.new(File.read('pipeline.yml.erb'))
b = binding