Just for reference, here is the bootstrap.sh file I use to bring up my vagrant dev box with Solr 4 and Jetty ready to go.
apt-get install python-software-properties
apt-get install php5
apt-get install php5-mysql
apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
apt-get install phpmyadmin
apt-get install php5-curl
apt-get install -y apache2
apt-get install -y tomcat6 curl
rm -rf /var/www
ln -fs /vagrant /var/www
mkdir -p /opt/jetty/webapps/
mkdir -p /opt/jetty/webapps/
tar -xvf solr-4.4.0.tgz
cp solr-4.4.0/dist/solr-4.4.0.war /opt/jetty/webapps/solr.war
cp -r /opt/solr-4.4.0/dist /opt/solr
p -r /opt/solr-4.4.0/contrib /opt/solr
# copy new cores
cp -R /var/www/solr-config-master/solr-config-master/example solr
cp -r solr-4.4.0 solr
sudo sh tomcat6 start
sudo java -jar start.jar
Whenever a new Solr version comes out they tend to move the location , so a good idea to check whats’ what: http://apache.hippo.nl/lucene/solr/
I’ve never really come across the need to use an interface, and usually just use inheritance to extend whatever class I needed to. Recently though I needed a generic base caching class, which would have other classes implement there own methods.
public function getCacheValue($key);
public function setCacheValue($key , $value);
Note that there is no content within the methods, and rather than curly braces, its closed off with a ‘;’.
To implement the interface:
public function getCacheValue($key)
//try and get cached value from the DB
public function setCacheValue($key , $value)
//add new cache value to DB
Then wherever its needed:
public function __construct()
$this->cache = new CacheGoogle;
public function checkCache(CacheInterface $this->cache)
This week we had the director of an external agency in the office.
During a meeting with him he brought up that back in the old
days of cubicle programmers, some would have ‘cardboard cutouts‘ to bounce ideas off when they got stuck with a problem.
I mentioned that often when I was stuck with something and went to Stackoverflow to find a solution, often in the process of typing out and explaining the problem to someone else I’d come to the solution myself.
As it turns out Jeff Atwood thinks so too.
Instagram now allow uploads from your gallery, making this post redundant.
A few days ago Instagram added the ability to upload short video clips as well as photos using its mobile app. In the same way as Vine though, you can’t upload videos that are pre recorded, you have to take the video there and then using the built in camcorder.
While playing around the other day I found a way to do it though, here’s how it works on Android, although I assume the process would be similar for iOS, but I haven’t had a chance to look yet.
For proof, see my test video
You’ll need a rooted Android device for this to work.
My first clue was that just after you press the ‘next’ button after recording a video, a small JSON file
gets created. This contains the path to a temporary video file, along with other data which gets sent to the Instagram API.
Open up Instagram and record a short video up to the marker. It doesn’t matter what of, as we won’t be using this.
Now in a file manager head to
or where ever the path is in you pending_media.json file.
In that videos directory, you’ll see a new directory dated with todays date. Open that and you’ll see the video we just made.
Next we need to overwrite that video with the one we want to upload. It needs to be around 10seconds long, and not too large, otherwise the upload will fail. Copy over the orignal file with your new one, making sure to keep the file name the same.
Re open Instagram, and then press the ‘next’ arrow. After a few seconds processing, you should see your pre-recorded video. It can now be uploaded as normal.
There is another directory called ‘music’ which contains the audio of the original video.
I had an issue with some videos not being rotated properly. Within the pending_media.json file there is an ‘orientation’ attribute, which was set to 0. Setting it to 1 before upload didn’t solve it, so I ended up rotating the videos 270 before upload.
Let me know how you get on with this!
Importing MySQL db into Solr4.
<span style="font-family: Trebuchet MS, sans-serif;"><dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mydb" user="root" password="root" batchSize="1" />
<entity name="Property" query="SELECT * FROM Property">
<field column="id" name="id" />
<field column="address1" name="address" />
<field column="city" name="city" />
<field column="county" name="county" />
<field column="lat" name="lat" />
<field column="lng" name="lng" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<requestHandler name="/dataimport" class="solr.DataImportHandler">
When I restarted Solr, I kept getting the exception ‘DataImportHandler not found’
For some reason, I had no ‘dists’ dir or ‘contrib’ in my /opt/solr. So I copied one accross:
tar -xvf solr-4.3.0-src.tgz
cp -r solr-4.3.0-src/dist /opt/solr
cp -r solr-4.3.0-src/contrib /opt/solr
Then I was missing the ‘com.mysql.jdbc.Driver’
Not sure if this was correct, so to make sure
open up SolrConfig.xml
Had a real issue installing PHPUnit on my Vagrant server.
Initially I got this error:
Googling around, many people solved using:
sudo apt-get upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.symfony.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit
But for me, that then just left me with:
Looking at my PEAR config:
Showed me that my PEAR executable directory was:
So then all I needed to do was symlink from usr/bin to the phpunit one:
This method will install an older version of Solr. To get the latest I followed this guide.
All I had to do was add:
to the Vagrant file.
You can then start Tomcat with:
sudo apt-get install openjdk-6-jdk
sudo apt-get install solr-tomcat
Then in your Vagrantfile add something like:
and ssh back in again.
and Solr should be running. Test it out:
Importing pre-existing MySQL DB using Doctrine in Symfony2 I came across this error:
Unknown database type enum requested, DoctrineDBALPlatformsMySqlPlatform
may not support it.
The fix was found within the Symfony2 Docs
To app/config/config.yml just under your connection info add:
I needed a way of automatically generating links from blog posts, based on a pre-defined set of variables, so I built this basic PHP Class. I did’nt’ Google around to see what others had done as I fancied the challenge. I’m sure this can be improved immensely.
* Link Builder from array
* Takes received string and array of text and auto generates links based on the array.
* $linkArray = array(
* 'link' => 'http://www.kieronhoward.co.uk',
* 'text' => array(
* 'My Website',
* 'kieron howard'
* @author Kieron Howard <[email protected]>
* @version 1.0
public function getLinkArray()
public function setLinkArray(array $linkArray)
$this->linkArray = $linkArray;
public function addLinkText($link , $text = array())
$linkArray = $this->linkArray;
$linkArray = array(
'link' => $link,
'text' => $text
$this->linkArray = $linkArray;
public function generateLinks($string)
$LinkedText = '';
foreach ($this->linkArray as $linkText)
foreach($linkText['text'] as $text)
$pattern = '~' . $text . '~';
if(preg_match($pattern, $string, $url))
$LinkedText .= preg_replace($pattern, '<a href="'.$linkText['link'].'" rel="nofollow">'.$url.'</a>', $string);
if($LinkedText != '')
You can either pass in a predefined array , or use the addLinkText() method.
'link' => 'http://www.kieronhoward.co.uk',
'text' => array(
$LinkBuilder = new LinkBuilder();
$LinkBuilder->;addLinkText('myLink' , array('MyText' , 'MyText2'));
//will output 'Welcome to <a href="http://www.kieronhoward.co.uk">my site</a>
echo $LinkBuilder->generateLinks(Welcome to my site);