Skip to content

Instantly share code, notes, and snippets.

View gartenfeld's full-sized avatar

David Rosson gartenfeld

View GitHub Profile
@gartenfeld
gartenfeld / readline.js
Created November 26, 2017 12:45
Read a file one line at a time
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const FILE_PATH = path.resolve(__dirname, '../data/ingest_test.txt');
const stream = fs.createReadStream(FILE_PATH);
const interface = readline.createInterface({ input: stream });
interface.on('line', processLine);
interface.on('close', () => console.log("\nDone!"));
@gartenfeld
gartenfeld / app.js
Created March 21, 2017 20:50 — forked from Turbo87/app.js
webpack + font-awesome test
require('font-awesome/css/font-awesome.css');
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>';
<a href="data:text/plain;charset=utf-8;base64,Zm9vIGJhcg==">Data as URI</a>

Install MacPorts

Optionally update MacPorts sudo port selfupdate

Download the port tree of HFST

  • Unpack the port tree
  • Add the port tree dir file:///.../hfst-macport/ to /opt/local/etc/macports/sources.conf
  • sudo port install hfst
@gartenfeld
gartenfeld / drag_and_drop_files.js
Created October 21, 2016 22:10
Drag and Drop Files
var element = $('#drop-area')[0];
var callback = function onFileDrop() {
var filenames = event.target.result;
};
function droppable(element, callback) {
element.addEventListener('dragover', function onDrag(event) {
event.stopPropagation();
event.preventDefault();
@gartenfeld
gartenfeld / centering.css
Created September 27, 2016 01:00
Centering without Flexbox
// Add full screen wrapper
.box {
top: 50%;
left: 50%;
margin: 0;
position: absolute;
transform: translate(-50%, -50%);
}
@gartenfeld
gartenfeld / fallback.sh
Created September 9, 2016 21:10
Shell Fallback with Error-Muting
# 2 represents stderr
# 2> redirects stderr (to /dev/null mutes error output)
# || runs the second command only if the first one fails
alias gcm='git checkout maybe 2> /dev/null || git checkout master'
@gartenfeld
gartenfeld / pubsub.js
Created September 9, 2016 19:18
A minimal PubSub
(function($) {
if (!$ || typeof $.extend !== 'function') {
console.info("No jQuery found. Plugin did not mount.");
return;
}
var _cache = {};
/**
@gartenfeld
gartenfeld / batch_convert.sh
Last active June 19, 2016 16:06
Batch Convert Script
for file in <DIR>/*.ogg; do
dest="converted/${file[@]/%ogg/mp3}"
ffmpeg -hide_banner -i "$file" -qscale:a 4 -acodec libmp3lame $dest
done
@gartenfeld
gartenfeld / syllable_frequency.txt
Created June 16, 2016 19:24
Frequency of Syllables in English
ðə 23038047
ə 18735224
ˈtu 12418461
ˈænd 11260533
ˈʌv 10968008
ɪn 10738928
li 5689929
ˈðæt 5416929
ˈaɪ 4683241
ˈfɔr 4678692