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


I haven’t tested the curl example, it was referenced from:

For curl, you add -k:

*/15 * * * * /usr/bin/curl -k

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

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

<feature name="Media">
     <param name="android-package" value="" />

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

OpenGL / Cinder – Custom Dynamic Attributes Example (GLSL 1.2)

Here’s an example of using dynamic custom attributes in GLSL 1.2 and Cinder.
I also found this link useful!

void makeVBO()
	gl::VboMesh::Layout layout;
	layout.addDynamicCustomFloat();  // add a custom dynamic float

	vboModel = gl::VboMesh(NUM_VBO_VERTICES, 0, layout, GL_POINTS); // create vbo mesh with dynamic positions
	GLuint loc = mShader.getAttribLocation("myAttribute"); // get location of "attribute float myAttribute" in vertex shader
	vboModel.setCustomDynamicLocation(0, loc); // set the local 'id' of the attribute

	int distFromCenter = VBO_RADIUS;

        // generate random vertices
	vector<Vec3f> vPositions;
	for (int j = 1; j < NUM_VBO_VERTICES; ++j)
			Vec3f(-(distFromCenter / 2) + randFloat()*distFromCenter,
			-(distFromCenter / 2) + randFloat()*distFromCenter,
			-(distFromCenter / 2) + randFloat()*distFromCenter)

        // iterate through vertices
	int i = 0;
	gl::VboMesh::VertexIter iter = vboModel.mapVertexBuffer();
	for (int idx = 0; idx < NUM_VBO_VERTICES; ++idx) {

		// set position of vertex
                // set the value of 'myAttribute' to a random number
                iter.setCustomFloat(0, 10+Rand::randFloat()*90);


void draw()

Hundreds of Thousands of Particles at 60 fps

Recently been getting to grips with Cinder, OpenGL and GLSL for a project. I managed to get close to a million particles drawing at around 60fps 

Here’s what I did to achieve this:

Firstly I created a VBO mesh that contained randomly positioned vertices (each vertex represented a root particle position).

Using VBO meshes mean you don’t have to upload the geometry before every draw call- it  gets uploaded to the GPU once, then you can transform and draw the referenced mesh in your render loop.

Once i had the VBO mesh, I created vertex and fragment shaders that accept GL_POINTS as the input and output types. This means the vertex shader is expecting a bunch of vertices and the fragment shader is expecting to draw a single points to the screen.

The clever thing is, you can flick a switch in OpenGL to enable point sprites, this means you can tell the fragment shader to draw a texture at the point instead.

You can also tell the vertex shader what size each point sprite should be rendered at based on its distance from the camera

Using point sprites is fast, because there are no triangles or textures that need mapping to them- the fragment shader just renders the texture at a given screen position and at the size you have specified.


Auto Orientate Image (Exif / PHP)

The following function will take an image path and automatically orientate it based on the images exif data. If it can’t find the exif data, it will do nothing!

function autoRotateImage($imagePath) {
	$exif = exif_read_data($imagePath);

	if(!isset($exif['Orientation'])) return;

	$ort = $exif['Orientation'];

	$image = imagecreatefromjpeg($imagePath);

	switch($ort) {
		case 3:
			$image = imagerotate($image, 180, 0);
		case 6:
			$image = imagerotate($image, -90, 0);
		case 8:
			$image = imagerotate($image, 90, 0);

	imagejpeg($image, $imagePath);

Mimic Mac on Windows

All the below worked a treat for me…

Don’t make a habbit of using CTRL, swap it on Windows:

How to Remap Windows Keyboard Shortcuts in Boot Camp on a Mac

Then reverse the trackpad scroll too:

How to Get the Worst OS X Lion Feature in Windows (Reverse Scrolling)

Note: I added an extra line at the top of the reverse-scroll script to stop an annoying “max hotkeys per interval” dialog box popping up. Here’s my full AutoHotKey.ahk script:

#MaxHotkeysPerInterval 400

Send {WheelDown}

Send {WheelUp}

Split String Method C++ / CPP

Here is a method that allows you to split a string in C++ (CPP). I couldn’t find a decent one on the internet so I wrote my own. The method accepts a source string and splits it by the specified delimiter. It returns a vector. I hope someone finds this useful!

std::vector<string> splitString(std::string source, std::string delimiter)
    console() << "Splitting " << source << " :: at :: " << delimiter << std::endl;
    int len = source.length();
    std::vector<string> words;
    std::string prev = "";
    for(int i = 0; i < len; ++i)
        std::string c = source.substr(i,1);
        if( != 0) prev = prev + c;
        if(( == 0 || i == len-1) && != -1) {
            prev = "";
    return words;