Skip to content

Instantly share code, notes, and snippets.

View morisy's full-sized avatar

Michael Morisy morisy

View GitHub Profile
#!/usr/bin/env python2
# -- coding: utf-8 --
import requests
import json
import csv
# Step 1: Create a file "file_with_agencies.csv" and add the agency IDs you want to file with in it, one per line. You can use 248 and 21983 as test agencies. You do not normally need to modify the following line. Filing with test agencies will deduct requests from your account, but if you reach out we can refund those requests or you can cancel them yourself within 30 minutes.
with open('file_with_agencies.csv', 'rb') as f:
"""
file: proj_get_doc_urls.py
what: script to download all the PDFs from a specified project
To use, install the python DocumentCloud wrapper (often using `pip install documentcloud` from the command line will do), and then run this script from the directory you want to save your files to.
Read more about the DocumentCloud Python Wrapper here:
https://documentcloud.readthedocs.io/en/latest/index.html
"""

Solr Database Expert to Help Optimize and Implement New Feature

Background

We are a non-profit organization that helps newsrooms, researchers, and public interest organizations host and share primary source documents. On the backend, we currently have 7.8 million documents, 131 million pages of searchable text, and 600 thousand individual shared notes in our database on production.

Each document has a somewhat complex permission system, which allows a document be set to private (only the owner can see it), shared (other members of their organization can see it), or public (publicly viewable and searchable), as well as a secondary set of permissions that allow documents to be added to project collections that also can grant access.

Users can put in a search on a centralized search bar that will parse through all of our documents and return matches that the user has permission to (if a person is not logged in, they can search through all public documents and get relevant results).

@morisy
morisy / Cranberry-mojito.txt
Created December 4, 2022 22:43
Cranberry Mojito Recipe
Yes, there is a variation of a mojito that uses peppermint and cranberry. This cocktail is similar to a traditional mojito, but it uses peppermint schnapps and cranberry juice instead of mint leaves and white rum. To make a peppermint cranberry mojito, you will need the following ingredients:
1 1/2 ounces of peppermint schnapps
2 ounces of cranberry juice
1 lime, cut into wedges
1 tablespoon of sugar
1 cup of ice
Sparkling water
Here is how to make a peppermint cranberry mojito:
@morisy
morisy / Code.gs
Created March 26, 2023 19:12
Google Sheets Open AI Apps Script
const SECRET_KEY = "OPEN AI API KEY GO HERE";
const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;
function GPT3(prompt, temperature = 0.4, model = "gpt-3.5-turbo") {
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: model,
messages: [
{ role: "system", content: "Instruct the AI what you want it to do with the input here, such as 'Summarize the text as a haiku' or 'extract the first address you see or otherwise respond none.'" },