apt update
apt upgrade
apt-get install python-software-properties
add-apt-repository -y ppa:ondrej/php
add-apt-repository -y ppa:pinepain/libv8-archived
apt update
apt-get install php7.2 php7.2-curl php7.2-dev php7.2-mbstring php7.2-zip php7.2-mysql libv8-dev
pecl -d php_suffix=7.2 install v8js
echo 'extension=v8js.so' >> /etc/php/7.2/cli/conf.d/20-v8js.ini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * works for json objects. will replace all | |
| * keys and values with the result of the | |
| * closure. | |
| */ | |
| function walk_recursive($obj, $closure) { | |
| if ( is_object($obj) ) { | |
| $newObj = new stdClass(); | |
| foreach ($obj as $property => $value) { | |
| $newProperty = $closure($property); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: SSH Remote Test | |
| */ | |
| add_action( 'admin_init', 'ssh_remote_test', 1 ); | |
| function ssh_remote_test() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "os/signal" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Returns a function, that, as long as it continues to be invoked, will not | |
| // be triggered. The function will be called after it stops being called for | |
| // N milliseconds. If `immediate` is passed, trigger the function on the | |
| // leading edge, instead of the trailing. | |
| function debounce(func, wait, immediate) { | |
| var timeout; | |
| return function() { | |
| var context = this, args = arguments; | |
| clearTimeout(timeout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Standardized data cleanup helper class */ | |
| class Cleanup { | |
| /** | |
| * Make a string into UTF8 compliant... cleans funcky input characters | |
| * @param mixed $str | |
| * @return mixed $str | |
| */ | |
| static function makeUTF8($str) { | |
| if (is_array($str)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?PHP | |
| /** | |
| * Spintax - A helper class to process Spintax strings. | |
| * @name Spintax | |
| * @author Jason Davis - https://www.codedevelopr.com/ | |
| * Tutorial: https://www.codedevelopr.com/articles/php-spintax-class/ | |
| */ | |
| class Spintax | |
| { | |
| public function process($text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| METHOD 1 | |
| This should roughly sort the items on distance in MySQL, and should work in SQLite. | |
| If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance. | |
| --- | |
| SELECT * | |
| FROM table | |
| ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC |