This way we can send HTTP requests from the Node.js instead of UI interactions.
const cookies = await page.cookies()
cookies.forEach(
async cookie => {
await setCookie(
-- Haversine Formula based geodistance in miles (constant is diameter of Earth in miles) | |
-- Based on a similar PostgreSQL function found here: https://gist.github.com/831833 | |
-- Updated to use distance formulas found here: http://www.codecodex.com/wiki/Calculate_distance_between_two_points_on_a_globe | |
CREATE OR REPLACE FUNCTION public.geodistance(alat double precision, alng double precision, blat double precision, blng double precision) | |
RETURNS double precision AS | |
$BODY$ | |
SELECT asin( | |
sqrt( | |
sin(radians($3-$1)/2)^2 + | |
sin(radians($4-$2)/2)^2 * |
# Reliable persistent SSH-Tunnel via systemd (not autossh) | |
# https://gist.github.com/guettli/31242c61f00e365bbf5ed08d09cdc006#file-ssh-tunnel-service | |
[Unit] | |
Description=Tunnel for %i | |
After=network.target | |
[Service] | |
User=tunnel | |
ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure yes" -o "ServerAliveInterval 60" -N tunnel@%i |
let fnGetFileNameFromContentDispostionHeader = function (header) { | |
let contentDispostion = header.split(';'); | |
const fileNameToken = `filename*=UTF-8''`; | |
let fileName = 'downloaded.pdf'; | |
for (let thisValue of contentDispostion) { | |
if (thisValue.trim().indexOf(fileNameToken) === 0) { | |
fileName = decodeURIComponent(thisValue.trim().replace(fileNameToken, '')); | |
break; | |
} |
# | |
# This is the ultimate HAProxy 2.0 "Getting Started" config | |
# It demonstrates many of the features available which are now available | |
# While you may not need all of these things, this can serve | |
# as a reference for your own configurations. | |
# | |
# Have questions? Check out our community Slack: | |
# https://slack.haproxy.org/ | |
# |
import { useState, useEffect, useCallback } from 'react'; | |
function useHistory () { | |
const [pathname, set_pathname] = useState(window.location.pathname); | |
const push = useCallback((next_pathname) => { | |
if (pathname !== next_pathname) { | |
window.history.pushState(null, null, next_pathname); |
class AssertionError extends Error { | |
/** | |
* @param {String|void} message | |
*/ | |
constructor (message) { | |
super(message); | |
this.name = 'AssertionError | |
if (Error.captureStackTrace instanceof Function) { | |
Error.captureStackTrace(this, AssertionError); |
// JSON to Uint8Array parsing and visa versa | |
// (Intended Bluetooth communication on Cordova) | |
var JsonToArray = function(json) | |
{ | |
var str = JSON.stringify(json, null, 0); | |
var ret = new Uint8Array(str.length); | |
for (var i = 0; i < str.length; i++) { | |
ret[i] = str.charCodeAt(i); | |
} |
Doxbee sequential | |
benchmarking ./doxbee-sequential/async-bluebird.js | |
{"time":428,"mem":60.38671875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-native.js | |
{"time":591,"mem":98.82421875,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/async-es2017-util.promisify.js | |
{"time":479,"mem":69.7734375,"errors":0,"lastErr":null} | |
benchmarking ./doxbee-sequential/callbacks-baseline.js | |
{"time":149,"mem":29.99609375,"errors":0,"lastErr":null} |
// rendered at http://localhost:8080/account | |
export const Account = (props) => { | |
const { user } = props; | |
return ( | |
<div> | |
{ user.username } | |
</div> | |
); | |
}; |