Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle McDonald kylemcdonald

View GitHub Profile
@kylemcdonald
kylemcdonald / dtw_mse.py
Last active Apr 12, 2021
DTW MSE numba function for use with UMAP.
View dtw_mse.py
# based on https://github.com/kylerbrown/ezdtw
# with modifications to be fully njit-able
import numpy as np
from numba import njit
@njit
def sqeuclidean(a, b):
return np.sum((a - b)**2)
@kylemcdonald
kylemcdonald / Collect Parler Metadata.ipynb
Last active Apr 10, 2021
Collect video URLs and GPS data for Parler videos.
View Collect Parler Metadata.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / ACAI (PyTorch).ipynb
Last active Apr 9, 2021
PyTorch ACAI (1807.07543).
View ACAI (PyTorch).ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / ffmpeg_load_audio.py
Last active Apr 7, 2021
Load audio from ffmpeg into Python using numpy.
View ffmpeg_load_audio.py
import numpy as np
import subprocess as sp
import os
DEVNULL = open(os.devnull, 'w')
# load_audio can not detect the input type
def ffmpeg_load_audio(filename, sr=44100, mono=False, normalize=True, in_type=np.int16, out_type=np.float32):
channels = 1 if mono else 2
format_strings = {
np.float64: 'f64le',
@kylemcdonald
kylemcdonald / three.js.shader.html
Last active Mar 28, 2021
Minimal three.js shader example.
View three.js.shader.html
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
overflow: hidden;
}
@kylemcdonald
kylemcdonald / showarray.py
Created Jan 3, 2016
Minimal code for rendering a numpy array as an image in a Jupyter notebook in memory. Borrowed from the Deep Dream notebook.
View showarray.py
import PIL.Image
from cStringIO import StringIO
import IPython.display
import numpy as np
def showarray(a, fmt='png'):
a = np.uint8(a)
f = StringIO()
PIL.Image.fromarray(a).save(f, fmt)
IPython.display.display(IPython.display.Image(data=f.getvalue()))
@kylemcdonald
kylemcdonald / matplotlib Border Removal.ipynb
Last active Mar 12, 2021
How to (mostly) remove all borders and padding with matplotlib.
View matplotlib Border Removal.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / cycloid.cpp
Last active Mar 8, 2021
Reconstructing cyclo. id#00 by Carsten Nicolai & Ryoji Ikeda with openFrameworks.
View cycloid.cpp
// download cycolid.wav with:
// $ wget -O cycloid.mp4 "https://vimeo.com/73860675/download?t=1446320826&v=187839750&s=46dcfa8c1c9ed3539dcc260443df6da08032ee60796f781df237bb6957cb8138"
// $ ffmpeg -i cycloid.mp4 cycloid.wav
#include "ofMain.h"
#include "ofxAudioDecoder.h"
class ofApp : public ofBaseApp {
public:
ofxAudioDecoder audio;
@kylemcdonald
kylemcdonald / parler-video.md
Last active Mar 4, 2021
How to view a video on Parler.
View parler-video.md

How to view a video on Parler

Let's say you have a video ID, like wfy02V209EwU taken from this map

The link for the video kiBnNejo0JW0 is at https://video.parler.com/ki/Bn/kiBnNejo0JW0. Notice that the link is: https://video.parler.com/ followed by the first two characters of the video ID, then /, then the next two characters, another /, and the video ID.

But if you click on this, you will get an error.

This is because the Parler video servers are still running (as of January 12) but the Domain Name System (DNS) is not running.

@kylemcdonald
kylemcdonald / _tsne.pdf
Last active Feb 28, 2021
Exploring antonyms with word2vec.
View _tsne.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.