Skip to content

Instantly share code, notes, and snippets.

View gavrya's full-sized avatar

Havryshchuk Oleksandr gavrya

  • Ukraine, Kiev
View GitHub Profile
@gavrya
gavrya / fullquery
Created November 30, 2015 13:24 — forked from OllieJones/fullquery
Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)
SELECT zip, primary_city,
latitude, longitude, distance
FROM (
SELECT z.zip,
z.primary_city,
z.latitude, z.longitude,
p.radius,
p.distance_unit
* DEGREES(ACOS(COS(RADIANS(p.latpoint))
* COS(RADIANS(z.latitude))
@gavrya
gavrya / startswith-endswith.md
Created November 28, 2015 16:01 — forked from umidjons/startswith-endswith.md
PHP: startsWith & endsWith functions

startsWith & endsWith functions

<?php
function startsWith($haystack, $needle)
{
    return strncmp($haystack, $needle, strlen($needle)) === 0;
}

function endsWith($haystack, $needle)