Skip to content

Instantly share code, notes, and snippets.

@gopi-ar
gopi-ar / tileConversionBug.php
Last active April 2, 2018 04:31
This script shows that we need to add round() before applying floor() in the Slippy Map Tiles' lat2tile() function. We also need to add (int) to avoid '-0' values. The bug is because PHP uses double-precision floating point numbers (https://stackoverflow.com/a/1863740/1094271)
<?php
/**
* This script shows that we need to add round() before applying floor() in the lat2tile() function. We also need to add (int) to avoid '-0' values.
* The bug is because PHP uses double-precision floating point numbers (https://stackoverflow.com/a/1863740/1094271)
*/
$tiles = [];
//Demonstrating only till z3, you can increase if you like
for ($zoomLevel = 0; $zoomLevel <= 3; $zoomLevel++) {
$tiles[$zoomLevel] = getTilesCount($zoomLevel);
@gopi-ar
gopi-ar / xyz_vs_tms.md
Created March 24, 2018 05:54 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@gopi-ar
gopi-ar / cloudflare-dns-analytics.php
Created October 30, 2017 07:43
Count Cloudflare DNS queries For All Domains
<?php
/*
* Script to count DNS queries for each domain associated to Cloudflare Account
*
* Params
* email Cloudflare Email
* token Cloudflare Global API Token
* start Start date in UTC ISO-8601 format Ex: 2017-10-20T00:00:00.000Z
* end End date in UTC ISO-8601 format
* domains (Optional) list of domains to compute DNS totals for; separate with comma. If this is empty, all domains will be checked. Ex: google.com,yahoo.com

tmux shortcuts & cheatsheet

start new:

tmux

switch inside tmux:

Ctrl + B + <command>