Skip to content

Instantly share code, notes, and snippets.

View hdon's full-sized avatar

Donny Viszneki hdon

View GitHub Profile
@hdon
hdon / foo.py
Last active March 15, 2018 07:43
garbage technique for training word embedding+predictor
# notable flaws:
# totally unorthodox method for training embedding (see lines 78, 81 and 82)
# extremely inefficient demo evaluation every 100,000 training steps (see lines 125-140)
# surprises:
# was actually extremely effective on small data sets
from __future__ import print_function
import tensorflow as tf
import numpy as np
import re, random, sys
@hdon
hdon / output
Created February 11, 2018 03:14
promise rejection simultaneously handled + not handled?
hdon@behemoth:~/src/git/ML-Tests/text-processing$ node --version
v8.9.3
hdon@behemoth:~/src/git/ML-Tests/text-processing$ node test-stream-promise-inverter.js
inverter caught transformer promise rejection:
Error: this is handled but also unhandled!
at fs.createReadStream.pipe.Inverter (/home/hdon/src/git/ML-Tests/text-processing/test-stream-promise-inverter.js:9:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:8082) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: this is handled but also unhandled!
(node:8082) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@hdon
hdon / word2vec-extract-vocab.js
Last active February 11, 2018 03:16
better word2vec stream-parser using stream-promise-inverter
/*
* Some examples of word2vec binary format:
* https://github.com/dav/word2vec/blob/master/src/word2vec.c#L560-L566
* https://github.com/jasonphillips/word2vec-stream/blob/master/index.js
*
* stream-promise-inverter:
* https://github.com/hdon/stream-promise-inverter
*
* compare to JUST word2vec format decode without stream-promise-inverter:
* https://github.com/jasonphillips/word2vec-stream/blob/8c76cf2df6a4dca14be9eb86ea784ccacfa7952d/index.js
#!/usr/bin/env node
var util = require('../lib/util');
var fs = require('fs');
var path = require('path');
var opt;
var reducer;
var reducerFunction;
var transpiledModulePath;
opt = require('node-getopt').create([
@hdon
hdon / utils.js
Created September 11, 2017 03:35
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var resolve = require('resolve');
function compileModule(babel, modulePath) {
var visitedFiles = {};
return _compileModule(modulePath);
var ll = new LazyLoad({
container: document.body
});
document.querySelector('#search').addEventListener('keypress', (ev) => {
var query = ev.target.value;
setTimeout(() => {
Array.prototype.forEach.call(document.querySelectorAll('body > a'), a => {
a.style.display =
( query.length == 0
.*.sw?
/.tox
/MANIFEST
.*.sw?
/.tox
/MANIFEST
@hdon
hdon / seth.py
Last active April 30, 2017 04:31
seth's thing
#import bleach # learn more: https://python.org/pypi/bleach
from bs4 import BeautifulSoup as bs
from bs4 import SoupStrainer as ss
import urllib as ul
import urllib.request
import re
#TODO: spider to crawl for urls
earl = 'http://www.premier-mountain-properties.net/houses-with-water-rights-almont-co/'
@hdon
hdon / knex-annoyance.md
Last active April 21, 2017 16:35
Anyone have a better solution in knex?

For the given schema:

create table foo (a int not null, b int not null, primary key (a, b));
create table bar (a int, b int, c int, foreign key foo_fk (a, b) references foo (a, b));

I want to join a and b, where there may be any number of bs for each a.

I can only come up with three solutions: