February 6, 2013
Symfony2 pagination
Using Symfony2, DQL and knplabs/knp-paginator-bundle - how to get around “Cannot count query which selects two FROM components, cannot make distinction”
Fails:
Works:
read more
February 5, 2013
Chroot SFTP home dir
Example user ‘iain’
sudo mkdir -p /chroot/iain/home/iain sudo useradd -M -d /home/iain iain sudo passwd iain sudo chwon iain: /chroot/iain/home/iain sudo nano -w /etc/ssh/sshd_config # At the end of the file, add: Match User paypoint ChrootDirectory /chroot/iain AllowTCPForwarding no X11Forwarding no ForceCommand internal-sftp sudo /etc/init.d/ssh restart
read more
February 4, 2013
Making an entity repository container aware in Symfony2.1
I had a need to add ACL rules to entities at the repository level.
My biggest struggle was getting dependancy injection working.
This is what I finally came up with after a fresh mind and an instant coffee:
Comments KingCrunch says: 16th February 2013 at 11:30 am
If your EntityRepository needs to know about the DIC, you made it wrong…
Wessel says: 13th June 2013 at 12:03 pm
Mmm nice trick.
read more
October 3, 2012
Adding extra fields to FOSUserBundle / SonataUserBundle
Sadly, this isn’t really documented (at time of writing).
Adding new protected variables to your User.php entity will not actually create database entries when you try to do a doctrine:schema:update.
While one still needs to have the protected variables in this entity class, along with getters and setters, the actual creation work is within UserBundle/Resources/config/doctrine/User.orm.xml
Here is an example for adding a foreign key:
<?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.
read more
June 26, 2012
Ubuntu 12.04 LTS on Bytemark VM
If, like me, you can’t wait for Ubuntu 12.04.1 to be released, you can force an upgrade of your favourite OS OS.
sudo apt-get update; sudo do-release-upgrade -d If you are going from the previous LTS 10.04, then the -d is important. Otherwise there would be no upgrade to offer.
The upgrade process should go smoothly enough. Except for when it comes to the kernel.
Bytemark VM’s make use of kernels that sit outside of the VM itself.
read more
June 24, 2012
Updating a WordPress database with new domain details
Further to my original quick db update queries, I found the need for a more in-depth approach.
A WordPress site my father works on has weekly backups, but he wanted to see that they actually worked.
To do so, I set up a subdomain vhost on my bytemark server and set about getting the back to work with it.
One of the most annoying/lazy/strange things about WordPress is that it uses serialised arrays within database fields.
read more
March 29, 2012
PPTP tunnels and if-up.d
Current project requires a couple of VPN tunnels to be set up. An IPsec and a PPTP.
The IPsec will wait for another day, the PPTP is set up and ready to go.
One thing that wasn’t quite right with the tunnel though, is the static route created by PPTP missed out a large chunk of the server’s network.
Starting the tunnel sets up the routing rule of 192.168.100.111 to be sent to the tunnel.
read more
February 2, 2012
Symfony 1.4 Doctrine 1.2 MS SQL Server
Web server: Linux (Ubuntu on my dev setup), Apache, PHP 5.3, Symfony 1.4, Doctrine 1.2.
Database server: Microsoft Windows 2008 Server, MS SQL Server
Trying to get Symfony to talk to the database server has been a painful experience for the last few days. But perseverance has paid off.
Lots of Googling with trial & error has resulted in actually achieving a development setup that will mirror the eventual production setup.
read more
November 18, 2011
Google calendar in Mozilla Thunderbird on Ubuntu 11.10
Via the Ubuntu Software Centre:
Search for thunderbird Click on the search result “Thunderbird Email” and then on the “More Info” button Enable at least the “Calendar Extension for Thunderbird - Google Calendar support (xul-ext-gdata-provider)” Install the add-ons Open your Google Calendar in your web browser In the left-hand column, under “My calendars”, hover over the calendar of choice and click the down arrow that appears after the calendar name Select “Calendar settings” Close to the bottom of the page will be the “Calendar ID” (in my case it is my full email address.
read more
August 4, 2011
Fixing odd characters
One of the biggest complaints that web developers have is their lack of control over end users.
When will we be able to tell them a) not to paste Micosoft Word or b) if you must, paste it into something that doesn’t do formatting 1st.
It has a nasty habit of converting quotes into “smart” quotes as well as messing up characters such as the euro symbol €.
This is the fix I came up with that allows end users to continue to paste from such programs and bring their weird charset issues with them:
read more