Skip to content

Instantly share code, notes, and snippets.

@josephrocca
josephrocca / npm-bad-word-relaxed-false-positives.js
Last active August 13, 2018 12:48
npm bad-word-relaxed false positives
// ==== NOTES ====
// Seems to have quite a few false matches. Might be worth updating the npm repo to tell
// people that `bad-words` seems to have fixed up its initial problems. It doesn't make
// any false matches in the google-10k list.
// ==== CODE ====
const Filter = require('bad-words-relaxed');
const profanity = new Filter();
const fetch = require('node-fetch');
@josephrocca
josephrocca / nlp-compromise-11.12.0 noun part-of-speech.txt
Created August 14, 2018 03:39
nlp-compromise-11.12.0 noun part-of-speech
===== NOTES =====
Some of the words in the desiquintans.com noun list aren't actually nouns, so this script itself
had a few false positives.
===== CODE =====
const fetch = require('node-fetch');
const nlp = require('compromise');
(async function() {
let words = await fetch("http://www.desiquintans.com/downloads/nounlist/nounlist.txt").then(r => r.text()).then(text => text.split("\n"));
for(let w of words) {
@josephrocca
josephrocca / test.html
Last active September 15, 2018 10:39
scrap - image loading in webcomponent test
<script>
(function(window, document, undefined) {
//document = document.currentScript.ownerDocument;
class ImageOnLoadExample extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
@josephrocca
josephrocca / simple-test.html
Last active September 15, 2018 12:33
scrap - simple web component test - async method
<script>
(function(window, document, undefined) {
const thisDoc = document.currentScript.ownerDocument;
class TestComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
@josephrocca
josephrocca / videoToCanvasToVideo.js
Last active February 25, 2019 10:57
Put a video on a canvas, and then encode the canvas frames into a new video file
// Depends on these script files being available:
// /library/whammy.js
// /library/libwebp-0.1.3.min.js
// Some details here: https://stackoverflow.com/questions/52371970/changing-quality-of-mediarecorder-and-canvas-capturestream/52378272#52378272
// videoUrl must either be a blob object url, or a file hosted on the same domain as this script, or have proper CORS headers to prevent canvas being "tainted".
// Obviously this function is useless unless you add some code to change the output
// canvas/video (e.g. add effects, resize, etc.)
@josephrocca
josephrocca / example.js
Last active September 27, 2018 15:01
Decode WebP Images in NodeJS
(async function() {
const WebPDecoder = await require("./fetchWebPDecoder")();
let webPDataUrl = "data:image/webp;base64,UklGRvYRAABXRUJQVlA4IOoRAAAQgQCdASpAAfAAPu1qrlEppaQqqXIMIVAdiWUHDODHxFjwOctUkVXfTu1UpVUx/8lcT9b44Nz547X6Nn7QXa4dE58x2yL9IRGF4LD3X1pNIIC8qvPaDVDfcOj3EjGc+T9JhNJF+L/SM7sk8BKuDSa9HYiOOPGixk0tWnhAPbVsTW2lc62I2xRGGbcjPJKjDUzadFCmB0hIFFWlTLKi6sBE/xkHbn/zbCr3pURqob/vE5mte/EjzeKcS7diP0QXZTbqEAHxHsKHICWbCjPQ2ZIUZ5Csu45dJ/hH/Gj1zF+R11M6P6dOpmpLZC+Fpv7dzbE08zm01ZOyOyXMBFoIJoB9bUmXZNfuYe4DuIGJrHH9Jw5K5Xp4m8dprR3hyErtiuNMK59cK4Ku0JyhQbrWURbQWFTbNvFk8hjBOOdBQPO/mJHMyHw/tSsFM6E+2yhGFDXnR9uYL+TCkGjo9JUE/2e7zJ9mLHS4ut+NkkDBQO7qJfJhYf1/PK5wUyAKc8oyhSCNBs28xKg/624mNhmQQhARg9qbZD8l8GiKnton/U3MCwVr81c0+6xKrGWYKYJGvRyVRj5TqwwbQPdrek7/hyhW/YNEYYY/BPljajvona6v3h+Q9faJtzqv0HBqITCFbKrXaFF0IZhlZZ4jLfL9h7kZ+I9tAUwxyeFWEpzl0+yDzOaJkwIAEshOQvZ3LsV5EIj/sysyOYDHhKKcVHPgGLHGq6g4OHovginNIHs08DpGFRfG7DG7MEF835uLXSHASXMdFpjHe3yp8NWYyVAqKfzrxU1tNQDkbezkHfcXRibTbHIlnxeP8sLv/hL7MRWyH/OoGNm+lok41jGTBlv0eZVrBXpx5r+xyBRdPkex0
@josephrocca
josephrocca / example.js
Created September 27, 2018 15:06
Decode WebP Images with NodeJS (inlined .wasm binary)
(async function() {
const WebPDecoder = await require("./fetchWebPDecoder")();
let webPDataUrl = "data:image/webp;base64,UklGRvYRAABXRUJQVlA4IOoRAAAQgQCdASpAAfAAPu1qrlEppaQqqXIMIVAdiWUHDODHxFjwOctUkVXfTu1UpVUx/8lcT9b44Nz547X6Nn7QXa4dE58x2yL9IRGF4LD3X1pNIIC8qvPaDVDfcOj3EjGc+T9JhNJF+L/SM7sk8BKuDSa9HYiOOPGixk0tWnhAPbVsTW2lc62I2xRGGbcjPJKjDUzadFCmB0hIFFWlTLKi6sBE/xkHbn/zbCr3pURqob/vE5mte/EjzeKcS7diP0QXZTbqEAHxHsKHICWbCjPQ2ZIUZ5Csu45dJ/hH/Gj1zF+R11M6P6dOpmpLZC+Fpv7dzbE08zm01ZOyOyXMBFoIJoB9bUmXZNfuYe4DuIGJrHH9Jw5K5Xp4m8dprR3hyErtiuNMK59cK4Ku0JyhQbrWURbQWFTbNvFk8hjBOOdBQPO/mJHMyHw/tSsFM6E+2yhGFDXnR9uYL+TCkGjo9JUE/2e7zJ9mLHS4ut+NkkDBQO7qJfJhYf1/PK5wUyAKc8oyhSCNBs28xKg/624mNhmQQhARg9qbZD8l8GiKnton/U3MCwVr81c0+6xKrGWYKYJGvRyVRj5TqwwbQPdrek7/hyhW/YNEYYY/BPljajvona6v3h+Q9faJtzqv0HBqITCFbKrXaFF0IZhlZZ4jLfL9h7kZ+I9tAUwxyeFWEpzl0+yDzOaJkwIAEshOQvZ3LsV5EIj/sysyOYDHhKKcVHPgGLHGq6g4OHovginNIHs08DpGFRfG7DG7MEF835uLXSHASXMdFpjHe3yp8NWYyVAqKfzrxU1tNQDkbezkHfcXRibTbHIlnxeP8sLv/hL7MRWyH/OoGNm+lok41jGTBlv0eZVrBXpx5r+xyBRdPkex0
@josephrocca
josephrocca / chromeFourtySupport.js
Last active January 8, 2019 01:01
Chrome 40 Support
/*
Workaround for a workaround for a workaround.
Includes:
- NodeList.forEach polyfill (not supported by polyfill.io)
- https://polyfill.io/v2/polyfill.js?features=default,es5,es6,Array.prototype.@@iterator,Array.prototype.entries,Array.prototype.find,Array.prototype.findIndex,Array.prototype.copyWithin,Array.prototype.findIndex,Array.prototype.includes,Array.prototype.keys,Array.prototype.values,DOMTokenList.prototype.@@iterator,DocumentFragment,Element.prototype.dataset,EventSource,Function.name,HTMLCanvasElement.prototype.toBlob,HTMLDocument,MutationObserver,NodeList.prototype.@@iterator,IntersectionObserver,IntersectionObserverEntry,NodeList.prototype.@@iterator,Object.entries,Object.values,Promise.prototype.finally,RegExp.prototype.flags,String.fromCodePoint,String.prototype.codePointAt,String.prototype.padEnd,String.prototype.padStart,String.prototype.repeat,Symbol.hasInstance,Symbol.isConcatSpreadable,Symbol.match,Symbol.replace,Symbol.search,Symbol.species,Symbol.split,Symbol.toPrimitive,Symbol.toS
@josephrocca
josephrocca / prefix-2-grams.json
Last active January 26, 2019 01:13
N-grams based on first N letters of top 466k+ english words (@dwyl/english-words/words.txt) - i.e. "prefix N-grams"
[["un",20576],["co",12944],["re",11833],["pr",10795],["no",9483],["in",8667],["ca",7734],["su",7670],["de",7549],["se",7169],["ma",6876],["pa",6834],["di",6735],["st",6462],["an",6050],["ch",6043],["tr",5657],["mi",5328],["pe",5072],["ba",5050],["po",5017],["ha",4714],["me",4703],["be",4683],["he",4553],["mo",4343],["ov",4326],["sp",4202],["sa",4182],["la",3935],["th",3894],["te",3718],["sc",3663],["br",3596],["al",3514],["sh",3482],["ho",3464],["ta",3333],["cr",3305],["ph",3279],["fo",3163],["ar",3160],["bo",3157],["en",3128],["li",3107],["qu",3095],["si",3000],["so",2993],["hy",2985],["gr",2978],["ra",2888],["to",2863],["ga",2847],["ex",2677],["pi",2660],["do",2648],["ro",2626],["ne",2608],["le",2597],["wa",2595],["we",2582],["pl",2566],["lo",2554],["bi",2506],["bu",2486],["cl",2433],["fi",2421],["fl",2420],["fa",2402],["ac",2389],["mu",2274],["wi",2213],["fr",2173],["vi",2139],["ou",2128],["bl",2109],["am",2039],["da",2018],["ve",1935],["wo",1906],["go",1902],["ge",1860],["im",1855],["ti",1853],["as",1817]
We can't make this file beautiful and searchable because it's too large.
word,count
the,23135851162
of,13151942776
and,12997637966
to,12136980858
a,9081174698
in,8469404971
for,5933321709
is,4705743816
on,3750423199