This file contains 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 | |
/* | |
Adapted from C function available at http://www.sqlite.org/fts3.html#appendix_a | |
Use like this: | |
$db = new SQLite3('database.db'); | |
$db->createFunction('rank', 'sql_rank'); | |
$db->query('CREATE VIRTUAL TABLE products USING fts4 (id INTEGER, title TEXT, description TEXT);'); | |
$db->query('SELECT * FROM products WHERE products MATCH \'Computer\' ORDER BY rank(matchinfo(products), 0, 1.0, 0.5) DESC;'); |
This file contains 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 | |
function mathEval($q) | |
{ | |
$q = preg_replace('/\s+/', '', $q); | |
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; | |
$functions = '(?:sinh?|cosh?|tanh?|abs|acosh?|asinh?|atanh?|exp|log10|deg2rad|rad2deg|sqrt|ceil|floor|round)'; | |
$operators = '[+\/*\^%-]'; | |
$regexp = '/^(('.$number.'|'.$functions.'\s*\((?1)+\)|\((?1)+\))(?:'.$operators.'(?2))*)+$/'; |
This file contains 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
#!/bin/bash | |
url=http://redefininggod.com | |
webarchive=https://web.archive.org | |
wget="wget -e robots=off -nv" | |
tab="$(printf '\t')" | |
additional_url=url.list | |
# Construct listing.txt from url.list | |
# The list of archived pages, including some wildcard url |
This file contains 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
#!/usr/bin/php | |
<?php | |
/** | |
* Download a large size art image from National Gallery of Victoria (NGV) website | |
* Copyleft (C) 2016 BohwaZ http://bohwaz.net/ (Public domain) | |
*/ | |
if (empty($argv[1])) | |
{ |
This file contains 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 | |
/** | |
* Named-Param vsprintf() | |
* | |
* positional-params based on key name, much the same as positional in sprintf() | |
* | |
* @link http://php.net/manual/en/function.sprintf.php | |
* @link http://www.php.net/manual/en/function.vsprintf.php | |
* | |
* @param string $str format string - replacements are in %KEY$x format |
This file contains 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 | |
$projects = []; | |
$projects[] = [ | |
'Project path', | |
'Owner', | |
'Name', | |
'Description', | |
'Created', |
This file contains 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 | |
/** | |
* Download large size images from SLSA Library | |
* (State Library of South Australia) | |
* Copyleft (C) 2015-2017 BohwaZ http://bohwaz.net/ | |
* GNU AGPL license | |
*/ | |
if (empty($argv[1])) |
This file contains 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 | |
$fp = fopen($argv[1], 'r'); | |
$db = new SQLite3($argv[1] . '.sqlite'); | |
$db->exec('BEGIN;'); | |
$header = null; | |
$i = 0; |
This file contains 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 | |
/** | |
* Returns UNIX timestamp from a NTP server (RFC 5905) | |
* | |
* @param string $host Server host (default is pool.ntp.org) | |
* @param integer $timeout Timeout in seconds (default is 10 seconds) | |
* @return integer Number of seconds since January 1st 1970 | |
*/ | |
function getTimeFromNTP($host = 'pool.ntp.org', $timeout = 10) |
OlderNewer