Skip to content

Instantly share code, notes, and snippets.

View morisy's full-sized avatar

Michael Morisy morisy

View GitHub Profile
@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.'" },
@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:

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).

"""
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
"""
#!/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:
@morisy
morisy / export_notes.py
Created March 19, 2021 15:05
Export notes from a given DocumentCloud document into a spreadsheet
import requests
import csv
from documentcloud import DocumentCloud # https://documentcloud.readthedocs.io/en/latest/gettingstarted.html#installation
# Install DocumentCloud Python Wrapper first: https://documentcloud.readthedocs.io/en/latest/index.html
USERNAME = input('Username: ')
PASSWORD = input('Password: ')
client = DocumentCloud(USERNAME, PASSWORD)
@morisy
morisy / Sample Output.json
Created August 28, 2019 18:53
Sample output from GovLens
{
"id": 2,
"name": "Traffic, Parking & Transportation",
"Website": "https: //www.cambridgema.gov/traffic",
"profile": {
"security_and_privacy": {
"https": {
"met_criteria": True,
"info": None
},
@morisy
morisy / Deputy Project Editor.md
Created June 19, 2017 19:53
Deputy Project Editor Opening

Deputy Project Editor – The Boston Globe Boston Globe Media Partners – Boston, MA

The Boston Globe is looking for an experienced journalist with strong editing and organizational skills to help direct the Globe’s investigative reporting and other long form projects, including the work of the Spotlight Team. This is a new position created as part of an expansion of the Globe’s long form journalism commitment, including additional investigative reporters and a new narrative desk. The deputy projects editor will directly supervise some investigative reporters and share oversight of projects throughout the newsroom. Candidates should have an excellent ability to visualize ambitious stories and to help guide reporters through the many challenges of project journalism, including fights over public records, data analysis and shaping the narrative. Please send a resume, cover letter and links to at least three projects you’ve worked on to Scott Allen, AME for Projects, at [email protected].

@morisy
morisy / Reset-LocalAccountPassword.ps1
Created March 8, 2017 01:54
This article presents a new script, Reset-LocalAccountPassword.ps1, which makes it easier and more secure to reset local account passwords on computers.
# Reset-LocalAccountPassword.ps1
# Written by Bill Stewart ([email protected])
#requires -version 2
<#
.SYNOPSIS
Resets the built-in Administrator account or a named local account password on one or more computers.
.DESCRIPTION
@morisy
morisy / delete_tweets.py
Created January 9, 2017 05:15 — forked from smortime/delete_tweets.py
Script to delete all of your tweets. Requires Python 3.x, Twython, and API keys.
#Schuyler Mortimer
from twython import Twython
import sys
#get from twitter developer site
APP_KEY = ''
APP_SECRET = ''
TOKEN = ''
TOKEN_SECRET = ''