Skip to content

Instantly share code, notes, and snippets.

View zdila's full-sized avatar

Martin Ždila zdila

View GitHub Profile
@zdila
zdila / GSM_GPS.c
Last active August 26, 2017 16:01
SMS controlled GPS tracker
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
AltSoftSerial altSerial;
TinyGPSPlus gps;
char line[256] = "";
int p = 0;
@zdila
zdila / prechodene.html
Created December 28, 2015 13:53
Prechodene
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.2/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@zdila
zdila / map_of_gps_traces.txt
Created December 28, 2015 15:36
Map of GPS traces
# download list
curl -u '*Martin*:****' http://api.openstreetmap.org/api/0.6/user/gpx_files > list.xml
# download the traces not containing " by " in the description
for id in `xmlstarlet sel -t -m "//gpx_file/description[not(contains(., ' by '))]/.." -v @id -nl list.xml`; do echo $id; curl -u '*Martin*:****' http://api.openstreetmap.org/api/0.6/gpx/$id/data > $id.gpx; done
# merge traces
gpsbabel -i gpx $(for GPX in *.gpx; do echo -n " -f $GPX "; done) -o gpx -F merged.gpx
# simplify merged trace
@zdila
zdila / ciiozatd700e4axlztyxupsor.json
Last active January 20, 2016 17:23
Hiking Slovakia
{
"version": 8,
"name": "Hiking Slovakia",
"metadata": {
"mapbox:groups": {
"1444934828655.3389": {
"name": "Aeroways",
"collapsed": true
},
"1444933322393.2852": {
osmosis --rb austria-latest.osm.pbf --rb czech-republic-latest.osm.pbf --rb hungary-latest.osm.pbf --rb poland-latest.osm.pbf --rb slovakia-latest.osm.pbf --rb ukraine-latest.osm.pbf --merge --merge --merge merge --m --bp file="../slovakia-extrude.poly" clipIncompleteEntities=true --wb file="slovakia-extrude.osm.pbf" omitmetadata=true
osmosis --rb austria-latest.osm.pbf --rb czech-republic-latest.osm.pbf --rb hungary-latest.osm.pbf --rb poland-latest.osm.pbf --rb slovakia-latest.osm.pbf --rb ukraine-latest.osm.pbf --merge --merge --merge --merge --m --bb left=16.6346 bottom=47.5438 right=22.7748 top=49.7483 clipIncompleteEntities=true --wb file="slovakia-extrude.osm.pbf" omitmetadata=true
as pg root:
CREATE EXTENSION hstore;
CREATE EXTENSION postgis;
-- drop TABLE ways, way_nodes, relation_members, relations, nodes, users;
@zdila
zdila / overpass_turbo_trails_to_gpx.js
Last active January 21, 2016 10:20
overpass_turbo_trails_to_gpx
// export NODE_PATH=/usr/local/lib/node_modules
// https://overpass-turbo.eu/
// [out:json];
// relation(area:3600014296)[route=bicycle]({{bbox}});
// out body;
// >;
// out skel qt;
var fs = require('fs');
@zdila
zdila / gist:f85c16621c41a94bc72c
Created March 19, 2016 09:53
preparations for gpx bulk upload
rsync -av --progress 2015-12* 2016* /home/martin/1 --exclude *.JPG --exclude *.MOV --exclude *.jpg --exclude *.bin --exclude *.pto
cat *.NMA > merged.NMA && gpsbabel -i nmea -f merged.NMA -o gpx -F skm53.gpx && rm *.NMA
@zdila
zdila / index.js
Created September 14, 2016 19:48
guidepost to hiking relation adder
// overpass query:
/*
[out:xml][timeout:250];
(
relation[route="hiking"][colour="yellow"]["operator"="KST"];
);
(._;>;);
out meta;
*/
@zdila
zdila / police.ino
Last active November 27, 2016 14:48
Arduino Police Car
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
long m = millis();
tone(8, (1.0 + sin(m / 250.0)) * 300 + 1200);
int x = m % 800;
@zdila
zdila / chrome-bg-with-sw-communication.md
Created February 20, 2017 09:54
How to send messages from service worker to the chrome extension without having the webapp open

In the background script we have:

chrome.webRequest.onBeforeRequest.addListener(function (details) {
  if (details.method === 'HEAD') {
    if (details.url.endsWith('?start')) {
      ringSound.play();
    } else if (details.url.endsWith('?stop')) {
      ringSound.pause();
 ringSound.currentTime = 0;