Skip to content

Instantly share code, notes, and snippets.

View leoauri's full-sized avatar

Leo Auri leoauri

View GitHub Profile
@drscotthawley
drscotthawley / oscilloscope.py
Last active May 3, 2023 19:02
Realtime oscilloscope in 20 lines of Python, via soundcard & OpenCV
import numpy as np
import cv2
import soundcard as sc # Get it from https://github.com/bastibe/SoundCard
imWidth, imHeight = 1024, 512 # screen size
def draw_wave(screen, mono_audio, xs, title="oscilloscope", gain=5):
screen *= 0 # clear the screen
ys = imHeight/2*(1 - np.clip( gain * mono_audio[0:len(xs)], -1, 1)) # the y-values of the waveform
pts = np.array(list(zip(xs,ys))).astype(np.int) # pair up xs & ys
cv2.polylines(screen,[pts],False,(0,255,0)) # connect points w/ lines
cv2.imshow(title, screen) # show what we've got
@Huluk
Huluk / gist:5117702
Last active December 8, 2023 22:34
Open Files with Terminal Vim by default [mac, iterm]
If you want your terminal vim to open files you double click, follow the following steps (MacOS only):
1. Open Automator
2. Select Application
3. Copy the attached file
4. Save and set as default for opening files
Multiple files are opened in vim tabs.
If there is already a vim instance running, files are opened in it.