Skip to content

Instantly share code, notes, and snippets.

@AnrDaemon
AnrDaemon / MySQL.sql
Created March 13, 2018 04:35
MySQL DateTime vs. TimeStamp vs. TimeZone changes.
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 | |
+-----------+-----------+------+-----+---------------------+-------+
<?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
<?php
ob_start();
phpinfo(~(2+64));
print str_ireplace('.e {background', '.e {white-space: nowrap; background', ob_get_clean());
<?php
/** Smarty template wrapper
*
* @version $Id: Smarty.php 674 2017-07-10 23:47:11Z anrdaemon $
*/
namespace AnrDaemon\CcWeb\Wrappers;
use
AnrDaemon\CcWeb\Interfaces;
<?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));
};
<?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__);
<?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');
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hrc PUBLIC
"-//Cail Lomecb//DTD Colorer HRC take5//EN"
"http://colorer.sf.net/2003/hrc.dtd"
>
<hrc version="take5" xmlns="http://colorer.sf.net/2003/hrc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://colorer.sf.net/2003/hrc http://colorer.sf.net/2003/hrc.xsd"
>
<?php
function get_new_image_name($dir, $id, $limit_num = PHP_INT_MAX)
{
$cache = [];
foreach(glob($dir . sprintf('/%02u-*.*', $id), GLOB_MARK) as $name)
{
if(is_dir($name))
{
continue;
}
__set_prompt()
{
test "$PS_ORIG" || PS_ORIG="$PS1"
test "$PC_ORIG" || eval "PC_ORIG='$PROMPT_COMMAND'"
PROMPT_COMMAND=__bash_prompt
}; readonly -f __set_prompt
__bash_prompt()
{
local ERRORLEVEL=$?
if [ $ERRORLEVEL != 0 ]; then