Skip to content

Instantly share code, notes, and snippets.

View Oylex's full-sized avatar

Joel Doyle-Tremblay Oylex

  • 1VALET
  • Canada, QC
View GitHub Profile
@Oylex
Oylex / geolocation.php
Created January 12, 2016 20:11
html 5 geolocation with fallback and using Google Maps to get the city
<?php
$task = $_GET['task'];
switch ($task) {
case 'ajax_fallback':
$output = [
'status' => 'ERROR',
];
$ip = $_SERVER['REMOTE_ADDR'];
@Oylex
Oylex / groupByRange.php
Created September 10, 2015 22:34
Take an array of numbers and return them grouped by range (sub array), ex: 1, 2, 3, 8 becomes: 1-3, 8
function groupByRange(array $numbers)
{
sort($numbers);
$output = [];
$firstNumberOfSequence = null;
$previousNumber = null;
if ($numbers) {
foreach ($numbers as $number) {