Skip to content

Instantly share code, notes, and snippets.

View jochemstoel's full-sized avatar
💭
Dematerializing

Jochem Stoel jochemstoel

💭
Dematerializing
View GitHub Profile
@jochemstoel
jochemstoel / dom-to-json.js
Created June 21, 2018 17:00 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@jochemstoel
jochemstoel / client.js
Created June 10, 2018 02:43 — forked from jcarroyo/client.js
Node.js send file with pure socket (low level transfer)
var net = require('net');
var socket = new net.Socket();
socket.connect(5000, "127.0.0.1");
var fs = require('fs');
var path = require('path');
var packets = 0;
var buffer = new Buffer(0);
socket.on('data', function(chunk){
packets++;

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@jochemstoel
jochemstoel / gist:0a222974a682a16af53ded466e472ccc
Created April 12, 2018 20:09 — forked from samhernandez/gist:5260558
Get an RSS pubDate from a Javascript Date instance.
/**
* Get an RSS pubDate from a Javascript Date instance.
* @param Date - optional
* @return String
*/
function pubDate(date) {
if (typeof date === 'undefined') {
date = new Date();
}
@jochemstoel
jochemstoel / wf.txt
Created April 1, 2018 17:37 — forked from brookhong/wf.txt
Top 2000 Vocabulary Words
the 9243 (definite article,adverb)
of 5220 (preposition,auxiliary verb)
and 5196 (conjunction)
to 4951 (preposition,adverb)
a 4506 (indefinite article,noun,preposition)
in 2822 (preposition,adverb)
is 2699 (verb)
you 2041 (pronoun,noun)
are 1843 (verb)
for 1752 (preposition,conjunction)
@jochemstoel
jochemstoel / README.md
Created April 1, 2018 17:35 — forked from nitaku/README.md
Word cloud intersection

This experiment tries to define and show the concepts of intersection and difference between two word clouds.

Two distinct documents A and B (the first about infovis and datavis, and the other about Human-Computer Interaction) are each used to compute word frequencies. Each word in common between the two documents is then used to create the intersection set, in which each word is assigned the minimum value among its original weights (something reminiscent of a fuzzy intersection operation). The remaining words are used to create the difference sets. For each word in common, the set which had the greatest weight also retains that word with a weight subtracted of the intersection weight mentioned above. In pseudocode:

for each word in common between A and B
  let a_w be the weight of the word in A
  let b_w be the weight of the word in B
  put the word into the intersection set with weight = min(a_w, b_w)
  if a_w - min(a_w, b_w) > 0

put the word into the A \ B set with weigh

@jochemstoel
jochemstoel / Thinkful-scope-Answers
Created April 1, 2018 16:43 — forked from MPKel/Thinkful-scope-Answers
Scope questions/answers
What is scope?
Put simply, scope is the availability of a variable within a program.
Scope determines which parts of a program have the ability to access and manipulate a variable.
A global variable is available for access/manipulation by all parts and collective files(*sometimes) of a program.
A local variable's access is restricted to the function or block within which it was declared.
Why are global variables avoided?
Global variables are avoided because they create the possibility of unexpected side effects,
namely the unintended manipulation of variables, which causes functions to become indeterminate.
var dictionary = [
'the',
'of',
'and',
'to',
'a',
'in',
'for',
'is',
'on',
@jochemstoel
jochemstoel / main.js
Created February 1, 2018 16:34 — forked from xmalinov/main.js
electron-win-url
//chat://function/?param=bar
const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');
let mainWindow = null;
let yourURL;
@jochemstoel
jochemstoel / statuses.json
Created January 30, 2018 19:37 — forked from AndersDJohnson/statuses.json
HTTP Status Codes from Node's http.STATUS_CODES
{
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",