Skip to content

Instantly share code, notes, and snippets.

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

Michelle Steigerwalt Yuffster

🕳️
ᕕ( ᐛ ) ᕗ
View GitHub Profile
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,5,18,23,2153,2226,2229,2231,2236,2237,2237,2238,2238,2238,2238,2239,2242,2242,2243,2243,2246,2247,2247,2248,2250,2250,2250,2264,2283,2283,2283,2283,2283,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2284,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2285,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,2286,22
@Yuffster
Yuffster / kmeans.js
Created February 19, 2017 12:39
kmeans?
function kmeans(k, arr) {
var clusters = [];
var sorted = [...new Set(arr)].sort((a, b) => a - b);
var size = Math.abs(sorted.length/k);
for (var i = 0; sorted.length>0; i += size) {
if (sorted.length < size*2) size = size*2;
clusters.push(sorted.splice(0, size));
}
console.log(clusters.map((a) => JSON.stringify(a.sort((a, b) => a - b))));
var center = (a) => {
@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;