duminică, 23 februarie 2020

Recover deleted PHP files

# search for a pattern
grep -iar "<?php" | cut -d':' -f 1 > phpfiles.txt


#remove recursed
cat phpfiles.txt | grep -vP "php.*" > phpfiles.txt.filtered


# check if any remaining files to move
wc -l phpfiles.txt.filtered


# move found files
cat phpfiles.txt.filtered | xargs -i mv '{}' ./php/

marți, 21 ianuarie 2020

(sf-dump)

Symfony Var Dumper Documentation:

    https://symfony.com/doc/current/components/var_dumper.html

But you don't need Symfony framework to use var dumper. You can just install it with composer.

https://packagist.org/packages/symfony/var-dumper
/* CSS rules */
.sf-dump { display: none !important; }
.sf-dump-show { display: block !important; }
// JavaScript statements
$('.sf-dump').addClass('sf-dump-show'); // to show debug info
$('.sf-dump').removeClass('sf-dump-show'); // to hide debug info

vineri, 29 noiembrie 2019

vineri, 8 noiembrie 2019

What is Fake Agile?

According to the DoD, a fake Agile project is one where:


  • No one is talking with or observing the software users
  • There is no continuous feedback loop between the users and the teams
  • There is a strong emphasis on requirements
  • Stakeholders are autonomous
  • End users are not present in any of the development
  • And manual processes are tolerated

joi, 1 august 2019

Understanding and Debugging Composer loader

Composer is great, but when it comes to understanding or debugging it, things are not so clear.

Understanding Composer


First of all, you may noticed that there is a file vendor/autoload.php


// autoload.php generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit::getLoader();


This is fine, right? Ok, but what is autoload_real.php? Short answer: it is nothing but the file with the definition of ComposerAutoloaderInit class. Great, until now ...

miercuri, 23 ianuarie 2019

Apache Redirect Combo

This is a simple and a well known setup for Apache servers. But this still can be a challenge when having to do a quick setup with a combo between two redirects:

  • one redirect from port 80 to port 443 (from plain HTTP to HTTPS);
  • one redirect from https://www.yoursite.com to https://yoursite.com without sacrificing the HTTPS aspect;
So here is the snippet.


# Redirect http to https
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://yoursite.com/$1 [R=301,L]

# Redirect www to non-www/https
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com
RewriteRule (.*) https://yoursite.com/$1 [R=301,L]