Category Archives: Uncategorized

Draft: Coder requests for Graphic Designers / How to design for code

WORK IN PROGRESS – this is a work in progress, if you have anything to add let me know here:  contact me!

Design is important, really important. Making things look right has an incredible impact on how visitors use our creations.

But not all design is essential, and not all styles are fixed.

Over many years of coding designs from mockups I’ve come across many habits graphic designers have which are very complicated to code.

So in my quest to ease Designer/Develoepr relations I’m compiling here a list of tips for designers to help them create designs which are easy (or not very messy) to code.

Naturally, if a design is wanted it can be coded. The Internet is magical like that – but if it doesn’t really matter if the logo is 2% larger on tablets than mobiles, lets keep them the same and keep the code sane.

Do use Rows

Everything on the web is either a rectangle or sits inside a rectangle.

You cannot see the rectangles which are responsible for layouts, but they’re still there. Making them overlap is possible, but not easy to do right.

Keeping things aligned in these invisible rows and columns makes coding life much easier.

Don’t make small changes

Every tiny visual change requires code to make the change and define when or where to apply the change. Having a button be 3px taller on the newsletter signup form than on the contact form requires about an extra 6 lines of code.

Don’t mix percentage and fixed widths

Having the form-labels be a fixed 150px wide and the form element take up the rest of the page is not fun to make happen in code. Either use percentage widths, or use fixed widths (which can be defined differently at different overall widths, but see “Don’t make small changes” above.

Category:

WordPress Shortcodes for Website Editors

Overview of Shortcodes

WordPress Shortcodes are snippets of code which WordPress turns into more advanced things. For example the gallery shortcode is very simple in the editor, but turns into a complicated bunch of code for displaying many images.

A basic shortcode is a word wrapped in square brackets, like this:

[gallery]

Simple Shortcode

A shortcode to display the most recent posts might look like this:

[recent-posts]

you can put that anywhere you like in your post body and when you view it on the front-end of the website it’ll display a list of recent posts.

Closing Shortcodes

Some shortcodes can be wrapped around some text, for example a shortcode might make a paragraph stand out and flash. In this case you put the usual shortcode form above before the content, and a repeat of it but with a forward slash added after the first square bracked after the content.

[stand_out_and_flash]This is the content[/stand_out_and_flash]

The shortcode will then generate some code to go before and after the content – in this case to make it stand out and flash.

Shortcode Settings

A shortcode can also have settings – this lets you use the same shortcode in different places but with different results. Taking the example of the recent-posts shortcode above we might want to choose how many of the most recent posts to show. We do this by adding a space after the shortcode name, followed by the setting name, and equals and then the value – followed by the closing square bracket.

You can add as many settings as you like (as long as the shortcode supports them) by repeating the format.

If the value of the setting contains a space (or some other special characters) you need to put it in quotes (you can put all values in quotes if you prefer too).

You don’t repeat the settings in the closing shortcode (E.g. the [[/stand_out_and_flash]] – they are always just a forward slash followed by the shortcode name.

Here are some examples:

[recent-posts count=10 order="oldest first"]
[recent-posts count=5]
[stand_out_and_flash flash_speed=fast] This will flash really fast[/stand_out_and_flash]

Have any questions or tips about Shortcodes? Ask in the comments below.

Category:

Don’t be Proud of Who You Are

Nobody’s Perfect

Everyone has things about themselves that they’d like to change, that’s not a bad thing. That’s what makes good people good.

We hear a lot that we should be proud of who we are, that nobody’s perfect and that’s OK. In fact it’s often said that it’s a good thing, we should surround ourselves with people who accept us for who we are.

Load of rubbish, I say.

I say surround yourselves with people who inspire you to be a better person, good friends love you for who you are – great friends love you for what you do and how you do it.

Everyone has dreams

When I was younger, I had lots of dreams. Some were realistic – I wanted to be a chef. Some I knew would only ever be dreams – how could I be a rock star if I couldn’t play music and sing/think/tap my foot at the same time?

Over time, these dreams changed. I realised that what I really wanted, was to make the world a better place. None of this “world peace” or “free Tibet” style better, I’ve never felt qualified for those.

The handy thing about a dream like “make the world a better place” is that is got quite a lot of scope, but it’s quite simple to do. At the end of the day I realised that the best way to do my bit for world peace is to become a better person.

This has the added advantage of being rather handy in my day to day life too.

Change Yourself

So I set about becoming the Sami I wanted to be. This started in Israel, where I knew nobody and could be whoever I wanted – I could ‘try out’ different behaviours, senses of humour, and see which I felt most comfortable in. That’s not to say I wasn’t comfortable before I went, but I was certainly more happy being the post-Israel me.

That was the most important thing I’ve ever learned – that it’s OK to change. You’ll make and lose some friends along the way, but that’s going to happen anyway (because change is OK, remember?).

Ever since then, I’ve thought about who I want to be, and how I want to get there. I’ve become comfortable as myself – step one. Over the past couple of years I’ve become more organised – step two. Next up, to become work-organised (a mysterious concept known as ‘having free time’) and to become healthily-organised. That last one’s a bit of a drag, I’ve never enjoyed exercise when it’s not a by-product of the quickest way to get to the train station.

But it’ll make me a better person, which will (in it’s own tiny way) make the world a better place.

So don’t be proud of who you are, be proud of who you have made yourself – and of who you want to be.

Category:

Installing PEAR, PHPUnit and Selenium on Windows

I wrote this for use at work, hence some of the wording. I may re-edit it one day, but it should do the trick. Feel free to leave any comments or questions below.

Installing PHPUnit on Windows is done with PEAR.

Installing PEAR

  1. Create the folder c:\program files\PEAR (This is your PEAR path)
  2. Download go-pear.phar from here: http://pear.php.net/go-pear.phar (the one which comes with PHP is usually broken) and save it in your PEAR path.
  3. Open a command prompt and navigate to your new PEAR folder, type php go-pear.phar
  4. Hit Enter to agree to a System install then Enter again to confirm all the settings are good (after checking them, of course).
  5. PEAR is now installed. When we use PEAR to install things, it creates a .bat files in our PEAR directory which can is used to run them. For example by the end of this page PHPUnit.bat will be installed and we can call it from the command line as ‘phpunit’ since windows is clever like that.

To be able to run these commands from outside of the PEAR directory we must add the PEAR directory to our PATH Environment Variable.

  1. Press Windows Key and Pause/Break to load the System screen.
  2. On the left click on Advanced System Settings.
  3. Click on the Advanced tab then “Environment Variables..” button at the bottom.
  4. In the bottom list, “System Variables” find and select the PATH variable and click Edit.
  5. Add a semi colon to the end of the list, and enter the path to your PEAR directory.
  6. Click OK and then OK again.

You will need to open a new CMD window if you already have one open so that you get one with the new environment variables available.

  1. Run “pear upgrade” to test and get the latest version in one handy step.

Installing PHPUnit

Navigate to your PEAR folder and run the following commands

  1. pear config-set auto_discover 1
  2. pear install --alldeps pear.phpunit.de/PHPUnit

PEAR creates a file called PHPUnit.bat, which we can run from anywhere because we put our PEAR directory into our PATH variable in the first step. It’s also created a bunch of other files which PHPUnit.bat uses.

You may wish to add C:\Program Files\PEAR\pear\PHPUnit to your php.ini include_path.

Installing Selenium for Integration Testing

Our Integration Tests use Selenium and involve launching a browser and running through things, they take siginificantly longer to run than Unit Tests and you’ll probably not run them every day. They’re useful when you’re changing the back end but not the UI, and will  need updating if you’re making changes to the UI. They also pick up JavaScript errors.

Selenium is a server to which PHPUnit will connect and issue commands, the server then launches a browser and tells it what to do.

  1. You need Java installed, take the Offline version from here: http://java.com/en/download/manual.jsp
  2. Download Selenium Server here: http://seleniumhq.org/download/ Create a folder and save this in c:\program files\selenium\
  3. Right click on your desktop, go to New > Shortcut. For Location simply type “Java”, hit Next and type Selenium Server as the name.
  4. Right click your new shortcut and click Properties, at the end of the “Target” field add -jar “C:\Program Files (x86)\Selenium\selenium-server-standalone-2.23.1.jar”
  5. Running this shortcut should give you a console screen with happy output.
  6. To install the PHPUnit Selenium extensions (to be able to run the Integration Tests) download this file (or check for a later version of PHPUnit_Selenium from here) and merge the PHPUnit_Selenium-1.2.7\PHPUnit\Extentions folder with it’s sister in your PEAR Directory under pear\PHPUnit

Note that we are using Selenium 2, so you must use the Selenium2 classes.

Running the tests

Running the tests should take a matter of seconds and are run from the command line. From within the Squadify code base cd into the tests folder, type “phpunit” and hit enter, you should see something like:

PHPUnit 3.5.15 by Sebastian Bergmann.
.... Errors Come out here ...
Time: 0 seconds, Memory: 5.25Mb

PHPUnit looks for a file called phpunit.xml from which it learns how you with the tests to run. There are command line options for running only sub sets of the tests specified, controlling the output and other cool things.

Writing or Editing Tests

Tests are seperated into TestCases, each TestCase will test one unit. Examples of units are models, pages and forms. Refer to PHPUnit’s documentation for specific details on how to write tests.

It’s very easy to write useless tests, some pointers to avoid doing so:

  • Before writing tests, write a Doc Comment description before the Test Case explaining why the test exists.
  • Write descriptive names for tests, similar to a Doc Comment these force you to think about what and why you’re testing.
  • You’re supposed to write tests that fail, this means running it so you can see it fail, then fix the code to make it pass. It’s important to remember that you must change the code being tested, not the test itself, for this.

For the sake of maintainability put as much care into reusing your test cases code as any other code, without violating these:

  • TestCases should never be dependant on another Test Case, individual tests can be when it makes lots of sense but it should be avoided. The reason is so that (for speed) you run a subset of the tests (hence the name Unit Test).
  • Factory methods (such as getEmptyUser() or getYoungUser()) should be begin with “get” and placed at the bottom of the class. They’re used to make maintaining easier.

More Information

PHP Unit Docs: http://www.phpunit.de/manual/3.2/en/
Advice on writing tests: http://blog.stevensanderson.com/2009/08/24/writing-great-unit-tests-best-and-worst-practises/

Tags:
Category:

Tikal

Sat here as Alex fertilised the forest gives me a short break from both our footsteps and our nattering.

I read my Lonely Planet a little before scolding at myself and just listening. Slowly at first, much like your eyes adjusting to the brilliance of the stars the volume slowly increases until the buzzing of bugs is only interrupted by birds chirping and trees rustling – and the odd fool with his MP3 player going, I politely reminded him I’d go to a disco if I wanted music. Turns out he works there, but what does that matter? That’s even more reason he should follow the “No Music” sign – which also forbids a small dictionary’s worth of other things.

Three weeks later, I finished writing this

Tikal is an awesome place, I’d love to have been the first person to write about it because it’s such a cliché. Walking down jungle paths between pyramids, climbing up them to peek at the tops of others poking out the trees.

Yada yada, I loved it but we had a different mission.

Yavin IV

Tikal, you see, was the set for the rebel base in Star Wars IV.  A fact pointed out by Steph (or Paola, or both perhaps) a few weeks earlier during our Star Wars Marathon.

So here we are on a mission to find X-Wings and support the rebel cause. hmm perhaps not sensible words to be using in these politically unstable countries!

Temple IV is the one used, though the noise of the X-Wings must have rustled the feathers of the much animal life (including Toucans!) we saw later that evening as we waited for the sun set.

Heading out as the light rapidly faded every leaf became a terrifying spider. We ducked into a bat cave (not knowing it was one until we reached the end) and finally got back to our hotel – El Jaguar- where we had rented a tent in their garden, and whiled the evening away drinking Micheladas and eating expensive pasta.

Flores

The next day we headed to Flores, I’d made a careful list of all the great sounding coffee shops, drinking establishments and food places I wanted to visit and Alex had agreed to a crawl of the lot of them. Unfortunately a truck ran into a power line and the whole of El Petén was out of power, so most places closed down. We whiled away the evening in our hostel, Hostel Las Amigos, and I had the chance to visit the well-worth-the-wait Cool Beans in the morning for breakfast. After breakfast I bought an excellent new book which kept me entertained during the 7 hour bus journey back home.

Passover Abroad (why on earth do I not drink beer?)

While I’m at home, living comfortably at dad’s, Passover abstinence is a relatively simple affair. Matza is in abundance, the kitchen is familiar and the local availability of produce well known.

This is my second Pesach while travelling, the first I was in Israel for the first day. I quickly got out of there because their [Major generalization warning] idea of Passover is to simply make awful bread rise with something other than yeast – but my gripes with the Orthodox are not the point of this post.

The easier food is, the less you think about it. So in England my family tends to avoid bread, marmite, pasta, beer and anything obviously leavened (we are not a family who thinks “Levaning Agents” is kosher just because there’s a Rabbi somewhere who wants carrot cake at the seder). There’s some weird ones, however. Neither Marmite nor beer are leavened and pasta doesn’t even contain yeast. Yet we avoid them, but why?

While abroad I’ve had the opportunity to rethink my Passover adherence and to decide what I should do, what really doesn’t matter and why I do it. I have decided to avoid Bread, Churros and Beer. It’s been several years since I considered Marmite not Kosher for Passover, this year and in this circumstance I have decided that Tortillas are Kosher for Pesach. Not that it matters, since your Judaism is yours and mine is mine, but here’s why.

We do it, because our grandma did

This is the real reason for most Jewish traditions. We come up with all kinds of symbolic reasons and even find biblical references for most traditions, but the real reason we do what we do is because that’s what makes us Jewish. However un-Jewish we may think we are are the very fact we identify as a Jew makes us 100% more Jewish than everyone else.

Making an effort is what makes us Jewish

Identifying as being Jewish can be quite an effort, though doing what it takes to feel like a Jew (and so to identify as a Jew) takes even more effort. Judaism isn’t a religion for the lazy or the shy, most of our traditions are in place to show our Judaism to those around us – from the curly whirlies of the orthodox to the Chanukah Parties decorated with cheap Christmas lights of the liberal. Jews are a proud people with fun traditions that many gentiles enjoy partaking in.

I’m a Jew, yeah!

This week I am not drinking beer or eating bread because that’s what makes me feel Jewish. I could avoid wine that hasn’t been commercially blessed as “Kosher for Passover” but that wouldn’t make me feel any more Jewish than saying a blessing before using the toilet. I don’t entirely eat Matza to remember my ancestors in the desert, because my ponderings of the previous years have lead me to question the historical accuracy I used to take for granted. I eat Matza because I am a Jew, and that’s what Jews do at this time of year. Each and every one of the 13 million other Jews out there may do something different for Passover, but that makes no difference to my Judaism.

A by product of my adherence is the remembering of and opportunity to retell the story of the Jewish people, a story I am very proud to be in the cast for the latest chapter of.

This post was inspired by videos such as the following:

Photo Credits:

The Travelling Geek

The Destination:

Aside from the Live USB sticks, this post is only Windows related.

The Journey:

The first few weeks I spend trying to travel and keep up some web development were laborious, and some lessons have been learned. I hope that this post can help someone else to avoid the time waste I have – though my experience has shown this to be a very touch and go way of working.

The Conclusion: Buy a Laptop

After a few months of working this way, I bought a second hand laptop in Mexico City. An HP Mini with an 8inch screen, 160GB hard drive and a few weeks later an extra battery (giving me about 8-10 hours life). I found that using the setup described here had too many shortcomings, including not being able to make use of the dozen-hour-long-bus journeys.

I loved my little Bubbles, but while sailing on The Wong I broke her screen. And then again, until my 8 inch screen was less than 6 inches. That’s when the VGA chip died.

Despite the extra cost, having a laptop meant I could work without having to ask my CouchSurfers for their computer, I could work in coffee shops and Cafes and on buses (charging when we stopped for lunch).

The Other Options:/h1>

Live USB Stick

I’ve concluded that a live OS on a pen drive is simply not stable, I’ve tried various versions of Linux (unfortunately I didn’t keep track of which they were, but Ubuntu 10.10 was included). From being troublesome to install to suddenly giving up after a few days, I have had no long term joy. I’m only an amature Linux user, so perhaps someone who can dig deeper into the config may have more luck.

Portable Apps

When using portable apps I highly recommend using a menu system for it, there’s a few around. The first I tried was SmithTech Portable Menu, about which I have no complaints: it’s fast, flexible and easy to use. However I switched to LiberKey because:

  • Their software catalog makes it silly easy to install applications.
  • The software in the catalog has been well modified to run portabley, in contract to some which work but are not quite portable.
  • You can still add your own applications, not from their catalog
  • You can split the menu between tabs (or categories)

I’ve disabled the animations and some of the other resource heavy pretty things, and made the menu single click instead of double click and am currently loving it.

PortableApps.com

I’ve tried about a dozen apps from portableapps.com and found them to be cheaply packaged and messy. I don’t even try them anymore unless I can’t find a well packaged or alternative piece of software.

 WAMP

Before I left to go travelling I spent some time wrestling with different WAMP setups. Wampserver is my preferred choice at home, however it doesn’t do portable very well.

I settled with Uniserver in the end, despite disliking some of it’s workings to begin with, the new version (8.0) makes things much easier (if slower).

I found running my DocumentRoot from my USB was too slow. So I now have a folder (which I call www) which I copy to c:\temp before getting going. It’s not as neat as running it all from the USB, but it’s fast enough to work from.

Document Root
With UniServer on my USB, and added an icon to LibreKey, and pointed the document root at c:/temp/www/public.

MySQL
I edited my.ini to tell MySQL to use c:/temp/www/data/mysql instead of it’s default folder on my USB.

Category:

Teotihuacan

Teotihuacan, not only can I now pronounce it but I can spell it too!

I’m not really sure what to say about it, it’s just awesome. That and we don’t actually know an awful lot about it.

IMG_9209.JPG

We know it’s old, it was probably started around 200BC though we have no idea by whom. It was all over by around 600AD, shortly before the Aztecs found it and thought it the place where the gods had lived.

At it’s height, around 450AD, it had around a population of around 200,000 and was probably the largest city in the world at the time.

It’s about 2 hours drive, and then several more hours walking around in awe, and clambering up the 234 steps of the Pyramid of the Sun. Which archeologists now think was actually dedicated to the rain god, not the sun god.

IMG_9225.JPG

The view from the top of the Pyramid of the Sun was amazing, in every direction you look there’s mountains (being in the Mexican Basin and all). You can also look down upon green grassy mounds covering not yet restored pyramids and other structured from the old city. To the north is some ugly urban sprawl clambering up the mountain, which sucks – but nothings perfect.

IMG_9229.JPG

Also cool is the Pyramid of the Moon, much smaller but due to it’s having larger steps actually harder to climb. It’s located next to a large plaza and was probably used more by the plebs, with the Pyramid of the Sun being for the priests and important people. So, predictably, I prefer the Moon 🙂

IMG_9240.JPG

Also surrounding the main attractions are the ruins of the city: houses, offices, plazas and soap boxes (allbeing huge ones made from stone) – and many of the walls still reatin a faded remenant of their original paint work. So with a little imagination, you can take yourself back and imagine getting ready to go watch the latest human sacrifice tumble down the side of the Pyramid of the Sun.

IMG_9197.JPG

IMG_9202.JPG IMG_9238.JPG

IMG_9225.JPG

IMG_9200.JPG

Category:

Lohr am Main – What do you get if you put and English Jew in a kitchen with a German Palestinian?

Phew! I am exhausted. Physically, mentally, emotionally and nearly spiritually. Not the bad kind of exhausted, burt the fullfilled and ready to rest kind. Also the awful handwriting kind, I’d better make an effort or I’ll never be able to read this in future.
I spent a good proportion of my train ride today trying to find words to describe Nicole. She’s an the perfect balance between mature enough to appreciate life and young enough to enjoy it. Awesomely open minded and both interesting and interested, and the most generous person I’ve ever met! She met me at Lohr am Main Station last night at about 8pm, with her friend Martina. The train from [[Frankfurt]] was €20, cheap enough compared to the ICE (German Fast Trains) from [[Bussels]] which I decided was too much. ICE is nice enough, very space-shipy but essentially a [[pendalino]]. The local train from my connection was nicer only because it was empty – from sitting on the floor to having half a carrige to fart as I please….
Nicole has a son but no babysitter. Which suited me because I love kids and was probably too tired for clubbing. So we cooked and cooked and cooked, and then made some side dishes.
I made [[roast potatoes]] which would have made Avi proud, vegetables, gravy and as close to [[Israeli salad]] as I could with a cabbage and a tomato. Nicole made pumpkin soup, burnt some paprika, turkish coffee, Palastinian rice (without the chicken) and Martina made [[Falafel]]s and fruit salad. We could have fed the town, but we managed without them. Shortly after eating, and Nicol’s son Jamil throwing some rice around (he was too excited to have visitors to sleep), we chatted and pumped up an air bed – Nicole who had only just moved in and hadn’t quite sorted out all the furniture – and soon it was to a sound sleep all. Except Jamil, and therefore Nicole… ok so I slept like a baby.
Tags: