Skip to content

Instantly share code, notes, and snippets.

View zdila's full-sized avatar

Martin Ždila zdila

View GitHub Profile
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "DHT.h"
const char* ssid = "mywifi";
const char* password = "mysecret";
const char* host = "192.168.0.102";
DHT dht;
// Tool for adding checksum and header (if missing) to uBlox UBX message.
// by Martin Ždila <[email protected]>
// License: CC0
const arg = process.argv[2];
if (!arg) {
console.error(`Usage: process.argv[0] process.argv[1] AABBCCDD...`);
process.exit(1);
}
@zdila
zdila / snowfox.ino
Created April 3, 2018 17:31
Sigfox Snow Monitor
#include <SoftwareSerial.h>
#include <avr/sleep.h>
const int echoPin = 1;
const int trigPin = 2;
const int Rx = 3; // this is physical pin 2
const int Tx = 4; // this is physical pin 3
const int hcPin = 0;
SoftwareSerial mySerial(Rx, Tx);
@zdila
zdila / fridge-alarm.ino
Last active March 31, 2018 09:05
fridge-alarm.ino
#include <avr/sleep.h>
volatile unsigned long count = 0L;
unsigned long lastClosed = 0L;
int sensorPin = 0;
int buzzPin = 1;
ISR(WDT_vect) {
count++;
@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;
@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 / 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 / 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 / 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');
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;