Skip to content

Instantly share code, notes, and snippets.

View akritiko's full-sized avatar
🏛️
“The energy of the mind is the essence of life.” – Aristotle

Apostolos Kritikos akritiko

🏛️
“The energy of the mind is the essence of life.” – Aristotle
View GitHub Profile
@akritiko
akritiko / time_travel.php
Last active August 29, 2015 14:00
Time travel (PHP)
/**
* Time Travel returns dates in the past or the future, to a specific format, based on a seed date.
*
* @param $date_format the format of dates (seed and returned)
* @param $date the seed date
* @param $where_to time travel "step" in days (e.g. for yesterday "-1", tomorrow "+1" and so forth)
*/
function time_travel( $date_format, $date, $where_to ) {
return date( $date_format, strtotime( $date . ' ' . $where_to . ' day' ) );
}
@akritiko
akritiko / point_in_polygon.js
Last active May 24, 2018 08:19
Point-in-polygon: Jordan Curve Theorem (JS)
/**
* Point-in-polygon based on Jordan Curve Theorem
*
* Checks whether a point with a specific lat, long coordinates is inside
* a polygon defined by a given set of points. You can find more information
* about the Jordan Curve Theorem to:
* http://en.wikipedia.org/wiki/Jordan_curve_theorem
*
* The algorithm, originally implemented in c/c++ and can be found to
* http://sidvind.com/wiki/Point-in-polygon:_Jordan_Curve_Theorem.