Category: development

  • 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…

  • 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…

  • curl, jq and slightly dynamic input to a service

    I keep forgetting the syntax for these two things, so there’s a chance writing it here will help me remember. Possibly of use/relevance for: elasticsearch or Debezium….

  • 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.

  • vagrant commands for the lazy and forgetful

    Vagrant commands : vagrant up  – aka “clocking on at work, time to boot up the VM” vagrant status – aka “did I leave that VM running last night?” vagrant halt – aka “time to go home or change project” vagrant destroy – aka “VM is broken; kill it with fire and deploy a virgin…

  • Checking PHP code for compatibility issues

    One project I occassionally hack on is Xerte Toolkits. Yesterday on the mailing list it came up that someone was trying to use XOT with PHP4. After getting over some initial shock that people still use PHP4 (it was end-of-lifed in August 2008) I wondered how easy it would be to check the status of…

  • 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…

  • 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…

  • 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…

  • PHP Serialization & igbinary

    Recently I’ve been trying to cache more and more stuff – mostly to speed things up. All was well, while I was storing relatively small numbers of data – because (as you’ll see below) my approach was a little flawed. Random background – I use Zend_Cache, in a sort of wrapped up local ‘Cache’ object,…