Skip to content

Instantly share code, notes, and snippets.

View amundo's full-sized avatar
🗿
khagga

Patrick Hall amundo

🗿
khagga
  • Massachusetts
  • 21:16 (UTC -12:00)
View GitHub Profile
@amundo
amundo / futz.py
Created March 11, 2014 05:31
futzing with python encodings.
>>> some_ethiopic = [u"\u1234", u"\u1235", u"\u1236"]
>>> for s in some_ethiopic:
... print s, unicodedata.name(s)
...
ሴ ETHIOPIC SYLLABLE SEE
ስ ETHIOPIC SYLLABLE SE
ሶ ETHIOPIC SYLLABLE SO
>>> # ok, now we want to put these in a dictionary:
... names = {}
>>> for s in some_ethiopic: names[s] = unicodedata.name(s)
@amundo
amundo / depunctuate.py
Last active August 29, 2015 13:57
A simple depunctuator with and without regexes
def depunctuate(raw, badletters):
"""
return a copy of the string raw with all of
badletters removed
"""
fixed = ''
for letter in raw:
if letter not in badletters:
fixed += letter
return fixed
@amundo
amundo / a2audio.js
Created March 19, 2014 17:16
JS function to change links like <a href="something.wav">sound</a> so that they play when clicked
/*
There are a lot of pages like:
http://titus.uni-frankfurt.de/ld/
Which have links to .wav files. It's annoying to have to change
context, load "QuickTime", blah blah, and to lose the context
of the name of the link when you're listening to it.
The following function creates an Audio object which plays when
cat sections/[0-6]_*.txt > masters.txt
#cat sections/[3]_*.txt > masters.txt
<!doctype html>
<html>
<head>
<title>page</title>
<meta charset=utf-8>
</head>
<body>
<div id="airplane">
<form class="col-md-8 form-horizontal">
@amundo
amundo / index.html
Last active August 29, 2015 14:00 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
rect {
stroke: #fff;
}
</style>
<body>
@amundo
amundo / .gitignore
Last active August 29, 2015 14:01 — forked from mbostock/.block
Oaxaca map
build
node_modules
.DS_Store
@amundo
amundo / count.js
Last active August 29, 2015 14:07
counting things in javascript
var count = function (sequence) {
return sequence.reduce(function (tally, item) {
if (!(item in tally)) {
tally[item] = 0
}
tally[item] += 1;
return tally
}, {
})
}
@amundo
amundo / emitterless.md
Created November 2, 2014 20:23
Do we really need an event emitter?

A ton of libraries out there model “event emitting”:

https://github.com/HenrikJoreteg/wildemitter

These libraries all allow us to create some sort of emitter object on which we can register and trigger custom events.

I’m not sure I get it.

It seems that everyone is shoving this emitter into the global namespace (if it’s used all over an app, no big whoop). So if that’s the case, what do we need an emitter for at all? We can just run addEventListener and dispatchEvent wherever we need to, and those events will be attached to window. (I’m talking browser here, I don’t speak node.)

@amundo
amundo / find.js
Created February 23, 2015 02:19
poor man's dom selection
function find(selector, scope) {
var matches = (scope || document).querySelectorAll(selector);
if (matches.length == 1) {
return matches
} else {
return [].slice.call(matches)
}
}