How to pass ENV variables to PHP

How to export variables to PHP in secure way

It’s not a good practice to store your password in the code. It is a well-known fact, and on multiple occasions, people get hacked because they share their code (and passwords) accidentally with others.

Many bots are just browsing GitHub for lost AWS_SECRET_ACCESS_KEY or GCE credentials. I’m going to show you how to pass your AWS_SECRET_ACCESS_KEY to PHP.

Inline date edit with nojQuery

Inline Datepicker with vanilla JavaScript

I do write a lot of front-end code, despite being born to be a back-end guy. Long story short - we do have many inline editing features, especially elements like dates, which are pretty painful. HTML5 Introduced input type=date , which is good enough to cover most of the cases, and we no longer need ugly and slow .datepicker() component from jQuery od 3rd party suppliers.

So if you do have edit you can use <input type="date" value="yyyy-mm-dd"> field, and a nice calendar will pop up. But we are looking for inline solution.

Never use file_get_contents to make URL queries

Why you should not ever use file_get_contents

As each programmer by nature, I’m lazy. I try to accomplish as much as possible with minimum effort.

So whenever I use PHP to fetch something, I use file_get_contents to make queries and pull data from other services. So basically, my favourite snippet is this guy here:

How to replace all links in html to markup

How to replace all links in html to markup

Regular expression to replace href to markup

I recently moved my blog from WordPress to Hugo , which involved a lot of content fixing. One of the problems was that not all HTML code was correctly transferred to markup during the export. So I needed fix (replace) all pending <a href="https://spidersoft.com.au">spidersoft</a> to [spidersoft](https://spidersoft.com.au). What we need are just two simple regular expressions. One to find links <a.*?href="(.+?)".*?>(.+?)</a> Second one to replace them in reverse order [$2]($1) You can run this in basically any IDE - Sublime will do the job, I was using PHPStorm