Skip to content

Instantly share code, notes, and snippets.

AnrDaemon

Block or report user

Report or block AnrDaemon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AnrDaemon
AnrDaemon / php-server.btm
Last active Feb 20, 2019
Server starter.
View php-server.btm
@ECHO OFF
SET SERVER="%~dp0php-xdebug.btm"
:: PARAMETRIZE [name param]
ALIAS /L
ALIAS PARAMETRIZE=`SET __name=%1 %+ SET __value=%@REREPLACE[^^--.*?=,,%2] %+ IFF "%[__value]" != "%2" THEN %+ SET %[__name]=%[__value] %+ UNSET __name %+ ENDIFF %+ UNSET __value`
SET _enc=UTF-8
SET _session=local
DO param IN /Q %$ ""
@AnrDaemon
AnrDaemon / moonphases.json
Created Mar 15, 2018
Moon phases tracker for InGameInfo (XML and JSON)
View moonphases.json
[
{
"str": "Day {day}, "
},
{
"if": [
{
"var": "daytime"
},
{
@AnrDaemon
AnrDaemon / curl-session-cookies.php
Last active May 11, 2018
Simple cURL setup with cURL internal session cookie handling
View curl-session-cookies.php
<?php
$url = new AnrDaemon\Net\Url("https://www.example.org/login/page");
// Ask for authentication password, fill the form
fwrite(STDERR, 'Enter password: ');
$form = [
"login" => 'admin',
"pass" => trim(fgets(STDIN)),
];
@AnrDaemon
AnrDaemon / MySQL.sql
Created Mar 13, 2018
MySQL DateTime vs. TimeStamp vs. TimeZone changes.
View MySQL.sql
mysql> CREATE TABLE `timetest` (`datetime` DATETIME DEFAULT 0, `timestamp` TIMESTAMP DEFAULT 0);
Query OK, 0 rows affected (0,29 sec)
mysql> DESCRIBE `timetest`;
+-----------+-----------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------+------+-----+---------------------+-------+
| datetime | datetime | YES | | 0000-00-00 00:00:00 | |
| timestamp | timestamp | NO | | 0000-00-00 00:00:00 | |
+-----------+-----------+------+-----+---------------------+-------+
View closure-iterator.php
<?php
$list = $_pdo->getAll('SELECT s1.`id` `id` FROM cat_section s1
LEFT JOIN cat_section s2 ON s1.`parent_id` = s2.`id`
WHERE s1.`parent_id` <> 0 AND s2.`id` IS NULL', [], \PDO::FETCH_COLUMN);
$iter = function($sid)
use(&$iter, $_pdo)
{
foreach($_pdo->getAll('SELECT s1.`id` `id` FROM cat_section s1
View pi.php
<?php
ob_start();
phpinfo(~(2+64));
print str_ireplace('.e {background', '.e {white-space: nowrap; background', ob_get_clean());
View SmartyWrapper.php
<?php
/** Smarty template wrapper
*
* @version $Id: Smarty.php 674 2017-07-10 23:47:11Z anrdaemon $
*/
namespace AnrDaemon\CcWeb\Wrappers;
use
AnrDaemon\CcWeb\Interfaces;
View nf.php
<?php
$nf = new \NumberFormatter("ru_RU", \NumberFormatter::CURRENCY);
$cs = ini_get('default_charset');
$formatter = function($price, $currency = 'RUB')
use($nf, $cs)
{
return iconv('UTF-8', "$cs//IGNORE", $nf->formatCurrency($price, $currency));
};
View classloader.php
<?php
/** Universal stackable classloader.
*
* @version SVN: $Id: classloader.php 739 2018-03-03 19:05:12Z anrdaemon $
*/
namespace AnrDaemon;
return call_user_func(function(){
$nsl = strlen(__NAMESPACE__);
View ractphp-example.php
<?php
require_once __DIR__.'/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$factory = new React\Datagram\Factory($loop);
function serverHandler(React\Datagram\Socket $server) {
$server->on('message', 'messageHandler');
You can’t perform that action at this time.