Skip to content

Instantly share code, notes, and snippets.

View MichaelPaulukonis's full-sized avatar

Michael Paulukonis MichaelPaulukonis

View GitHub Profile
@MichaelPaulukonis
MichaelPaulukonis / zipper.js
Created February 27, 2017 19:56
renames and zips recursive files
'use strict';
// https://gist.github.com/VinGarcia/ba278b9460500dad1f50
// List all files in a directory in Node.js recursively in a synchronous fashion
let walkSync = function(dir, filelist) {
if (dir[dir.length-1] != `/`) { dir = dir.concat(`/`); }
var files = fs.readdirSync(dir);
filelist = filelist || [];
@MichaelPaulukonis
MichaelPaulukonis / pride.from.finnegans.wake.txt
Last active November 29, 2016 21:46
closest sentences via levenstein distance (first two chapters of PRIDE AND PREJUDICE)
Rise up now and aruse!
Caution!
It is how sweet from her, the wispful, and they are soon seen swopsib so a sautril as a meise.
Our people here in Samoanesia will not be after forgetting you and the elders luking and marking the jornies, chalkin up drizzle in drizzle out on the four bare mats.
@MichaelPaulukonis
MichaelPaulukonis / songstory.txt
Created November 15, 2016 03:12
NaNoGenMo 2016 - story told by a child
Did you ever hear about the Princess who made friends with a real live sign? The sign's name was Ice Skate and the Princess's name was Diamonds.
They decided to play a game.
The game was hide-and-seek.
Diamonds said "First you hide, then I'll find you!" "Okay!" said Ice Skate.
They decided to play a game.
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function(dir, filelist) {
if( dir[dir.length-1] != '/') dir=dir.concat('/')
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function(file) {
if (fs.statSync(dir + file).isDirectory()) {
@MichaelPaulukonis
MichaelPaulukonis / gist:8301218
Created January 7, 2014 15:42
various bookmarklets
javascript:var%20loc='site:https://developer.mozilla.org/en-US/docs/Web/JavaScript';if('%s'){loc='https://www.google.com/search?q=site%3Ahttps%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs/+%s';}location.href=loc;
javascript:if('%s')%20location.href='https://duckduckgo.com/?q=%s+site%3Aemacswiki.org';else%20location.href='http://emacswiki.org/';
javascript:if(escape("%s"))%20location.href='http://stackoverflow.com/search?q='+escape("%s");else%20location.href='http://stackoverflow.com/';
// search netflic -- but now prompts for profile; possible to set?
javascript:{var%20loc="http://movies.netflix.com/";if(escape("%s")){var%20srch="%s".replace("%20","+");loc="http://movies.netflix.com/WiSearch?raw_query=SRCHTERM&ac_category_type=none&ac_rel_posn=-1&ac_abs_posn=-1&v1=SRCHTERM&search_submit=".replace(/SRCHTERM/g,srch)}location.href=loc}
javascript:if('%s')%20location.href='http://www.xradiograph.com/?q=%s&focus=on&action=search';else%20location.href='http://www.xradiograph.com/';
@MichaelPaulukonis
MichaelPaulukonis / js2-indent-set.el
Last active January 2, 2016 11:59
Setting Emacs' js2-mode indent level on the fly. See refs @ http://www.xradiograph.com/JavaScript/Emacs
;;; do I even need to say how preliminary all of this is?
;;; in-progress variant to use universal-argument or param
(defun js2-cust-idnt (&optional indt)
"set indentation in this buffer"
(interactive)
;; TODO if no prefix-arg and no idnt, prompt for indent?
(let ((indent-level (if indt indt
current-prefix-arg)))
(setq js2-basic-offset indent-level)))

Third "major" variation -- if original noun started with a capital letter, replacement will start with a capital letter.

More punctuation removal - not perfected however. I've added some unit-tests, but even that's stubby.

Some of the punctuation removal to the detriment of the title -- "D'ARTHUR" is now un-replaced

This contains 158797 words.

In the "chapter highlights", the standalone two-word lines correspond to "BOOK I" "BOOK II" etc. in the original.

Third "major" variation -- if original noun started with a capital letter, replacement will start with a capital letter.

More punctuation removal - not perfected however. I've added some unit-tests, but even that's stubby.

Some of the punctuation removal to the detriment of the title -- "D'ARTHUR" is now un-replaced

NLP transformation of text sample. source code

"King" and more nouns and proper nouns (singular and plural) are replaced. Replacement is better. The opening line shows that it is not perfect.

#NaNoGenMo

@MichaelPaulukonis
MichaelPaulukonis / How Sir Dinadan rescued a lady from Sir downlink direction 0000000.txt
Last active December 29, 2015 12:29
first results of noun-replacement. WEIRD WEIRD FLAWS. "Le Morte D'Arthur" with the nouns replaced by nouns from "Underground -- Hacking, madness and obsession on the electronic frontier." The nlp library (https://github.com/fortnightlabs/pos-js/) insists on interpreting every instance of "king" or "King" as a VBG (verb, gerund). AAAARGH. BEACUSE…