Skip to content

Instantly share code, notes, and snippets.

View abbadon1334's full-sized avatar
⚙️
Aut inveniam viam aut faciam

Francesco Danti abbadon1334

⚙️
Aut inveniam viam aut faciam
View GitHub Profile
@abbadon1334
abbadon1334 / gist:cd5394ccc8bf0b411c7d75a60215578e
Created February 1, 2019 04:19
create transcode array for database schema in atk/schema using ikkez/f3-schema
<?php
/**
* Copyright (c) 2019.
*
* Francesco "Abbadon1334" Danti <fdanti@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
@abbadon1334
abbadon1334 / benchmark_loops.php
Created February 21, 2019 08:57
benchmark of some loops in php
<?php
$a = function($array) {
$ret = [];
foreach($array as $item)
{
$ret[] = $item;
}
return $ret;
@abbadon1334
abbadon1334 / benchmark_suppression.php
Created February 21, 2019 11:58
Suppression bench @ vs isset
<?php
/**
* Copyright (c) 2019.
*
* Francesco "Abbadon1334" Danti <fdanti@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
<?php
include '../common.php';
class MyApp extends \atk4\ui\App
{
public $db;
public $auth;
@abbadon1334
abbadon1334 / BackgroundProcess.php
Last active March 2, 2019 07:04 — forked from jakzal/BackgroundProcess.php
Starting a PHP built in server in phpunit tests
<?php
namespace Zalas\Test;
use Symfony\Component\Process\Process;
trait BackgroundProcess
{
/**
* @var Process
@abbadon1334
abbadon1334 / findKmInRadiusWithAtk4.php
Created May 10, 2019 10:51
Given a MaxRadiusInKm, filter the reference of a model and get All records in the request radius by longitude and latitude.
$radiusMaxInKm = (int) $filterRequest['km'][0] ?? $filterRequest['km'] ?? 0;
$IDCitta = (int) $value;
$mCitta = new Citta($this->app->db);
$mCitta->tryLoad($IDCitta);
$earthRadiusKilometers = 6378.140;
$latitude = $mCitta->get('Latitude');
$longitude = $mCitta->get('Longitude');
@abbadon1334
abbadon1334 / benchmark_class_exists_and_reflection.php
Created May 12, 2019 07:36
Testing check for class existence and if caching class name is relevant in function of performance check over 10000000 iterations just to minimize errors and first loading of not already loaded existent class Results on PHP 7.3.5 shows that is not needed. https://github.com/atk4/ui/pull/702
<?php
/*
Testing check for class existence and if caching class name is relevant in function of performance
check over 10000000 iterations just to minimize errors and first loading of not already loaded existent class
Results on PHP 7.3.5 below shows that is not needed :)
BENCHMARK CASE CACHE REFLECTION AVG Time(s) Max Time(s) Tot Time(s) StdDev Time AVG MEM(b)
\Profiler N N 0.00000069 0.00246596 6.92156839 0.00000104 53.68750880
@abbadon1334
abbadon1334 / composer.json
Last active June 27, 2019 18:14
my actual composer.json for development with script for phpstan cs-fixer phpunit metrics coverage atk4
{
"name": "abbadon1334/nemesi",
"description": "description",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Francesco Danti",
"email": "fdanti@gmail.com"
}
@abbadon1334
abbadon1334 / UserGridCriteria.php
Created December 5, 2019 10:22
User Grid Criteria, an object to store filters and columns visibility
<?php
class UserGridCriteria extends \atk4\data\Model
{
public $table = "user_grid_criteria";
public $title_field = "name";
/**
* @var string
<?php
use atk4\core\AppScopeTrait;
use atk4\core\DIContainerTrait;
use atk4\core\FactoryTrait;
use atk4\core\InitializerTrait;
use atk4\core\TrackableTrait;
use atk4\ui\CRUD;
trait PluginTrait