Skip to content

Instantly share code, notes, and snippets.

Kyle McDonald kylemcdonald

View GitHub Profile
@kylemcdonald
kylemcdonald / index.html
Last active May 22, 2020
Minimal example of uploading a webcam image to a Flask server.
View index.html
<html>
<head>
<title>Webcam Upload</title>
<style>
html, body {
height: 100%;
}
* {
font-family: sans-serif;
user-select: none;
@kylemcdonald
kylemcdonald / capture_fast.cpp
Last active May 21, 2020
Try to capture from arducam on RPI as fast as possible.
View capture_fast.cpp
#include "arducam_mipicamera.h"
#include <linux/v4l2-controls.h>
#include <stdio.h>
#include <sys/time.h>
void capture_image(CAMERA_INSTANCE camera_instance) {
IMAGE_FORMAT fmt = {IMAGE_ENCODING_RAW_BAYER, 0};
BUFFER *buffer = arducam_capture(camera_instance, &fmt, 6000);
arducam_release_buffer(buffer);
}
View two-chords.md

At 0:37 into this track generated by a machine learning algorithm, there are two high-pitched bell-like very jazzy chords that arpeggiate from the higher to the lower notes.

The rest of the track is Cm, and my best guess for these chords is:

  1. Db Eb F Ab Bb (Db69)
  2. Eb F G Bb (Ebadd9)
@kylemcdonald
kylemcdonald / ripple.ipynb
Last active Mar 2, 2020
Ripple tank simulations in PyTorch based on https://github.com/jsbarbosa/rippleTank
View ripple.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / youtube-batch-search.py
Created Jan 18, 2020
Search YouTube for results using a newline separated list of queries.
View youtube-batch-search.py
import json
import googleapiclient.discovery
query_fn = 'queries.txt'
api_key = '' # insert API key here
# https://developers.google.com/youtube/v3/docs/search/list
params = {
'videoDuration': 'short', # any long medium short
'videoDefinition': 'any', # high standard
'order': 'viewCount', # date rating relevance title viewCount
View keybase.txt
### Keybase proof
I hereby claim:
* I am kylemcdonald on github.
* I am kylemcdonald (https://keybase.io/kylemcdonald) on keybase.
* I have a public key whose fingerprint is AAD2 D2E7 28AF 5533 86B6 3209 8F40 5F0E D0DE 80FF
To claim this, I am signing this object:
@kylemcdonald
kylemcdonald / a2-collections.py
Last active Oct 14, 2019
List a2p collections.
View a2-collections.py
from urllib.request import urlopen
import json
from multiprocessing import Pool
traders = json.load(urlopen('https://a2p.bitmark.com/s/api/traders'))
id_to_alias = {}
tasks = []
for trader in traders['traders']:
id = trader['id']
id_to_alias[id] = trader['alias']
@kylemcdonald
kylemcdonald / Interprocess Queue Performance.ipynb
Created Sep 8, 2019
Testing the performance of Queue-based IPC in Python 3.7.
View Interprocess Queue Performance.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / threaded-worker.py
Created Aug 29, 2019
Example of multithreaded/multiprocess workers in Python.
View threaded-worker.py
from multiprocessing import Process as WorkerType
# uncomment this line to try multithreading instead
# from threading import Thread as WorkerType
from multiprocessing import Queue
from time import sleep
def job_loop(id, q):
print(id, 'ready')
@kylemcdonald
kylemcdonald / Line Segment Intersection.ipynb
Created Jul 2, 2019
Python Line Segment Intersection example.
View Line Segment Intersection.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.