About Jamie on Software

Jamie on Software is the online journal of web developer and writer Jamie Rumbelow.

Jamie likes books, guitars, programming, open source and food. He writes about these things too. This is where he puts the things he writes.

My Books

Tags
Tweets
Feeds
We Love
Powered by Squarespace
Thursday
Apr072011

My Blogging Process

As you’ve no doubt noticed, I’ve been blogging a lot more recently. I’ve been making a conscious effort to write much more, not only in an effort to enhance my education but also as an outlet for my creativity and energy. Anyone who knows me will know I’ve got a lot of both.

I’ve been experimenting with different tools to help me blog better. After a few weeks of trialling, I think I’ve hit upon the sweet spot.

My current blogging process looks like this:

  1. Write the post in WriteRoom. WriteRoom is a brilliantly simple text editor that lets me block everything out and get shit done. I’m using Markdown to write the posts; I love being able to unobtrusively format my posts in a fully textual environment.
  2. At this point, I’ll either head straight to my blog and post it on there - I host with Squarespace, and they support Markdown directly - or I will open up TextMate and use the fantastic Markdown bundle to convert my post to HTML in a single button press. It’s Control + Shift + H, if anyone’s interested.
  3. Use MarsEdit to preview and make any final modifications to the post before adding tags and hitting submit. MarsEdit supports all kinds of blogs and protocols, so you’ll probably be able to use it with your blogging platform.

The process above means that I can write peacefully, without distractions and in a decent environment, before being able to tweak and edit in a different tool and publish straight to my blog. And here are the tools that make it happen:

  • WriteRoom. It’s a writer’s paradise.
  • Markdown. Improving the world’s text formatting, one character at a time.
  • TextMate. The best, nay, only code editor anyone should use ever.
  • markdown.tmbundle. Brilliant Markdown support for TextMate.
  • MarsEdit. Brilliant blogging tool with multiple blogging platform support and clever preview generation.
  • Squarespace. A powerful and beautiful web publishing platform.

What does your blogging process look like?

Wednesday
Apr062011

Getting to know ExpressionEngine 2’s config file - Part 1

Configuring ExpressionEngine is a black art; the layout of configuration values in the control panel isn’t particularly well thought out. Some values are on one page, others are on a different page, and the whole thing needs much more logical grouping.

Additionally, storing configuration in the database has its own set of downfalls: deploying sites is a real pain because DB values need to be updated and some of them are even encoded in the database. Accessing and modifying them quickly becomes cumbersome.

Thankfully, EE can be configured through an alternative method. You can override pretty much any configuration value in ExpressionEngine in the expressionengine/config/config.php file.

But why would you want to? As I’ve just stated, most of ExpressionEngine can be configured in some way or another from within your config file. This allows you to contain your entire system’s configuration in one accessible place, making it simple and brief to change a system setting.

Additionally, having config values in a file rather than the database makes deploying your EE website much, much easier. Using a few clever techniques can help you run your site in multiple environments and on different servers without having to make any changes between deploys.

One of the really beautiful things about holding your system values in your config file is that your entire’s system can be held in version control. I’ll discuss the merits of using a version control system with EE entirely some other time, but the ability to switch between versions, use branching and distributing files to others with ease barely scratch the surface. The number of benefits is staggering.

