Pragmatism in the real world

Git push to multiple repositories

I have a couple of projects where I need to push to more than one repo all the time. I have been using this command line to do so: git push origin && git push other-remote However, I recently discovered that I can create a remote that points to more than one repository using these commands: git remote add all git@github.com:akrabat/projectname.git git remote set-url –add all ssh://example.com/path/to/projectname.git I now have a remote called all that… continue reading.

Kim

Today is Ada Lovelace day which celebrates the achievements of women in science, technology, engineering and maths. I have many role models in my technical life and many are women who inspire and encourage me to do better. There are too many to list, but I am thankful every one of them, both men and women. I want to talk today about one person who inspires me: Kim. Kim is relatively new to development. Fortunately… continue reading.

Jerry-rigging pygments to support new PHP keywords

I use rst2pdf to create my presentations and noticed that the syntax highlighter wasn't highlighting instanceof. rst2pdf uses pygments for syntax highlighting, so I wondered what was going on. A short investigation led to me realise that the current stable version of pigments is 1.6 and they are working on 2.0. It seems that 2.0 has a number of changes to the PHP lexer, which aren't in 1.6. While I'm waiting, I modified my local… continue reading.

Context specific history at the bash prompt

One change I made recently to my .profile is this: # up & down map to history search once a command has been started. bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward' These two bind command change the way that the up and down arrow keys work once you start typing a command to only search the history for lines that start with what you've typed so far. This means that I type, say, git and then press ↑… continue reading.

Alias for the PHP built-in server

I keep forgetting the correct command line syntax for the PHP build-in server, so I've now made an alias for it in my .profile: alias phps='php -S 0.0.0.0:8888' Now I can simply type: phps public/index.php to start the built-in web server.

Setting up mailcatcher as a service in Debian/Ubuntu

I've recently been changing joind.in's Vagrant system to use Debian and one issue I came across was getting Mailcatcher to start on boot and integrate property with the service command. To do this, I created an init script which is based off the skeleton and then stored this in /etc/init.d and then ran update-rc.d mailcatcher defaults to set up the correct links in the various rc.d directories. This is the init script: /etc/init.d/mailcatcher: #! /bin/sh… continue reading.

Codes of conduct

As my mind turns towards the conferences that I'm attending this autumn, I came across Why you want a code of conduct & how we made one by Erin Kissane. I highly recommend that you read it and the links within it. The part that struck me most was the thoughts on a plan of action. It's all very well to have a code of conduct, but if the event's organisers haven't got a plan… continue reading.

Using ZF2 Forms with Twig

Following on from looking at how to integrate Zend Framework 2 forms into Slim Framework, let's look at the changes required if you also happen to want to use Twig. When it comes to rendering the form, we would want our template to look like this: <form method="POST" role="form"> <div class="form-group"> {{ formRow(form.get('email')) }} </div> {{ formElement(form.get('submit')) }} </form> The ZF2 view helpers, formRow and formElement now look like Twig functions, however we don't want… continue reading.

Sending attachments in multipart emails with Zend\Mail

I've written before about how to send an HTML email with a text alternative in Zend\Mail, but recently needed to send an attachment with my multipart email. With help from various sources on the Internet, this is how to do it. use Zend\Mail\Message; use Zend\Mime\Message as MimeMessage; use Zend\Mime\Part as MimePart; use Zend\Mime\Mime; use Zend\Mail\Transport\Sendmail; function sendEmail($to, $from, $subject, $html, $text, $attachments = null) { $message = new Message(); $message->addTo($to); $message->addFrom($from); $message->setSubject($subject); // HTML part… continue reading.

Throw an exception when simplexml_load_string fails

I keep having to look up how to stop the warning that are emitted when simplexml_load_string & simplexml_load_file fail, so this time I've written the world's simplest little class to take care of it for me from now on: <?php namespace Rka; use UnexpectedValueException; class Xml { /** * Load an XML String and convert any warnings to an exception * * @param string $string * @param string $class_name * @param int $options * @param… continue reading.