Skip to content

Instantly share code, notes, and snippets.

View Uberi's full-sized avatar

Anthony Zhang Uberi

View GitHub Profile
import pyaudio, audioop
CHANNELS = 2
RATE = 44100
CHUNK = 4096
FORMAT = pyaudio.paInt16
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK)
sample_size = pyaudio.get_sample_size(FORMAT)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Uberi
Uberi / realtime-plot.py
Created April 25, 2015 02:10
Realtime plotting with Matplotlib.
#!/usr/bin/env python3
import time, random
import math
from collections import deque
start = time.time()
class RealtimePlot:
def __init__(self, axes, max_entries = 100):
@Uberi
Uberi / image_plot.py
Created November 13, 2014 02:32
Scatter plot the RGB values of an image in 3D! Requires Pillow and matplotlib, running on Python 3.
image_path = "HOPE.png"
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot
from PIL import Image
fig = pyplot.figure()
axis = fig.add_subplot(1, 1, 1, projection="3d") # 3D plot with scalar values in each axis
im = Image.open(image_path)
@Uberi
Uberi / Keri.html
Last active August 29, 2015 14:07
Keri.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WARR NEVER CHANGES</title>
<style>
body {
background: black;
overflow: hidden;
}
@Uberi
Uberi / markov-single-word.py
Created October 2, 2014 04:30
Run the previous `normalize.py` on FB chat data, then run this script on its output to get sentences generated using a Markov chain.
path = "normalized_data.json"
user = "Keri Warr"
import json, sys, re
import random
from collections import defaultdict
data = json.load(open(path, "r"))
START, END = 0, 1
@Uberi
Uberi / normalize.py
Last active August 29, 2015 14:07
FaceBook chat data processing helper script. Run `normalize.py` to normalize the raw JSON data into cleaner JSON, then run `process.py` to calculate some interesting stats.
path = "data.json"
new_path = "normalized_data.json"
from urllib.parse import urlparse, parse_qs
import json
users = {
"fbid:100001608518631": "Anthony Zhang",
"fbid:1538370516": "Keri Warr",
"fbid:814604197": "Daniel Hopper",