Skip to content

Instantly share code, notes, and snippets.

View notwa's full-sized avatar
🚲
bikeshedding

Connor notwa

🚲
bikeshedding
View GitHub Profile
// ==UserScript==
// @name YouTube audio compressor
// @namespace https://eaguru.guru/
// @version 0.5.2
// @description Adds an audio compressor option to YouTube videos. Now with over-engineering! Based on code by Vivelin and Wareya.
// @author notwa
// @match https://*.youtube.com/*
// @updateURL https://gist.github.com/notwa/9b8466b0c2ca48d756afcd02a5e43739/raw/YouTube%2520audio%2520compressor.user.js
// @run-at document-idle
// @grant none
@notwa
notwa / huffman.py
Last active October 21, 2020 18:46 — forked from mreid/huffman.py
Example implementation of Huffman coding in Python
# Example Huffman coding implementation
# Distributions are represented as dictionaries of { 'symbol': probability }
# Codes are dictionaries too: { 'symbol': 'codeword' }
def huffman(p):
'''Return a Huffman code for an ensemble with distribution p.'''
# Base case of only two symbols, assign 0 or 1 arbitrarily
if len(p) == 2:
return dict(zip(p.keys(), ['0', '1']))