Let’s Encrypt

Generating a certificate:

# Point to the letsencrypt directory
$ cd /root/letsencrypt;
$ ./letsencrypt-auto certonly --standalone --email developer@example.com -d example.com -d www.example.com

Docker – Modify files in a running container

Here is a solution to use a fully functioning text editor within a docker container when ssh’d into a remote linux host.

# Log on to your container
docker exec -it grave_ride /bin/bash

# Run this command to fix the terminal
export TERM=xterm

# Continue to open and edit your file in your faviourite text editor.
nano my-file.js

Symfony form querybuilder with parameters

->add( 'weeks', 'entity', array(
    'class' => 'MV\CaravanBundle\Entity\CaravanRow',
    'property' => 'line',
    'query_builder' => function(EntityRepository $er ) use ( $caravan ) {
        return $er->createQueryBuilder('w')
                  ->orderBy('w.dateFrom', 'ASC')
                  ->where('w.caravan = ?1')
                  ->andWhere('w.visible = 1')
                  ->andWhere('w.booked = 0')
                  ->setParameter(1, $caravan);

Source: http://stackoverflow.com/a/13847387

Fix timezone settings for PHP on Mac OSX El Capitan for Symfony

Symfony requires you to specify a date.timezone in the ini file. The problem is, Mac uses it’s own install of PHP, and you need to create directory structure it searches for the ini file… and a php.ini file. Here’s how you do it.

1. Open terminal
2. nano /Library/Server/Web/Config/php/php.ini
3. add line date.timezone = “Europe/London” (Other timezones)
4. Save & exit.

The original error:

Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.  

Cron Job over SSL (wget & curl)


With wget, you must add the argument –no-check-certificate.
Hitting a PHP script every 15 minutes over SSL:

*/15 * * * * /usr/bin/wget -q -O /dev/null --no-check-certificate https://example.com/script.php


I haven’t tested the curl example, it was referenced from: http://serverfault.com/questions/476141/cron-jobs-no-longer-work-since-installing-ssl-cert-on-rackspace-cloud-server

For curl, you add -k:

*/15 * * * * /usr/bin/curl -k https://example.com/script.php

Symfony2 Entity Timestamps With Doctrine

1. Add line to entity annotation:


2. Add new columns for created and modified:

* @ORM\Column(type="datetime")
protected $created_at;

* @ORM\Column(type="datetime")
protected $modified_at;

3. Now tell doctrine that before persisting or updating, call updatedTimestamps()

* @ORM\PrePersist
* @ORM\PreUpdate
public function updatedTimestamps()
    $this->setModifiedAt(new \DateTime(date('Y-m-d H:i:s')));

    if($this->getCreatedAt() == null)
        $this->setCreatedAt(new \DateTime(date('Y-m-d H:i:s')));


Add Media plugin in PhoneGap CLI 5.0.0 (Android)

Firstly, open terminal and globally install the latest cordova (if it isn’t already global):

$ sudo npm install -g cordova

Then open your phonegap project root in terminal and run the following to add the plugin:

$ cordova plugin add org.apache.cordova.media

Once this has successfully been added, open config.xml and add the following entry:

<feature name="Media">
     <param name="android-package" value="org.apache.cordova.media.AudioHandler" />

I guess you just have to add config entries for another platforms.

MSAA (Anti-aliasing) on FBO’s in Cinder

Framebuffer objects in Cinder (by default) have no anti-aliasing which leaves your edges jagged.
The solution is to create a Framebuffer format and specify the number of samples to use.

gl::Fbo::Format msaaFormat;
msaaFormat.setSamples( 4 ); // enable 4x MSAA
gl::Fbo myMsaaFbo( 640, 480, msaaFormat );

More info on FBO’s and anti-aliasing