docker proxy image download

Docker doesn’t like me for some reason, and I often get really bad download speeds from my home IP address. One crude fix, is use an external server I can access as a SOCKS proxy. To do so, edit / create /etc/systemd/system/docker.service.d/http-proxy.conf and put in it : [Service] Environment=”HTTP_PROXY=socks5://localhost:8888″ Then, restart/reload systemd ( systemctl daemon-reload… Continue reading docker proxy image download

Mockery (test doubles/mocking dependencies)

[This is a relatively old post I think I forgot to publish….] Previously, I’d only used PHPUnit’s mock implementation; however lately I’ve been exposed to Mockery. While they both achieve broadly the same result (at least from my point of view), here’s an example of how to mock dependencies with Mockery. Class to test: class… Continue reading Mockery (test doubles/mocking dependencies)

PostgreSQL unbuffered queries and PHP (cursors)

From using MySQL, I’ve used the ‘unbuffered queries‘ feature a number of times. It’s where you don’t fetch the entire resultset into memory at once – which is necessary if you’re retrieving more data than you have memory available. If’s often also generally gets results/data back to you sooner.

Netbeans vs Vim … round 1 … fight

So, I think I’ve changed ‘editor’. Perhaps this is a bit like an engineer changing their calculator or something. For the last 10 years, I’ve effectively only used ‘vim‘ for development of any PHP code I work on. I felt I was best served using something like vim – where the interface was uncluttered, everything… Continue reading Netbeans vs Vim … round 1 … fight

SQL Injection with added magic_quotes assistance (the joys of legacy code maintenance)

  Sometimes you really have to laugh (or shoot yourself) when you come across legacy code / the mess some other developer(s) left behind. (Names slightly changed to protect the innocent) class RocketShip { function rahrah() { $sql = “insert into foo (rah,rahrah,…) values ( ‘” . $this->escape_str($this->meh) . “‘, …… )”; mysqli_query($this->db_link, $sql) or… Continue reading SQL Injection with added magic_quotes assistance (the joys of legacy code maintenance)

Zend_Cache – automatic cache cleaning can be bad, mmkay?

$customer uses Zend_Cache in their codebase – and I noticed that every so often a page request would take ~5 seeconds (for no apparent reason), while normally they take < 1 second … Some rummaging and profiling with xdebug showed that some requests looked like : Note how there are 25,000 or so calls for… Continue reading Zend_Cache – automatic cache cleaning can be bad, mmkay?