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
@rem <?php /* | |
@d:\yada\yada\bin\php "%~dpnx0" %* & exit /b & rem */print "\r \r"; | |
//-------------------------------------------------------------------------------------------------------------------- | |
// Make sure you replace the "d:\yada\yada\bin\php" with your real php.exe path | |
//-------------------------------------------------------------------------------------------------------------------- | |
print "This is a PHP script that looks like a batch.\n"; | |
print "Anything that's below the line is normal PHP, you can write your script here.\n"; | |
print "In fact, let's count to ten:\n"; | |
for($c=0;$c++<10;) print "$c, "; |
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 | |
error_reporting(E_ALL - E_NOTICE); | |
$thatsTooMany = "That's too many.\nYou'll exhaust your memory.\n"; | |
$desiredOutputCount = $argv[1] ?: 10; if($desiredOutputCount>500000) die($thatsTooMany); | |
$moreThanEnoughTries = $desiredOutputCount * 12; | |
$allFirstNames = wordsOf(firstNames); | |
$allLastNames = wordsOf(lastNames); |
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
setTimeout(function() { | |
var amount = 100; // how many pixels before the miracle happens | |
var beyondClass = 'beyond-that-point'; // this class will be added | |
var targetSelector = 'body'; // which element to add the class to | |
var checkMS = 20; // check scroll position every N milliseconds | |
var eClass = document.querySelector(targetSelector).classList; | |
setInterval(function() { |
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 arg($x="",$default=null) { | |
static $argtext = ""; | |
static $arginfo = []; | |
/* helper */ $contains = function($h,$n) {return (false!==strpos($h,$n));}; | |
/* helper */ $valuesOf = function($s) {return explode(",",$s);}; |
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 wordSimilarity($s1,$s2) { | |
$wordsof = function($s) { | |
$a=[];foreach(explode(" ",$s)as $w) if($w) $a[$w]=1; | |
return $a; | |
}; | |
$w1 = $wordsof($s1); if(!$w1) return 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 | |
function deleteQuotedParts($s,$replaceWith="#") { | |
$inQuote = ""; | |
$protect = 0; | |
$sl = strlen($s); | |
$quoteChars = ["'"=>1,'"'=>1,"`"=>1]; | |
for($i=0;$i<$sl;++$i) { | |
if($protect) { |
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 | |
class SimpleSheet { | |
private $data = []; | |
private $worksheetName = "Export"; | |
private $widthMultiplier = 6; // how many points for one character; gives rough approximations | |
private $cellLimiter = " "; // add extra character after each cell value (overflow limiter) | |
private $rowLimiter = " "; // add extra cell at the end of each row (overflow limiter) |
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 | |
'Options';{ | |
$outerLoops = 1000; // number of times to repeat measure (choose shortest time), give it 1000+ | |
$innerLoops = 30; // iterations within each measurement; depends on what you're measuring | |
$magnitude = 6; // one of [3,6,9], or [nanoseconds,microseconds,milliseconds], respectively | |
$decimals = 2; // normally 2 but be my guest | |
$methods = 3; // number (and order) of methods to run; simple integer or like [1,3,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
function ajaxGet(url,cbStateChange,xmlData,method) { | |
var rq; | |
method = method||"GET"; | |
try{ | |
if(window.XMLHttpRequest) | |
{rq = new XMLHttpRequest();} else | |
{rq = new ActiveXObject("Microsoft.XMLHTTP");} | |
;; | |
}catch(e) {return;} |
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 showRecords($list) { | |
$head = array_keys(reset($list)); | |
?> | |
<style> | |
* {box-sizing:border-box;} | |
show-records { --header-height:40px; --header-color:steelblue; --fonts:calibri,arial,helvetica; } | |
show-records, scrolling-box, stable-header {display:block;} | |
show-records {box-shadow:0px 5px 14px -8px black;height:80vh;position:relative;} |