This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function weightedStdDev(values, weights) { | |
var avg = weightedMean(values, weights); | |
var result = values.map(function (value, i) { | |
var weight = weights[i]; | |
var diff = value - avg; | |
var sqrDiff = weight * Math.pow(diff, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function weightedMedian(values, weights) { | |
var midpoint = 0.5 * sum(weights); | |
var cumulativeWeight = 0; | |
var belowMidpointIndex = 0; | |
var sortedValues = []; | |
var sortedWeights = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elastic = require('elasticsearch'); | |
var client = new elastic.Client({ host: 'localhost:9200' }); | |
var index = 'myindex'; | |
var type = 'document'; | |
(function init() { | |
Promise.resolve() | |
.then(deleteIndex, handleError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tail -n0 -F "$1" | while read LINE; do | |
(echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \ | |
"payload={\"text\": \"$(echo $LINE | sed "s/\"/'/g")\"}" "$2"; | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#needs: pdftk, imagemagick, ghostscript and tesseract-ocr | |
#pdf should be 300dpi or higher resolution | |
#set -o errexit | |
function success () { | |
echo "\033[33;32m ✓ \033[33;00m" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extract text from PDF files (with images) | |
// Installation guide: https://github.com/nisaacson/pdf-extract | |
var extract = (function() { | |
'use strict'; | |
var fs = require('fs'); | |
var path = require('path'); | |
var pdfExtract = require('pdf-extract'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"selectors": [ | |
{ | |
"parentSelectors": [ | |
"_root" | |
], | |
"type": "SelectorLink", | |
"multiple": true, | |
"id": "month", | |
"selector": "div.calendar-switcher.months ul li a", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="search"> | |
<fieldset> | |
<legend>Search string</legend> | |
<input type="search" name="query" value="" placeholder="Enter text"> | |
</fieldset> | |
<fieldset> | |
<legend>Search for</legend> | |
<input type="radio" name="type" value="name" checked="checked"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=CHAR((ROW(A1)-1)/26+97)&CHAR(MOD(ROW(A1)-1;26)+97) |