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
View PageUnitsCollection.php
<?php
/** Collection handler for webpage content blocks
*
* @version SVN: $Id: PageUnitsCollection.php 1231 2018-08-11 19:40:50Z anrdaemon $
*/
namespace AnrDaemon\CcWeb\Helpers;
use
AnrDaemon\CcWeb\Objects\PageUnit;
View named-constructor.php
<?php
namespace AnrDaemon;
class Xxx
implements \JsonSerializable, \Serializable
{
public static function createFromState(array $state)
{
$self = new static();
@AnrDaemon
AnrDaemon / apiaware.php
Last active Oct 30, 2018
Domain to infrastructure chained API interaction
View apiaware.php
<?php
/** Wrapper for actual thing that do the network talking.
This could be encapsulation for curl, Guzzle, Net\Browser, etc.
The wrapper offers a known stable interface to external library.
*/
class Service\Api\Wrapper
{
View create-validator.php
<?php
public function createValidator($spec)
{
list($type, $name) = explode(":", $spec, 2) + ['', ''];
$options = ["default" => null];
switch($type)
{
case 'dummy': // Dummy "non-empty" validator
return function($var)
View SettingsManager.php
<?php
namespace AnrDaemon\CcWeb;
use
AnrDaemon\CcWeb\Interfaces;
class SettingsManager
implements Interfaces\SettingsManager
{
@AnrDaemon
AnrDaemon / git-squash.sh
Created Apr 1, 2018
Easy and safe git squash with no manual calculations
View git-squash.sh
#!/bin/sh
git status --branch --untracked-files=no --porcelain=2 | (
while IFS=' .' read -r _s _b _name _value; do
[ "$_s" = "#" ] || break
if [ "$_b" = "branch" ]; then
case "$_name" in
head|upstream|ab)
eval "_$_name='$_value'"
;;
@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 | |
+-----------+-----------+------+-----+---------------------+-------+
You can’t perform that action at this time.