The one where I realise I've been suffering from premature session-itis
Back in 2010 Google said, “Speeding up websites is important — not just to site owners, but to all Internet users. Faster sites create happy users and we’ve seen in our internal
No tail call optimization in PHP (yet)
In a previous post about functional programming in PHP I used an example of reading a text file to show how a functional style of programming is different from ‘normal’ PHP coding. The
Using WordPress transients API to speed up plugins and themes
WordPress has a transient storage API that is perfect for caching data that is used in plugins and themes. It can be used to temporarily store often-accessed data from the database or slow external
Apache HTTP server uses far less memory than you think it does
This post is about the memory consumption of Apache’s HTTP Server (v2.2) using the prefork MPM configuration.
Apache does not use as much memory as many people think; I’ve seen a good
Wordpress performance: Simple ways to speed up your website
The speed of your website is very important; not only does a fast website make for happy users it can also improve your ranking in search engines.
The faster your website is the happier your users
Functional programming in PHP - anonymous functions, closures and tail calls
This post gives a brief introduction to functional programming with PHP. It doesn’t dive into the details of functional programming but it does try and show how the functional style differs
Using Smarty templates with CodeIgniter
This post explains how to integrate the Smarty templating engine with the CodeIgniter MVC framework.
CodeIgniter ships with its own templating system, which is nice and simple to use, is fast and
Adding a bit of color to your linux shell commands
Unix command shell output can often be hard to read. If you are running commands that produce lots of output text it can be hard to read and hard to find the strings in the output that you are
SQL Server and Java JDBC connection
This post shows how to connect (and read from) a Microsoft SQL Server database using a JDBC driver. It doesn’t use Hibernate or any other ORM.
The driver I used to connect to the SQL Server
Curse of the devpreneur, or: why I'm still only making $285 a month
I love programming. I love learning new languages, trying out new JS libraries, improving my code, optimizing it, coding things to see how they work, making stuff, I love thinking about language
Why I released a crappy todo app that no-one will ever use
The last thing the world needs is another todo app, so, uh….., here’s mine.
I wanted to build the simplest possible todo list, I wanted nothing more than a paper-and-pencil list in my
It’s the only good fight there is
If you’re going to try, go all the way. Otherwise, don’t even start. This could mean losing girlfriends, wives, relatives and maybe even your mind. It could mean not eating for three or four days.
Adding PHP build system to Sublime Text 2
Sublime Text 2 has the concept of build systems. This basically means that if you are editing a Python file then you can run the Python interpreter on the source file your are editing and see the
Getting in the zone versus cranking out the easy work
To do our absolute best work we have to be in the zone, concentrating fully on that task at hand and ignoring all other todos or distractions. We have to be immersed in the work, we have to know
My 2 cents on whether you should use Smarty/Twig/etc in view templates instead of raw PHP
It’s up there with the big questions of our time: How do we stop global warming? What happens after we die? Do we have free will? Can we cure AIDS? How do we bring peace and stability to the
Keeping at it
You see, startups are like fire. They need oxygen to fuel them. You can’t build a roaring fire by blowing a little air over it once a day. You can’t succeed when every day you return to find
The programmer who went up a hill & got stuck on a mountain
I’ve got no end of projects sitting unfinished on my hard drive, most of them are 80-90% finished and one or two evening’s work would see them out the door. So why don’t I just
Why shouldn't be a self-closed tag
The HTML <img> tag is self-closing, meaning that you write it likes this
<img src=”lolinternet.jpg” alt=”lol” />
and not like this
<img src=”lolinternet.
Using native PHP sessions with CodeIgniter
This post explains how to use native PHP sessions ( the $_SESSION[”] global array ) with CodeIgniter 2.1.0 in place of CodeIgniter’s default session storage.
CodeIgniter doesn’t
PHP 5.4 syntax changes to make your pants tingle
It’s the little irks and annoyances in a programming language that makes you love it or hate it. A language that has a terse syntax and plenty of quick ways to accomplish common programming
Creating a JavaScript templating function
Templating provides a separation of concerns between your data and its display. Back-end languages like Java and PHP have been using templating as part of the MVC paradigm for years and as JavaScript
GAME shares slump after disastrous Christmas
GAME, the video game retailer, saw shares slump by 40% after like-for-like sales tumbled 15.2% in the eight weeks to 7 January. This isn’t particularly surprising as most big-grand stores are
Creating JavaScript string startsWith() and endsWith() functions
JavaScript strings don’t have native startsWith() or endsWith() functions. Fortunately it is very easy to add them to the string prototype so that you can use them throughout your code.
Adding far-future expiry times for static content in a Java application
Having to serve lots of static content is a common factor in poorly performing websites. It is not unusual these days to have to download 50+ images, 10+ JavaScript files and several CSS files to
PicStrips - a jquery plugin to give your images a little something
PicStrips is a little jQuery plugin that I created after seeing a nice magazine layout by Teresa Wozniak. Basically, the plugin lets you split any image on your webpage into a number of vertical
Allow method chaining for fluent APIs
Method chaining means being able to call multiple methods of an object whilst not having to respecify the owning object on each call. Assume we have an object with three methods, one(), two() and
Plumbers in Bicester
If you need a plumbers in Bicester or the surrounding areas, then I strongly recommend Gordon White as the man for the job. He started his GW Plumbing service in the summer of 2011 after spending
Two things that would really improve PHP
I use PHP to build most my personal projects, I’ve been using it for years and I can get stuff built easily and quickly using it. As a language it does suck a bit, I’ve been tempted many
Java snobbery at its very best
The belief that Java+web framework is a more professional, robust and scalable solution than ‘toy’ languages like PHP, Ruby and Python is one that is widely held by management,
He loved is so much he ate it
Once a little boy sent me a charming card with a little drawing on it. I loved it. I answer all my children’s letters — sometimes very hastily — but this one I lingered over. I sent him a card
Is that why techies don't suit up?
Dress codes…. dressing in a suit if you’re a techie means you’re admitting to not being up to much. Lawyers, M&A bankers dress to impress. Techies/Softies expect to be judged on
Project Euler question #17 solved using Ruby
Here’s the solution for Euler question #17 in Ruby
know = { "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five",
"6" => "six", "7" => "seven",
Project Euler question #9 solved using Ruby
My first ever Ruby script. I’m sure this can be done neater using a list comprehension, but it works, so….
for a in (1..1000)
for b in (1..1000)
for c in (1..1000)
if (a*a +
Project Euler question 7 solved using Groovy
Question 7 on Project Euler reads:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
This was very easy to
Project Euler question 8 solved in Java
Project Euler question 8 is:
Find the greatest product of five consecutive digits in the 1000-digit number.
The 1000-digit number is represented as the big String in the code below.
public class
Project Euler question #6 solved in Java
Project Euler question 6 is:
The sum of the squares of the first ten natural numbers is,
12 + 22 + … + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + … +
Project Euler #5 solved in Java
Project Euler question 5 is:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible
Project Euler #4 solved in Java
Project Euler question 4 is:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made
Project Euler #3 solved in Java
Question 3 on Project Euler is
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
My solution in Java:
public class Primes
{
public
Sieve of Eratosthenes implementation in Groovy
The Sieve of Eratosthenes is one of a number of prime number sieves. Here’s my implementation in Groovy, comments on how this could be improved are very welcome.
//find all prime number up to
Project Euler question #2 solved in Python
Question 2 is:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
Project Euler question #1 solved in Groovy
Learning a new language? What better way to get started than to work through the Project Euler questions.
Here’s my solution to question #1 in Groovy:
def t = 0
(1..999).each {
if ( [it % 3,
Invalid duplicate class definition error (Groovy)
Invalid duplicate class definition of class steve.Test : The source /steve/Test.groovy contains at least two definitions of the class steve.Test
Groovy treats your .groovy file as either a script
Using a temporary array to check for equality instead of multiple if statements
If you have multiple if statements that are checking for equality, something like:
def kingofqueens1(name) {
name = name.toLowerCase()
return (name == "doug" || name == "carrie" || name == "deac"
Checking versions numbers using Javascript
An interesting question popped up on Stackoverflow the other day: How to compare software version number using js? (only number). I think this would make a great interview question to get the
How to use this in JavaScript and live happily ever after
I’ve written before about how the this keyword is used in JavaScript and how problems can arise. This article deals specifically with how to use this without running into problems.
Lets say we
The basics of using the "this" keyword in Javascript.
Douglas Crockford famously said that Javascript is the world’s most misunderstood programming language. How right he was. Javascript is often misunderstood because it’s syntax is very
Website, the special edition
Martin Belam blogged recently about Sunday editions of newspapers and how they are still special editions with different formats, different names and come with extra sections and magazines. He
Still looking?
The web is a great learning resource. We can find a non-stop flow of infomation on any subject we want. How to gain muscle, lose weight, market a product, start your own business - it’s all