Add grepdict, and make toys official

This commit is contained in:
Neale Pickett 2019-10-05 19:49:01 -06:00
parent e088ed6981
commit 75ddfc8c52
6 changed files with 99235 additions and 1 deletions

View File

@ -31,9 +31,9 @@
<footer> <footer>
<nav class="left"> <nav class="left">
<ul> <ul>
<li><a href="{{ '/' | relative_url }}" title="Homepage">Home</a></li>
<li><a href="{{ '/tartans/' | relative_url }}" title="AKA Plaids">Tartans</a></li> <li><a href="{{ '/tartans/' | relative_url }}" title="AKA Plaids">Tartans</a></li>
<li><a href="{{ '/papers/' | relative_url }}" title="Various writings">Papers</a></li> <li><a href="{{ '/papers/' | relative_url }}" title="Various writings">Papers</a></li>
<li><a href="{{ '/toys/' | relative_url }}" title="Dumb apps">Toys</a></li>
</ul> </ul>
</nav> </nav>
<nav class="right"> <nav class="right">

3
run.sh Executable file
View File

@ -0,0 +1,3 @@
#! /bin/sh
docker run --rm --net=host -v $(pwd):/srv/jekyll -u $(id -u):$(id -g) jekyll/jekyll:minimal /usr/gem/bin/jekyll s --host 0

45
toys/grepdict/grepdict.js Normal file
View File

@ -0,0 +1,45 @@
// jshint asi:true
var words
function addWords(wl) {
words = wl.split("\n")
let re = document.querySelector("#regexp")
re.value = ""
re.disabled = false
re.focus()
}
function regexInput(e) {
let re = new RegExp(e.target.value, "ui")
let matches = document.querySelector("#matches")
while (matches.firstChild) {
matches.firstChild.remove()
}
let nmatches = 0
for (let word of words) {
if (word.match(re)) {
let li = matches.appendChild(document.createElement("li"))
li.textContent = word
nmatches += 1
if (nmatches > 50) {
li.textContent = "…"
break
}
}
}
}
function init(e) {
fetch("words.txt")
.then(r => r.text())
.then(addWords)
document.querySelector("#regexp").addEventListener("input", regexInput)
}
window.addEventListener("load", init)

14
toys/grepdict/index.md Normal file
View File

@ -0,0 +1,14 @@
---
title: Grep Dict
scripts:
- grepdict.js
---
Ever wanted to run `grep` on `/usr/share/dict/words`,
but you only have a phone?
Me too.
<label for="regexp">Match Regex</label>:
<input id="regexp" type="search" disabled="true" value="loading...">
<ul id="matches"></ul>

99171
toys/grepdict/words.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ Here is some various junk I've done. Maybe you'll find it amusing.
Maybe you'll just wonder why I spend so much time on this garbage. Maybe you'll just wonder why I spend so much time on this garbage.
* [Starship Noise Generator](starship/) * [Starship Noise Generator](starship/)
* [Grep Dict](grepdict/) runs `grep` on `/usr/share/dict/words`; perfect for cheating on crossword puzzles
* If you need to write someone a letter but really don't want to, try my * If you need to write someone a letter but really don't want to, try my
[social letter generator](letter.html) [social letter generator](letter.html)
* [Crunt](crunt.html) * [Crunt](crunt.html)