Skip to content

Instantly share code, notes, and snippets.

View jnsprnw's full-sized avatar
🍊
Making smoothies

Jonas jnsprnw

🍊
Making smoothies
View GitHub Profile
@jnsprnw
jnsprnw / lineBreak.js
Last active November 29, 2016 17:21
Insert a line break at the best postition (http://jsbin.com/nokehadija/edit?js,console)
function calcStandardDeviation(values){
const avg = calcAverage(values);
const squareDiffs = values.map(value => {
const diff = value - avg;
const sqrDiff = diff * diff;
return sqrDiff;
});
const avgSquareDiff = calcAverage(squareDiffs);
function getSpacePositions(str, origin) {
const positions = [];
const pre = str.lastIndexOf(' ', origin);
const post = str.indexOf(' ', origin);
if (pre > 0) { positions.push(pre); }
if (post > 0) { positions.push(post); }
return positions;
}
function getClosestValue(positions, value) {
@jnsprnw
jnsprnw / scraper.js
Created December 15, 2016 15:43
PhantomJS setup for hiding Phantomjs fingerprint
"use strict";
var page = require('webpage').create();
page.onConsoleMessage = function (msg) {
console.log('Console.log: ' + msg);
};
page.onError = function (msg) {
console.log('Error: ' + msg);
};
@jnsprnw
jnsprnw / converter.md
Last active May 11, 2017 08:30
Converter settings for CH Post

Install FFmpeg

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265

Webvideos

<video controls>
  <source src="somevideo.webm" type="video/webm">
 
@jnsprnw
jnsprnw / MoviesCountries.csv
Last active January 17, 2017 15:00
OpenRefine Walkthrough
Title Countries
Amores Perros Mexico
The Revenant USA
birdman USA
Babel France,United States,Mexico
Biutiful Mexico, Spain
Schindler’s List USA
The Color Purple United States Of America
Hook United States of America
eternity and a day Griechenland,Frankreich,Deutschland,Italien
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jnsprnw
jnsprnw / worldmap.json
Created January 15, 2017 14:21
GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jnsprnw
jnsprnw / berlin.csv
Last active August 15, 2017 19:23
Wikidata
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 3 columns, instead of 2. in line 6.
attribute,identifier,value
"highest point",P610,"Arkenberge (Q19259618) ()"
"topic's main Wikimedia portal",P1151,"Portal:Berlin (Q3248436) ()"
"instance of",P31,"seat of government (Q1901835) ();metropolis (Q200250) ();federal capital (Q257391) (+1990-10-03T00:00:00Z);big city (Q1549591) ();state of Germany (Q1221156) ();municipality of Germany (Q262166) ();city with millions of inhabitants (Q1637706) ();city-state (Q133442) ();integrated municipality (Q1307779) ();city (Q515) ();Einheitsgemeinde of Germany (Q15974307) ()"
"contains administrative territorial entity",P150,"Mitte (Q163966) ();Friedrichshain-Kreuzberg (Q158893) ();Pankow (Q163012) ();Charlottenburg-Wilmersdorf (Q158095) ();Spandau (Q158083) ();Steglitz-Zehlendorf (Q158064) ();Tempelhof-Schöneberg (Q158106) ();Neukölln (Q4071168) ();Treptow-Köpenick (Q158089) ();Marzahn-Hellersdorf (Q119284) ();Lichtenberg (Q329609) ();Reinickendorf (Q158876) ()"
"legislative body",P194,"Abgeordnetenhaus of Berlin (Q640859) ()"
"highest judicial authority",P209
{
"p1": {
"id": 1,
"content": "photo",
"content_links": [
"http://placekitten.com/200/300"
],
"correspondent": "Hashmat Yousufzai",
"correspondent_id": 4,
"name": "Abdul Majeed Rouyee",
company location
Adobe 151 Almaden Blvd, San Jose, CA 95113
Altera 101 Innovation Dr, San Jose, CA 95134
Apple 1 Infinite Loop, Cupertino, CA 95014
Applied Materials 3050 Bowers Ave, Santa Clara, CA 95054
Cisco 170 W Tasman Dr San Jose, CA 95134
eBay 2065 Hamilton Ave San Jose, CA 95125
Equinix 1 Lagoon Dr, Redwood City, CA 94065
Facebook 1601 Willow Road, Menlo Park, CA 94025
Google 1600 Amphitheatre Pkwy Mountain View, CA 94043