Technologies

Never use file_get_contents to make URL queries

Why you shouldn't over use file_get_contents

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

So whenever I use PHP to fetch something I’m using 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

Recently I moved my blog from Wordpress to Hugo , and that involved a lot of content fixing. One of the problems was that during the export not all HTML code was correctly transferred to markup. So I needed fix (replace) all pending <a href="https://spidersoft.com.au">spidersoft</a> to [spidersoft](https://spidersoft.com.au). What we need is just 2 simple regular expressions. One to find links <a.*?href="(.+?)".*?>(.+?)</a> Second one to replace them in reverse order [$2]($1)
Docker, GO and CGO application build

Docker, GO and CGO application build

I’ve been avoid Docker for a very long time. I started my career as a sysadmin setting up servers running FreeBSD and early versions of Debian on bare-bone servers. As soon as “cloud” came into to the market I switch to AWS, and GCE and have been using them since then. EC2 was my always goto choice to quickly deploy something on the internet. But Docker — from some reason I was avoiding it until this 2 years ago, when I actually started using it. Without to much trust but…

But today history is not about my love & hate relationship with docker, but about trying to deploy Go application and VIPS library. Couple problems appeared during the process and it’s worth mentioning it for future generations because could find much help around my issues.

PrestaShop margin size on delivery slips

Recently one of my clients contacted me asking if I can make a change. Shrink a little bit huge margins on PDF delivery slips. The task wasn’t easy because settings is bit hidden in the files. By modifying templates you can change font size, and amend or remove elements from the printout. Unfortunately you can’t actually decrease margin on PDF printout.

CURL to GO

CURL to GO

Quite often we are looking for a quick way to make a request in GO, and we have working query tested in CURL. Sometimes it’s problematic to “move” all queries to GO, and build up whole query using client, protocol and so on. From the author of my beloved Caddy server there is a tool called curl-to-Go which basically does what is says. Just paste your CURL request and GO lang code to implement that.