Skip to content

Instantly share code, notes, and snippets.

View FluxCoder's full-sized avatar
🏠
Working from home

FluxCoder

🏠
Working from home
View GitHub Profile
@FluxCoder
FluxCoder / taxi.php
Last active March 26, 2019 20:21
Find the nearest Taxi to one point
<?php
/*
* Calculate the distance between 2 coordinates
* By James Roffey - https://jroffey.me
*/
if(isset($_GET["lat"]) && isset($_GET["lon"])){
$pickup = array($_GET["lat"], $_GET["lon"]);
$taxis = array(
0 => array ('id' => '1','driverid' => '1','lat' => '51.873675','lon' => '0.544403','online' => '1','number_plate' => 'FE07 RAB'),
@FluxCoder
FluxCoder / distance.php
Created March 26, 2019 20:04
Calculate the distance between 2 coordinates
<?php
/*
* Calculate the distance between 2 coordinates
* By James Roffey - https://jroffey.me
*/
function distance($start, $last){
$theta = $start[1] - $end[1];
$dist = sin(deg2rad($start["0"])) * sin(deg2rad($last[0])) + cos(deg2rad($start[0])) * cos(deg2rad($last[0])) * cos(deg2rad($theta));
@FluxCoder
FluxCoder / index.php
Last active March 10, 2019 18:12
Index.php - Used for hooks project
<?php
// Main index.php, could be combined with router to add hooks to entire site.
// https://jroffey.me
$x_events = array();
global $x_events;
//Include App Class & create variable.
require("app.class.php");
$app = new app();
@FluxCoder
FluxCoder / App.class.php
Last active March 10, 2019 18:06
App Class for simple PHP hooks script.
<?php
class app {
public function RunHooks($hook, $value = NULL) {
global $x_events;
if (isset($x_events[$hook])) {
foreach($x_events[$hook] as $function) {