Skip to content

Instantly share code, notes, and snippets.

View mrummuka's full-sized avatar

Mika Rummukainen mrummuka

View GitHub Profile
function cosineDistanceBetweenPoints(lat1, lon1, lat2, lon2) {
const R = 6371e3;
const p1 = lat1 * Math.PI/180;
const p2 = lat2 * Math.PI/180;
const deltaP = p2 - p1;
const deltaLon = lon2 - lon1;
const deltaLambda = (deltaLon * Math.PI) / 180;
const a = Math.sin(deltaP/2) * Math.sin(deltaP/2) +
Math.cos(p1) * Math.cos(p2) *
Math.sin(deltaLambda/2) * Math.sin(deltaLambda/2);
@mrummuka
mrummuka / reversewigo-solver-monkey.js
Last active March 29, 2024 08:23
Reversewigo autosolver - Tampermonkey script to automatically solve reverse wherigos on geocaching.com page
// ==UserScript==
// @name Reversewigo solver ✓🐵 DEV
// @namespace http://tampermonkey.net/
// @version 0.30
// @description Reversewigo solver ✓🐵 - solve reverse wherigo automatically on cache page. Solver code originated from Rick Rickhardson's reverse-wherigo source (public domain). Also, creates show source button for mystery cacahes.
// @author mrummuka@hotmail.com
// @grant GM_registerMenuCommand
// @grant GM_getValue
// @grant GM_setValue
// @grant GM.getValue
@mrummuka
mrummuka / geojsonio-wp-generator.js
Last active May 26, 2020 19:24
Generate all points (gps resolution) into hand-drawn region inside browser, using geojson.io as data source
// featureCollection and all features on map
let fc;
// autogenerated features (points within hand-drawn region)
let uniqueWps;
// gps coordinates of autogenerated features
let wps;
// script that does the magic
let gscript = "https://gist.githubusercontent.com/mrummuka/b70b9a9fb0825b4bace91a4b6d6b1257/raw/602987bba124e03a7641e96d56800375abd96409/regionWpGenerator";
fc = window.api.data.get('map');
const MYSTERY_RADIUS = 3.218; // km
const CACHE_RADIUS = 0.160; // km (WAS: 0.1609)
// resolution for how dense the created points will be (target: one gps decimal)
// var cellSide = 0.00001666666667; // if I calculated correctly this should have been enough, but apparently I didn't so doubling the precision for tests
const cellSide = 0.000006;
// converts decimal degree value into array of degrees, minutes and minute decimals (gps)
// todo: range checks
function l_dd2d_m_dec(val) {
@mrummuka
mrummuka / logtb.py
Last active September 25, 2016 11:18
logtb for executing pycaching library's log TB method from command-line. Usage: logtb.py <tracking_code> <msg_to_log>
import sys, datetime, pycaching, time
if len(sys.argv) > 2:
tbcode = sys.argv[1]
tbmsg = sys.argv[2]
else:
print("arg1=tbcode arg2=logmsg not provided")
exit(1)
geocaching = pycaching.login()
from pycaching.log import Log, Type as LogType
log = Log(type=LogType.discovered_it, text=tbmsg, visited=datetime.date.today())
@mrummuka
mrummuka / pycipher-cli.py
Created September 17, 2016 16:24
pycipher-cli for executing pycipher library from command-line
#
# cli for pycipher (https://github.com/jameslyons/pycipher)
#
from __future__ import print_function
import pycipher
from pycipher import ADFGX
from pycipher import Affine
from pycipher import Atbash
from pycipher import Autokey
from pycipher import Beaufort