This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MV_AVG_H | |
#define MV_AVG_H | |
typedef struct { | |
double average; | |
size_t oldest_index; | |
double *samples; | |
size_t num_samples; | |
} movingAverage_t; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use gcc as the compiler | |
CC=gcc | |
visualizer: simple_visualizer.c libapa102.a moving_average.c | |
$(CC) -I/usr/local/include -L/usr/local/lib -L./libapa102 -I./libapa102/lib -o visualizer simple_visualizer.c moving_average.c -lapa102 -lwiringPi -lpthread -ljack -lm | |
libapa102.a: ~/visualizer/libapa102/lib/build/apa102.o ~/visualizer/libapa102/lib/build/apa102_anim.o | |
ar rcs $@ $^ | |
~/visualizer/libapa102/lib/build/apa102.o: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'' : ..., | |
'he': ..., | |
'th': { | |
occurances: ['e', 'i', 'u', ...], | |
e: 582, | |
i: 226, | |
u: 56, | |
... | |
total: 1692 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createChain(words) { | |
chain = {}; | |
for (const word of words) { | |
addWordToChain(chain, word); | |
} | |
return chain; | |
} | |
/* | |
* Example: Adding "beat" to the chain will |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomWord(chain, length) { | |
// get initial prefix | |
word = randomOccurance(chain, ''); | |
for (var i = 0; i < length - 2; i++) { | |
lastTwoLetters = word.substr(-2); | |
// restart if chain hits dead end | |
if (chain[lastTwoLetters] == undefined) { | |
return randomWord(chain, length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const alph = 'abcdefghijklmnopqrstuvwxyz' | |
demo(); | |
function demo() { | |
try { | |
var fileContents = fs.readFileSync('./dictionary.txt', 'utf8'); | |
} catch(err) { | |
throw "Dictionary file does not exist"; |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A | |
A's | |
AMD | |
AMD's | |
AOL | |
AOL's | |
Aachen | |
Aachen's | |
Aaliyah | |
Aaliyah's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const alph = 'abcdefghijklmnopqrstuvwxyz' | |
try { | |
var fileContents = fs.readFileSync('./dictionary.txt', 'utf8'); | |
} catch(err) { | |
throw "Dictionary file does not exist"; | |
} | |
var words = fileContents.split('\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
html { | |
font-family: Arial; | |
} | |
.shorten-output { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
html { | |
font-family: Arial; | |
} | |
.shorten-options { | |
position: absolute; |