rand(Ø)

> beautiful code & photos

about <

Posts tagged: hack

Link ID fields in EasyAdmin

If you also use EasyAdmin and are exhausted by clicking twice to see an entity ID when on the entity index page, you can use this small tweak to have your index page generate the detail page link on the ID field.

For this, simply override the template crud/field/id.html.twig.  
The original value is currently this:

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{# this template is used to display Doctrine entity primary keys #}
{{ field.formattedValue }}

Instead, you could replace its content with this:

> Continue Reading

MySQL: silent insecure password warning

I won't invent anything new here but I'll share a quick improvement on an answer I've found on Stack Overflow.

If you are doing batch actions and don't want to write in .mylogin.cnf file, there's the trick: use a process substitution!

$ mysqldump --defaults-extra-file=<(printf "[client]\nhost = host.rds.amazonaws.com\nuser = username\npassword = \$PassW0rd\$") \
    database > dump.sql

This also works for any other file input, like Docker env file run param:

> Continue Reading

CSP Header Hacking for Apache2

Hello,

I write here to report my latest dirty hack. Story—

While enforcing our HTTP server configuration at work, we are slowly implementing CSP policies and one of them allow Web browsers to report violations to a given endpoint.

At this moment, we are only at the reporting step of the implementation because the first time we attempted to roll this header out, it ended up breaking our staging env.

So, it's recommended to set the Content-Security-Policy-Report-Only header.

This header takes the report-uri directive which allows the browser to push the violation findings to a given endpoint.

For this example:

> Continue Reading

Android: Remote screenshot with adb

Hi there and happy new year!

Not that it's not easy to find this information but I recently signed up on Snapchat and let's be honest, it's not easy to capture the device screen when long tapping the screen.

Fortunately, Android development kit comes with a shell that allows to control your device from your computer through adb. No teaching you anything today.

I quickly wrote a tiny script that would allow anyone who found the way to install adb to capture your device screen remotely.

Create a screenshot file in the same folder of the adb binary and paste

> Continue Reading

CSS: Quick tip to test your design responsiveness

Meanwhile I'm finishing my photography portfolio, I was wondering how could I test my design responsiveness as my screen resolution is 1440x900 max so I figured out a work around...

For low resolutions, it's quite easy because you only have to resize your browser window or use Web Developer extension which provides some predefined common window sizes.
But what about 1600x1200 resolution when your laptop screen is 1440x900 (for my example)?

You could either use tool like Responsive Design Testing by Matt Kersley OR, you could use your native browser functionality if your design is well done. I mean if

> Continue Reading

PHP: Wordpress Popular Posts for the current category

Hi folks!

For my work, I luckily had to hack a client Wordpress instance... I'm glad to reached 6 years of studies after my A-Level to finally be a Wordpress hacker.

Anyway, today, my client Wordpress uses the popular plugin Wordpress Popular Posts to display various popular posts on his website. The plugin allows to exclude certain categories if you want but doesn't allow to filter for only one specific category. I read in the plugin forum that the plugin developer has this feature in his to-do list...

If you need this feature by the current version (2.2.1)

> Continue Reading