Git archive to expanded tree in directory of your choice

git archive master –remote=git@somegitrepo.git –format=tar | tar xvf – -C /path/to/folder/

Lemonstand product & category throw 404 if not found

Lemonstand weirdly does not come with a way to configure it’s dynamic pages such as categories and products to throw automatically throw a 404 if the product was not found.

I solved this with the following simple snippet. Initially just added to the post_action.php for both the category/ and product/ pages.

if(!isset($product)){
  $params = array();

  $page = Cms_Page::findByUrl('/404', $params);
  header('HTTP/1.0 404 Not Found');
  Cms_Controller::get_instance()->open($page,$params);
  exit;
}

if(!isset($category)){
  $params = array();

  $page = Cms_Page::findByUrl('/404', $params);
  header('HTTP/1.0 404 Not Found');
  Cms_Controller::get_instance()->open($page,$params);
  exit;
}

An improvement to this could be to wrap the 404 throwing into a function provided by a custom module and then just keep the logic behind throwing the 404 in the relevant areas of the site. In this case I just couldn’t be bothered…bite me.

A quote of inspiration: Waves

I came up with this the other night, no idea whether it’s original or not, but, i’m sure as hell going to claim it so, until proven otherwise.

In an ocean there are many waves, of these waves only few make it ashore, even fewer leave a mark. Leave a mark.

Edit*

In an ocean there are many waves, of these waves few but make it ashore, even fewer leave a mark. Leave a mark.

Moneys nice to have, but …

Moneys nice to have, but, if you have to sacrifice too much time to get it, when you do eventually stop, there will be no one around to share it with you.

Your job no matter the title

If you work with people, no matter what your title is, it’s your job to make the people around you feel better, empowered and encouraged.

Wordcamp 2013 Lancaster – my thoughts

Having just returned from Wordcamp Lancaster 2013, I thought what better time to write a quick round up of how I felt the weekend went than now. Having previously been to Wordcamp Portsmouth 2011 I was keen to make up for missing 2012’s Edinburgh event. I hope by providing some feedback and some relevant information to those who didn’t attend this years event in Lancaster it might help them make decisions about going in the future.

I’ve decided to break the review down into the following areas; Location, Venue, Hotel, Range/Quality of talks, Workshops and Social.

Location

Lancaster was chosen for the location of the premier UK WordPress developer event of 2013 (although it is rumoured they are also having a London based event in the winter hush, hush), affectionately (as always) dubbed Wordcamp 2013. Lancaster itself is a pretty quaint northern city with a huge University presence but when uni’s out for the summer it’s pretty quiet. Lancaster was a difficult venue to travel to for a Londoner like me, though it does have reasonable travel links via Virgin trains from London Euston. On a friday night a direct train to Glasgow stops at Lancaster without needing a change (bonus!). This is a slightly different story on a Sunday evening however, a 4 hour train ride with a change at Manchester Picadilly is what your looking to get you back to London Euston.

Venue

Lancaster university was the event venue, I couldn’t fault this. Perfect location and a nice university campus with alot of new buildings. The lecture theatres were perfectly fit for purpose. Though it was a little difficult to find the relevant area of the campus that the event was taking part in. There was some hot and cold food provided at lunch time which was a nice touch, seems as you had very little choice for alternatives.

Hotel

We stayed in the Lancaster House Hotel. This was awesome! Nicest hotel in Lancaster (apparently) certainly seemed pretty good. Great breakfast, good rooms, even better showers and a nice array of other facilities such as swimming pool, sauna and gym.

Range & Quality of talks

I like to measure the quality of an event by the amount of tangible things I walk away with, against what it costs me to be there. This years Wordcamp 2013 for me didn’t quite live up to my expectations. Despite it’s extraordinarily cheap event ticket prices (just £25 if you grab an early bird ticket) being in Lancaster I had to chuck another £300 just for travel, accommodation and food costs. I use WordPress professionally week in week out and I go to be involved in the community and learn a few things myself while i’m at it. This year I struggled to identify one tangible thing that I could look back on and say that i’ve added x to my armoury this year.

Range of talks

The good: There was a reasonable range of talks (at least in title), most of the talks were high level talks which applied to a wide range of event goers. Most of the content covered in the talks was easy going (with a few exceptions) and there was plenty of room for event goers to ask questions at the end of talks with little objection. I felt that all those giving talks did so with good delivery, well spoken and capable of answering questions to a good level at the close of the talks.

