Skip to content

Instantly share code, notes, and snippets.

View joshxyzhimself's full-sized avatar

joshxyzhimself joshxyzhimself

  • Philippines
View GitHub Profile
@joshxyzhimself
joshxyzhimself / ssh-tunnel@.service
Created June 26, 2020 04:48 — forked from guettli/ssh-tunnel@.service
Reliable persistent SSH-Tunnel via systemd (not autossh)
# 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
@joshxyzhimself
joshxyzhimself / README.md
Created June 2, 2020 11:41 — forked from ilyazub/puppeteer-reuse-cookie-in-http-request-from-node.js
Reuse `puppeteer` cookies in `tough-cookie` and `got`

Reuse puppeteer cookies in tough-cookie and got

This way we can send HTTP requests from the Node.js instead of UI interactions.

Set puppeteer cookies to tough-cookie's CookieJar

const cookies = await page.cookies()
cookies.forEach(
  async cookie => {
 await setCookie(
@joshxyzhimself
joshxyzhimself / haversine.sql
Created April 11, 2020 13:27 — forked from carlzulauf/haversine.sql
PostgreSQL function for haversine distance calculation, in miles
-- 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 *