Skip to content

Instantly share code, notes, and snippets.

View Yuffster's full-sized avatar
🕳️
ᕕ( ᐛ ) ᕗ

Michelle Steigerwalt Yuffster

🕳️
ᕕ( ᐛ ) ᕗ
View GitHub Profile
@Yuffster
Yuffster / scrape_morse.py
Created February 18, 2017 23:26
Morse Sample Scraper
from bs4 import BeautifulSoup
import requests
import os
def fetch(url):
if (url[0:4] != "http"):
url = 'http://www.arrl.org'+url
fname = url.split("/")[-1]
print("Fetching [{}] from {}".format(fname, url))
if os.path.isfile(fname):
{
let log = (str, styles) => {
styles = styles || {};
var args = [];
var active = [];
var flushed = true;
str = str.replace(/(?:(?:\[([^\]]+)\]|([^[]+)))/g, (a, b) => {
if (a.match(/^\[\//)) {
let changed = false;
function getSpeech(cb) {
if (!webkitSpeechRecognition) return false;
var recognition = new webkitSpeechRecognition();
recognition.interimResults = true;
recognition.onresult = (event) => {
var transcript = event.results[0][0].transcript;
cb(transcript);
}
recognition.start();
class UIState {
constructor(...selectors) {
this._selectors = {};
this._memoized = {};
this.__state = {};
for (let s of selectors) this.selectors = s;
}
bind(name) {
return (...a) => { this.update(name); };
}
var __contexts = 0; // Just for debugging.
class Context {
constructor(parent, transaction=false) {
this._data = {};
this._children = [];
this._parent = parent;
this._transaction = transaction;
this._revision = __contexts++;
}
@Yuffster
Yuffster / dictionary.js
Last active December 12, 2016 17:35
Common words -> Letter Frequency graph based dictionary.
(function() {
/**
* Lets you add words to a dictionary and then retrieve words
* based on a set of letters that you'd like to include.
*
* So you can be like, "Hey, I only know the letters E, T and A, what
* words can I spell?"
*
* The dict structure is a graph sorted on character frequency
@Yuffster
Yuffster / nato_sprites.js
Last active November 25, 2016 17:14
NATO alphabet with audio sprites.
class AlphabetGenerator {
constructor() {
this._playback_rate = 3;
this.audio = document.getElementById('nato-alphabet');
var my = this;
this.audio.addEventListener('loadeddata', function(ev) {
my.audioLoaded();
});
window.setTimeout(function update() {
class AlphabetGenerator {
constructor() {
const context_name = '_MORSE_AUDIO_CONTEXT'
var ac = window[context_name] || new window.AudioContext();
var an = ac.createAnalyser();
an.connect(ac.destination);
an.minDecibels = -140;
an.maxDecibels = 0;
this._audio_loaded = false;
@Yuffster
Yuffster / speech.js
Created November 24, 2016 03:08
Speech synthesis for a string by character.
class SpeechGenerator {
constructor() {
this._word_pause = 8;
this._char_pause = 8;
this._ready = false;
this._queued = [];
this._voice_index = 0;
this._rate = 1;
var my = this;
window.speechSynthesis.addEventListener('voiceschanged', function() {
@Yuffster
Yuffster / morse.js
Last active November 25, 2016 17:05
Morse code with WebAudio.
const MorseCodes = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",