The bad: Most talks lacked relevancy to WordPress or relevancy to real life application when using WordPress, which in my mind makes it difficult for event goers to put talks into context or convert to something tangible. There was a big lack of advanced subject matter / Workshops for heavy WordPress developers to truly geek it up at the entire event. Some talks were even outright boring mainly due to their lack of relevancy or loop back to reality from theory.

Quality of talks

The quality of talks for me this year was lacking in content more so than it was speakers. I thought each of the speakers were more than capable of presenting. I just thought the talks lost focus on the audience being able to have an “aha” moment! To me alot of the talks lacked a little bit of finesse and very few added real value back to the advanced WordPress event goer. I guess I normally also expect the talkers to be those pushing WordPress to the limits or having particular expertise in certain areas of WordPress. Indeed that is at least where i’m personally likely to learn the most. This year felt like alot of speakers first talks and some of the talks came across asif the speaker hadn’t truly mastered his/her subject matter in real life situations, before giving it.

It may sound a bit harsh, and it probably is, besides, it’s always easier to sit in the audience goading the speaker, than it is to be the speaker, right!?

Workshops

There wasn’t really any. Nothing hands on anyway. Bit disappointing personally for me, though I do understand they add an extra layer of complexity to proceedings.

Social

Events and conferences alike are always good places to go and meet people working in similar fields to you. Usually you’ll find lots of friendly people and this year was no exception. There was even a social drink up in Lancaster town in the evening on Saturday night.

Will I be going again?

Probably. I guess I wouldn’t be writing this post if I didn’t want someone to read it and make it better next year.

Limit login attempts locks every day or so from 127.0.0.1

I use the WordPress Limit Login Attempts plugin a little bit across various WordPress sites that I run and support. Lately i’ve toyed with fine tuning some of these sites by using Limit login attempts in conjunction with Nginx and Varnish.

Varnish happens to be a reverse proxy (more on varnish here varnish) which means all traffic is routed through it first.

Every other day I would get a message telling me that limit login attempts has exceeded total amount of failed attempts from IP 127.0.0.1 – after a little brain racking and a bit of confusion I had an aha moment! Varnish was causing all failed login attempts to be from the same IP I.E the local one!

Once I realised this was the cause of the problem it was pretty simple to fix. Limit login attempts has an under reverse proxy setting which is as simple as just flicking on to prevent this problem.

Simple as that, quite frustrating until you realise this though. So i’m hoping it helps someone else out sometime in the future.

If – a poem written in 1895 by British Nobel laureate Rudyard Kipling

If you can keep your head when all about you are losing theirs and blaming it on you, if you can trust yourself when all men doubt you, but make allowance for their doubting too; if you can wait and not be tired by waiting,or being lied about, don’t deal in lies, or being hated, don’t give way to hating, and yet don’t look too good, nor talk too wise: if you can dream – and not make dreams your master; if you can think – and not make thoughts your aim; if you can meet with Triumph and Disaster and treat those two impostors just the same.

If you can bear to hear the truth you’ve spoken twisted by knaves to make a trap for fools, or watch the things you gave your life to broken, and stoop and build ‘em up with wornout tools: if you can make one heap of all your winnings and risk it on one turn of pitch-and-toss, and lose, and start again at your beginnings and never breathe a word about your loss.

If you can force your heart and nerve and sinew to serve your turn long after they are gone, and so hold on when there is nothing in you except the will which says to them: ‘Hold on!’

If you can talk with crowds and keep your virtue, or walk with kings – nor lose the common touch.

If neither foes nor loving friends can hurt you, if all men count with you, but none too much; if you can fill the unforgiving minute with sixty seconds’ worth of distance run -yours is the Earth and everything that’s in it, and – which is more – you’ll be a man my son!

Laravel .htaccess localhost MAMP and Mac OS X

I was, like anyone, excited about the release of Laravel 4 and quickly set about following the initial installation instructions on a vanilla vhost locally to have a play around with. I quickly found that the default suggested .htaccess file was causing a server error in MAMP on OS X.

I got around it with a little trial and error and can confirm the below contents in your .htaccess file – works great for me.

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]

The offending line from the suggested .htaccess contents was

RewriteRule ^ index.php [L]

Vim delete all lines in currently open file

It’s been a while since I blogged anything so I thought i’d stick this up which I found useful from time to time.

Deleting all lines in a currently open file when opening from vim in mac terminal.

Type gg to move the cursor to the first line of the file, if it is not already there.
Type dG to delete all the lines.

Then press “i” to insert new lines or copy from clipboard.