Useful Git Configuration Items

29 Aug 2011 • 1 minute read

Name and email address

Each commit you make has your name and email address attached to it. Git will automatically configure these based on your username and hostname, but this information is usually not a good identifier. It is a good idea to set your real name and email address so that your commits can be identified easily.

git config --global user.name "Your Name"
git config --global user.email you@yourdomain.com

Global ignore file

Often there are files or directories that you want Git to ignore globally. These are probably created automatically by your IDE or operating system. Git’s core.excludesfile config allows you to write a global .gitignore so that you don’t have to fill local .gitignore files with clutter.

git config --global core.excludesfile /path/to/.gitignore_global
(Read more)

Deploying a Git repository to a remote server

21 Aug 2011 • 1 minute read

Git’s archive command is basically the equivalent of SVN’s export – it dumps a copy of the entire repository without any of the version control files, making it perfect for deploying to a testing or production server.

(Read more)

Setting up a Web Server on Ubuntu/Debian

23 Jul 2011 • 2 minute read

Setting up a web server with Apache, PHP, and MySQL on any Debian-based system is really easy thanks to APT (Advanced Packaging Tool). Follow along and you’ll have a web server set up within fifteen minutes.

(Read more)

Convert print and echo statements to short syntax

25 Jun 2011 • 1 minute read

It’s debatable whether or not it’s good practice to use short syntax in PHP. I personally prefer to use short syntax because it keeps my view files looking tidy.

The regular expression below will find all one-liner print and echo statements (e.g. <?php print $var; ?>) and convert them to <?= $var ?> statements. It will not match statements containing closing brackets, for example when using ternary operators: <?= ($foo == $bar) ? 'Foobar' : 'Foo' ?>

Find:
<\?php[\s]*(print|echo)[\s]*\(?([^>\)]+?)\)?[\s]*;?[\s]*\?>
Replace:
<?= $2 ?>
(Read more)

Recursively chmod Directories Only

23 May 2011 • 1 minute read

The find utility’s -exec flag makes it very easy to recursively perform operations on specific files or directories.

find . -type d -exec chmod 755 {} \;

This command finds all directories (starting at ‘dot’ - the current directory) and sets their permissions to 755 (rwxr-xr-x).

find . -type f -exec chmod 644 {} \;

Similarly, this command finds all files and sets their permissions to 644 (rw-r–r–).

Thanks to moveabletripe for the info.

(Read more)

Dynamic Virtual Hosts Using .htaccess

21 May 2011 • 1 minute read

There are several ways to set up virtual hosts on your web server. One of the more common methods is to manually create a [<VirtualHost>](http://httpd.apache.org/docs/2.0/mod/core.html#virtualhost) record for each virtual host. While using this method is fine, it can end you up with a huge configuration file that is difficult to manage.

Because all of my virtual hosts are sub-directories of my web server’s base directory, I prefer to dynamically allocate the virtual host directory based on the host name. For example, I want wildlyinaccurate.localhost to point to /var/www/wildlyinaccurate. This can be achieved by modifying the .htaccess file of your web server’s base directory:

(Read more)

CodeIgniter 2/Doctrine 2 Installation

17 May 2011 • 1 minute read

If you want a quick way of getting Doctrine 2 working with CodeIgniter 2, you can download a pre-configured installation from my GitHub repository. There are currently three branches available:

For more information, read my post on integrating Doctrine 2 with CodeIgniter 2

(Read more)

The Music Production Process

5 Feb 2011 • 4 minute read

People who enjoy listening to more ‘traditional’ styles of music often believe that electronic music shouldn’t be called ‘real’ music. They believe that producing electronic music must be so easy, because after all, isn’t it just a few loops played over and over? This is one of the common misconceptions about electronic music production.

I have recently been working on a remix of a Shapeshifter song called Longest Day. To give you an idea of the music production process and how it is much more than looping a few sounds, I’m going to share with you some of the work that I’ve put into this remix.

(Read more)

Useful Doctrine 2 Console Commands

9 Jan 2011 • 3 minute read

Doctrine 2’s console is really powerful when you know how to use it. You can generate entity classes and their method stubs, reverse-engineer a database, validate your entity schemas, and much more. In this post, I’m going to cover some of the Doctrine console’s more useful commands and explain how you can use them to reduce development time. For a full overview of the Doctrine 2 console, read the Doctrine Tools documentation.

(Read more)

Beer Review: Renaissance Elemental

24 Nov 2010 • 1 minute read

I touched briefly on the Renaissance brewery while writing about their Craftsman stout, in My Top Five Beers. Founded by Californians Andy Deuchars and Brian Thiel in 2005, Renaissance is located in the historic Grove Mill in Blenheim, New Zealand. Their beers have been available to the general public since 2006, and have been winning awards ever since. The Elemental porter is Renaissance’s most awarded beer, having won gold medals in New Zealand and Australia. More recently the Elemental received a silver medal at the Australia International Beers Awards in May 2010.

(Read more)

eAccelerator and Doctrine 2

13 Nov 2010 • 1 minute read

A word of warning: eAccelerator does not play well with Doctrine 2. This came to my attention today after I installed eAccelerator so that I could measure the performance gains (if any). As it turns out, one of eAccelerator’s “features” is to remove DocBlocks from PHP scripts - probably to reduce compile times. Suddenly my application was throwing exceptions with the message “Class X is not a valid entity or mapped super class”.

(Read more)

Segment-Based URLs with Query Strings in CodeIgniter 2

9 Nov 2010 • 4 minute read

My latest CodeIgniter 2 project requires that I use query strings in some of my URLs. CodeIgniter 1 was notoriously difficult to work with when you enabled query strings, and unfortunately CodeIgniter 2 is no different. Whereas in CodeIgniter 1 you could change two configuration options to enable a combination of segment-based URLs and query strings, this same approach only makes matters worse in CodeIgniter 2.

(Read more)

Custom Doctrine 2 Console Commands

5 Oct 2010 • 4 minute read

This post assumes you have set up Doctrine 2 with CodeIgniter 2.

Load Data from Fixtures

I could not find a command to load data from fixtures, so I made a very basic command that recursively executes native SQL. If you want to load data from YAML files, you will need to search elsewhere for a YAML interpreter or even a way to convert YAML to SQL.

(Read more)

My Top Five Beers

27 Sep 2010 • 5 minute read

Before I start this list, let me explain something. I am not a beer connoisseur; I haven’t tried every beer under the sun. I am actually quite picky when it comes to drinking beer. I have no tolerance for the beer-flavoured fizzy water that multi-billion dollar companies like Carlsberg and Heineken produce. I do not enjoy beers that are “low carb” or “light”.

Well then, what beers do I like? Stouts and dark ales, of course! So really, this isn’t a list of my top five beers. It’s a list of my top five dark ales and stouts.

(Read more)

Integrating Doctrine 2 with CodeIgniter 2

26 Sep 2010 • 11 minute read

If you’re looking for a quick way to get Doctrine 2 running with CodeIgniter 2, you might want to download my CodeIgniter 2/Doctrine 2 package

Overview

CodeIgniter is a great PHP framework. The codebase is clean, the documentation is fantastic, and it’s regularly updated. Doctrine is a good ORM for the same reasons: it’s very well-written, has extensive documentation, and is actively developed. A combination of these two systems makes it easy to build database-oriented web applications quicker than ever before.

To get started, download CodeIgniter 2 and Doctrine 2 – make sure you use the ‘Download Archive’ link when downloading Doctrine.

(Read more)

← Newer Posts