Skip to content

Instantly share code, notes, and snippets.

View kylemcdonald's full-sized avatar

Kyle McDonald kylemcdonald

View GitHub Profile
@kylemcdonald
kylemcdonald / lease-answering.ipynb
Last active June 30, 2023 22:30
Notebook demonstrating the way that you ask GPT-3.5 a question changes the response. The function calling API performs the worst.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / function-calling.ipynb
Created June 14, 2023 01:10
Example of OpenAI function calling API to extract data from LAPD newsroom articles.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / accumulate-lapd.py
Created May 9, 2023 04:57
Accumulate LAPD roster totals by division, rank, etc.
import pandas as pd
from utils.list_files import list_files
mapping = {
'name': 'name',
'employeename': 'name',
'first name': 'first name',
'firstname': 'first name',
'last name': 'last name',
'lastname': 'last name',
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 8 columns, instead of 5 in line 4.
video name,name,duration,link,thumbnail,created_time,modified_time,release_time
Edwin Romero - LAPD Graduation,Edwin Romero,9,https://vimeo.com/820913028,https://i.vimeocdn.com/video/1662337989-c465c556a26a1239bf66df570c0d588a27ffe49fd4dfb27398e8ad08520bc973-d_1920x1080?r=pad,2023-04-25T14:34:12+00:00,2023-05-07T21:22:00+00:00,2023-04-25T14:34:12+00:00
Luciana Stearns - LAPD Graduation,Luciana Stearns,114,https://vimeo.com/786321915,https://i.vimeocdn.com/video/1580691589-bbcd7bee9c1b59476b2f6a9f1ee370ba47e2d583c7a38c8f8ad72ce771b4c02e-d_1920x1080?r=pad,2023-01-04T16:54:41+00:00,2023-05-07T21:41:04+00:00,2023-01-04T16:54:41+00:00
Ramiro Zuniga - LAPD Graduation,Ramiro Zuniga,117,https://vimeo.com/786322420,https://i.vimeocdn.com/video/1580691813-b922d241efc3c18712ed8a6134faf506e64e739003dfd2e24929411ad805c7c9-d_1920x1080?r=pad,2023-01-04T16:56:17+00:00,2023-05-07T21:40:57+00:00,2023-01-04T16:56:17+00:00
Herrera Ortega Lucio- LAPD Graduation,Herrera Ortega Lucio,167,https://vimeo.com/820913708,https://i.vimeoc
@kylemcdonald
kylemcdonald / download-cpra.py
Created January 17, 2023 08:51
Python script for downloading public CPRA documents.
import requests
import json
from itertools import count
import os
import sys
import urllib3
from multiprocessing.dummy import Pool
from tqdm import tqdm
from ratelimit import limits, sleep_and_retry
@kylemcdonald
kylemcdonald / tumbleword.py
Last active December 21, 2022 23:56
Tumbleword guidance.
"""
For Tumbleword by Jer Thorp
https://tumbleword.glitch.me/
"""
from collections import defaultdict
from time import time
import random
start_word = 'charade'
@kylemcdonald
kylemcdonald / Audio Normalizer.ipynb
Created November 16, 2022 07:59
Normalize audio based on local peaks.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / split.py
Created May 15, 2022 07:58
Split an audio file into multiple files given a list of timestamps exported from timestamps.me out of an Ableton set.
import subprocess
track_fn = 'audio.wav'
timestamps_fn = 'timestamps.csv'
with open(timestamps_fn) as f:
lines = f.read().splitlines()
lines = [e.split(',')[2] for e in lines]
cmd_string = 'ffmpeg -hide_banner -loglevel error -i {tr} -acodec copy -ss {st} -to {en} {nm}'
@kylemcdonald
kylemcdonald / compare.sh
Last active March 13, 2023 21:46
Python vs Node web3 speed comparison.
#!/bin/bash -x
python get_block_speed_sync_ipc.py
python get_block_speed_async_http.py
node get_block_speed_sync_ipc.js
python get_block_speed_sync_ipc_raw.py
node get_block_speed_async_ipc.js
@kylemcdonald
kylemcdonald / droplet-setup.md
Created September 14, 2021 04:26
Setting up a Digital Ocean droplet for node.js

Get the $IP from Digital Ocean and use the same $USERNAME as your main computer.

ssh root@$IP
adduser $USERNAME
usermod -aG sudo $USERNAME
ufw allow OpenSSH
ufw enable
rsync --archive --chown=$USERNAME:$USERNAME ~/.ssh /home/$USERNAME