Skip to content

Instantly share code, notes, and snippets.

View marguslt's full-sized avatar

margusl marguslt

  • Tallinn, Estonia
View GitHub Profile
@marguslt
marguslt / 01.md
Last active December 1, 2023 08:04
aoc2023_R
library(tidyverse)
# 1 -----------------------------------------------------------------------
# a: 142
x <- read_lines(
"1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
")
@marguslt
marguslt / mc-pois.js
Last active December 16, 2021 15:01
Scraping Movescount POIs into GPX
let gpx = `<?xml version="1.0" encoding="utf-8"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xmlns="http://www.topografix.com/GPX/1/1">
`;
document.querySelectorAll("div.waypoint_item div.fl0.fs0").forEach(poi => {
let descr = poi.querySelector(".columns-header").innerText.trim();
let [poi_match,poi_lat,poi_lon,poi_elev,poi_date,poi_time] = poi.querySelector(".columns-para").innerText.trim().match(/([\d.]+), ([\d.]+) ([\d.]+ m )?([\d.]+) ([\d:]+)/);
let [d_match,d,m,y] = poi_date.match(/(\d+)\.(\d+)\.(\d+)/)
let [t_match,hh,mm] = poi_time.match(/(\d+):(\d+)/);
let poi_datetime = new Date(y,m - 1,d,hh,mm);
@marguslt
marguslt / bridleways-tags.js
Last active October 1, 2020 10:04
OSM Overpass API snippets - overpass-turbo.eu/
/*
query bridlways, style according to "foot" tag
seems that without "foot" many routers currently ignore those paths, even though in UK
https://overpass-turbo.eu/s/Pli
*/
[out:json];
(
way[highway=bridleway][designation=public_bridleway]({{bbox}});
@marguslt
marguslt / maa-amet.tms
Last active October 1, 2020 11:00
QMapShack online map file providing access to Estonian Land Board TMS service, only few layers are in EPSG:3857 projection.
<TMS>
<Layer idx="0">
<Title>Maa-amet - Eesti kaart</Title>
<Script><![CDATA[(function convert(z1,x1,y1){ y=(1<<z1)-1-y1;return "http://tiles.maaamet.ee/tm/tms/1.0.0/kaart@GMC/" + z1 + "/" + x1 + "/" + y + ".png&ASUTUS=MAAAMET&KESKKOND=LIVE&IS=TMSNAIDE";})]]>
</Script>
</Layer>
<Layer idx="1">
<Title>Maa-amet - Ortofoto</Title>
<Script><![CDATA[(function convert(z1,x1,y1){ y=(1<<z1)-1-y1;return "http://tiles.maaamet.ee/tm/tms/1.0.0/foto@GMC/" + z1 + "/" + x1 + "/" + y + ".png&ASUTUS=MAAAMET&KESKKOND=LIVE&IS=TMSNAIDE";})]]>
</Script>
@marguslt
marguslt / README.md
Last active December 25, 2019 18:32
Random Chrome snippets

Random js snippets for Chrome dev tools

@marguslt
marguslt / README.md
Last active April 21, 2020 13:32
Suunto App / Sports-Tracker fit export bookmarklet
@marguslt
marguslt / mc-chart-tune.js
Last active October 1, 2020 11:36
Movescount chart tune, improve readability of multi-series charts by changing chart colors.
document.querySelector("#moveCharts-chart > div > svg > g.highcharts-series-group > g:nth-child(3) > path").style.stroke="#aa0000";
document.querySelector("#moveCharts-chart > div > svg > g.highcharts-series-group > g:nth-child(5) > path").style.stroke="#00aa00";
@marguslt
marguslt / suunto-pomodoro.js
Created April 29, 2018 16:51
Suunto App Zone Pomodoro timer
/*
Own variables:
WorkCycleLength = 25
BreakCycleLength = 5
While in sport mode do this once per second
*/
if (Suunto.mod(SUUNTO_LAP_NUMBER,2) != 0) {
prefix = "W";
RESULT = 60 * WorkCycleLength - SUUNTO_LAP_DURATION;