Let’s see some code. The following is an example of a very basic config.php that can be used for simple, one server ExpressionEngine projects.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/* ExpressionEngine Configuration
-------------------------------------------------------------------*/
$config['app_version'] = "213";
$config['license_number'] = "0000-0000-0000-0000";
$config['debug'] = "1";
$config['install_lock'] = "";
$config['system_folder'] = "system";
$config['is_system_on'] = "y";
$config['allow_extensions'] = "y";
$config['site_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['server_path'] = FCPATH;
$config['cp_url'] = $config['site_url'] . ‘/system/‘;
$config['theme_folder_url'] = $config['site_url']."/themes/";
$config['theme_folder_path'] = $config['server_path']."/themes/";
$config['save_tmpl_files'] = "y";
$config['tmpl_file_basepath'] = $config['server_path']."/templates/";

/* CodeIgniter Configuration
-------------------------------------------------------------------*/
$config['base_url'] = $config['site_url'];
$config['uri_protocol'] = 'AUTO';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['subclass_prefix'] = 'EE_';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\\-';
$config['enable_query_strings'] = FALSE;
$config['directory_trigger'] = 'D';
$config['controller_trigger'] = 'C';
$config['function_trigger'] = 'M';
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['time_reference'] = 'local';

/* End of file config.php */
/* Location: ./system/expressionengine/config/config.php */

It looks like a lot of code, but if you take a brief look it’s actually all very simple. Firstly, I’ve cleaned up the original config file by removing most of the comments and grouping the file up by ExpressionEngine configuration and CodeIgniter configuration. As our file gets bigger we can group even further.

I’ve also removed many of the configuration values that we won’t be touching. You’ll be surprised at how few configuration values we actually need to use in our config file; and that includes CodeIgniter.

Our first few lines of code:

$config['app_version'] = "213";
$config['license_number'] = "0000-0000-0000-0000";
$config['debug'] = "1";
$config['install_lock'] = "";
$config['system_folder'] = "system";
$config['is_system_on'] = "y";

These are the basic, default ExpressionEngine configuration variables. The current EE version, your license number, debug settings, install lock, name of the system folder and the current system enabled status. It’s all self-explanatory.

You’ll almost always want to enable extensions (and can sometimes get caught out if you don’t!) so we’ll do that in our config file to make sure it happens.

$config['allow_extensions'] = "y";

We’ll also semi-dynamically set our server path and URL, so that if we decide to update our domain name, or push the site live, our configuration changes will be minimal. We can use the HTTP_HOST server variable value to get the current domain. Likewise, we can use CodeIgniter’s FCPATH to get the path to our front controller. In most cases this is your index.php file.

$config['site_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['server_path'] = FCPATH;

Setting these means that we can use them later in the config file. Lets make some other paths and URLs dynamic. The path and URL to the themes directory is really important, so let’s set them to be relative to our site_url and server_path.

We will also set our CP URL to be relative to our aforementioned site URL. Finally, we can enable saving templates as files from the config file and set the directory dynamically.

$config['cp_url'] = $config['site_url'] . '/system';
$config['theme_folder_url'] = $config['site_url']."/themes/";
$config['theme_folder_path'] = $config['server_path']."/themes/";
$config['save_tmpl_files'] = "y";
$config['tmpl_file_basepath'] = $config['server_path']."/templates/";

Using your config.php file to configure and maintain your ExpressionEngine install is easy. While this is a simple example, it’s immediately practical, and can help you get on your way to better EE installations.

In a future post I’ll demonstrate how you can create a multi-server setup in your config.php file and let ExpressionEngine be truly dynamic.

Saturday
Apr022011

Biphasic Sleeping - It’s not for me (yet)

Over the past two days, I have been trying out an experiment in biphasic sleeping. I had hoped to increase my energy during the day, spend more time awake and get up earlier. I had hoped to have better quality sleep. After two days, however, I’ve decided to end this experiment.

Before you judge me, I’ve got a simple and important reason.

I’m a teenager.

It has become apparent that I am one of those people that just needs large amounts of good sleep.

While this is the end result of biphasic sleeping, I do not have the self-discipline or motivation to continue. I knew I would struggle with the adaptation phase, but this morning I slept through my alarm. And this triggered a different alarm in my head. It made me realise I can’t be trying to revise and work if I’m feeling tired all the time.

I can’t hedge my bets that I’ll get used to it, that my body will adapt. I can’t be going to school on Monday feeling as bad as I felt yesterday. I can’t run that risk.

I need to find another solution to my sleeping issues. I’m going to try to get up at 6:30 each morning anyway and go to bed at, say 11pm; I like having time in the morning to get up leisurely. I’ll try to go running every morning, perhaps more exercise will make me sleep better?

To anyone thinking about biphasic sleeping: don’t expect adapting to be easy. I’m sure that it’s fantastic once you’ve adapted, and I will encourage anybody to give it a go. I just don’t have the will or energy to go through this fatigue.

I’m a teenager. I need more sleep than adults. So until I become comfortable on less sleep, I’m going to keep sleeping monophasically.

Perhaps, some time in the future, I will give it another go.

Thanks to everyone who has been interested in this little experiment, and apologies for letting you all down.

Friday
Apr012011

Biphasic Sleeping - Day 2

It was only 35 hours ago that I decided to take the plunge into biphasic sleeping. I always knew my second day would be a struggle, but, my god, this is more difficult than I anticipated. I've got pains across all my muscles, including my eyes, and caffeine only relieves it for a few moments.

I'm struggling to concentrate and have to be thinking all the time to just stay focused. My motor skills are impaired, and typing and writing is difficult. Right now, I'm at home on my own. I'm expecting to get into the rhythm of the day and be feeling better by lunchtime, but right now it's ghastly.

Yesterday's nap was nice, but not quite what it should be. It'll take a few days to get used to sleeping in the day, so until then I can't expect it to be brilliant. I dreamt two very weird dreams in my one nap, and woke up in the middle. Give it time, but it seems to be on the right track.

Last night's sleep was lovely, until I had to wake up. I managed to scrape together enough discipline to get out of bed but I fear that won't perservere. If I'm not feeling well after my nap, I'm not sure I'll wake up tomorrow morning. Thank god it's Saturday and doesn't matter.

I'm remaining optimistic. My body needs time to adapt. Until then, I'm going to struggle through school on high-caffeine drinks. Have a good day.

Clearly, I don't work well without sleep.

Friday
Apr012011

A radical new shift in data storage; Rumblestorage

Last night I had an epiphany. I was working with one of those old, cruddy databases, and it got me thinking. Why isn't there a better solution? Why am I doomed to use legacy systems such as MySQL and MongoDB for the rest of eternity? So, I began researching alternatives. And when I couldn't find any, I chose to write my own.

I am proud to announce Rumblestorage. From now on, every project of mine will be using Rumblestorage as its data storage medium. I hope that you too can see the light and understand that, frankly, databases just don't cut it any more.

Rumblestorage utilises the native capabilities of your language and stores everything in a flat text file; a simple and elegant solution. It brings your data into memory at class instantiation and saves it on destruction. It has a beautifully usable API. It's clear that in this 21st century world, databases are just far too restrictive. Your storage engine should be built specifically for your programming language; it should be fast, easy to use and above all flexible.

Best of all, Rumblestorage is free and open source, available on GitHub. I'm already in talks with the CodeIgniter Reactor team as to integrate Rumblestorage as a replacement for the old and tired database class.

Access the source code at GitHub, and feel free to fork and make your contribution to the future of data storage!

Page 1 ... 7 8 9 10 11 ... 12 Next 5 Entries »