Enforce Coding Standards with PHP_CodeSniffer and Eclipse IDE on Ubuntu Linux
Visualising Website Performance with Flame Graphs
Getting Set up with Ogre 3D on Ubuntu
Book Review: How to Implement Design Patterns in PHP
JQuery Venetian Blinds Transition Effect
Native Linux Space Warfare: Freespace 2

Principles of the Doctrine ORM in Symfony

Friday, 1st October 2021

I've been using Symfony professionally for a year now, and it's a framework which I really like. However some of the details of the usage of the Doctrine ORM were a bit unclear for me, so I took a moment to read through the documentation more thoroughly and I'm summarising the key principles here.

Managed Entities and the Identity Map

One thing to remember is that, as you work with entities retrieved from and saved into your database, Doctrine will maintain its own separate collection of entities. When you are handling a web request and fetch an entity from the database for the first time, Doctrine will add that entity to its own collection. The next time you ask for the same entity in the same request, Doctrine will not fetch a new copy but instead return a reference to the previously fetched entity. This internal collection is called the Identity Map, because it contains entities which are mapped to those in the database by their "identity" (i.e. their primary

read more ..

VR on Linux

Sunday, 27th November 2022

Currently the two best-supported choices for VR on Linux are the original HTC Vive headset (the plain HTC Vive and also the Vive Pro v1 - but not the Pro v2) and the Valve Index. These both have native SteamVR support for Linux. That said, SteamVR has its bugs and not all of its features are available on Linux, but as long as you force the GPU to performance mode (so that it doesn't ever downclock and cause stutter) and can tolerate the SteamVR issues it's still a great experience. The main issues on Linux are that camera passthrough isn't implemented, and SteamVR doesn't manage lighthouses for you automatically (or at all). For the latter issue, while there's no real harm in letting them run 24/7, you can just unplug/turn power off manually, or write a script or find an Android app to put them to sleep and wake them up so they're not running all the time. Also be aware that Gnome doesn't yet support DRM leasing as required for VR to work on Wayland, so you need to use X server

read more ..

Moving Arch Linux to a new SSD with rsync

Thursday, 11th July 2013

So we all got shiny new SSDs at work recently, and I was keen to get a new Arch installation up and running from the lovely new silicon. A bit-wise clone of the old disk's contents wouldn't work for me, as that was still formatted using ext3, and I wanted to use this opportunity to switch to ext4.

My initial plan was to just install a fresh copy of Arch from a USB, and it was as I was doing this that I realised I should be able to do the exact same procedure but from my existing Arch installation. After all, the Arch install process simply boots you into a minimal Arch on your USB drive (or CD-ROM/DVD), and then installs onto the target drive with the help of chroot. So, from my old Arch system, I tried the standard install procedure of running the pacstrap script. This script was not available however, and I couldn't immediately find it in the repos.

As I was searching online for suggestions, I came across

read more ..

How to Rollback a System Update on Arch Linux

Friday, 6th April 2018

After updating my system recently (with pacman -Syu), Wine games stopped recognising my gamepad. Native games had no problem,so my first thought was the Wine version bump from 3.4 to 3.5. However, the gamepad still didn't work after downgrading to Wine 3.4, so it seemed that one of the other packages in the upgrade must be the culprit.

There had been a total of 94 packages updated, including the Linux kernel. I didn't relish the idea of manually downgrading each likely package one by one, so I did a bit of Googling, and found out about the Arch archives. All older versions of Arch packages are stored here - a total of over 100,000 packages.

The archives make it easy to roll back your system to any date in the past. All you need to do is point pacman at the archive specifying the date you want to roll back to in the URL, refresh your local package database and upgrade your system.

So

read more ..

Visualising Website Performance with Flame Graphs

Sunday, 17th May 2020

As well as allowing you to step through code line-by-line, and to record profiling data, Derick Rethans' Xdebug can log all function calls, including parameters and return values, to give further insight into how your code runs. These "function traces" can be dumped as HTML, human-readable text or in a machine-readable format that can be read by other software packages to create visualisations.

One such visualisation is the "flame graph", created by Brendan Gregg, a performance engineer at Netflix. Brendan has released a tool written in Perl that we can use to create flame graphs from Xdebug traces.

Generating Function Traces with Xdebug

First, we need to set up Xdebug to create the function traces we need.

read more ..

Switching from netctl to networkd with iwd

Sunday, 12th January 2020

On a fresh install of Arch Linux, systemd will be set up with its default network service, networkd, and its name resolution service, systemd-resolved, enabled along with a configuration file that will create a wired ethernet connection using DHCP. For existing installations, this service won't necessarily be running, so check with:

systemctl status systemd-resolved systemd-resolved
If either are not already running, start and enable them:
sudo systemctl enable --now systemd-networkd systemd-resolved

Wired/Ethernet Connections

We've now got all we need to establish wired ethernet networks. For each connection, you'll need to create a config file in /etc/systemd/network/ with a name that ends in .network. These will be processed in alphabetical order, so the

read more ..

Relocating Eclipse Projects: The project description file (.project) for XXX is missing

2 Nov 10

Recently I changed the name of the mountpoint where my Eclipse projects are located, and while a lot of my projects opened without any problem, others would not, instead generating the error message:

The project description file (.project) for PROJECTNAME is missing

By default, Eclipse will look for the .project file in the root directory of the project itself. In some cases though, you may want to have the .project file outside of the main project directory, and you can do

read more ..

Book Review: How to Implement Design Patterns in PHP

31 Oct 10

Matt Zadstra's book, PHP Objects, Patterns and Practice, aims to give an overview of sound OOP design in PHP applications, with a direct focus on Design Patterns. Design patterns describe high-level algorithms that form part or all of the application's software architecture.

Software Architecture

Software architecture relates to the high-level view of a system:

  • how it is organised into components
  • the relationships between the components and each other and the
read more ..

Profiling PHP using XDebug and Webgrind

15 Sep 14
Derick Rethans' Xdebug is a really useful PHP extension that lets you step through code line-by-line as it executes, watching variables and seeing exactly what's going on.

Line-by-line debugging isn't the only way this extension allows you to examine and improve your code though, as it can also profile your code to let you see how much time each part of your script takes to execute.read more ..

GSM Internet on Raspberry Pi using Huawei E8372 WiFi Dongle

25 Dec 19

The Huawei E8372 WiFi dongle (aka "wingle") is a pretty cool device. Like any WiFi dongle, it acts as a GSM modem allowing you to connect a PC to the internet wherever you have mobile signal. It supports 4G, allowing downloads at up to 5 Mb/sec. In addition to this however, the Huawei also contains a fairly well-specified WiFi router. This makes the dongle a standalone WiFi hotspot - you can plug the dongle into one PC which connects via USB, and then connect other devices (such as phones or

read more ..

Git Pre-commit Hook to Block Accidental Commits

1 Dec 18

Here's a simple pre-commit hook to prevent you commiting files you don't want to:

#!/bin/bash git diff --cached --diff-filter=AM | grep -q gitblock if [ $? -eq 0 ] then echo gitblock comment detected exit 1 fi
Save it as .git/hooks/pre-commit in the repo you want to protect, make it executable, and it will prevent you commiting any file that contains the text "gitblock" in a comment.

The hook uses git diff's --cached argument to get all

read more ..

Nice n' Easy JQuery Image Rotator

9 Sep 11

There are a myriad free libraries out there that offer JQuery image rotator functionality. The idea is simple enough - cycle through a series of images, smoothly transitioning between each using some effect or other.

So why code your own? Simplicity and control are the main reasons. Unless you're already loading up a 3rd-party rotator library, why add to the bandwidth overhead? Some of those libraries can be quite time-consuming to get to grips with, so a roll-your-own solution can be

read more ..

Scrollable Tables with Floating Header using CSS

10 Dec 16

The secret here is to contain your table's rows in <thead> and <tbody> sections, and set these to display:block. Click Activate Demo to view the scrollable table:
read more ..

Going Back in History with AJAX and HTML5

13 Sep 11

Web pages have become increasingly dynamic in recent years, with more and more content being fetched, manipulated and saved in the background with AJAX. This breaks the traditional connection between the URL and the displayed document: no longer does a URL refer uniquely to one single document. This causes problems for users, because browsers use the URL when storing pages in history. Browser history is implemented as a stack, a last-in, first-out (FIFO) structure. As you navigate through the

read more ..

JQuery Venetian Blinds Transition Effect

24 Aug 11

JQuery has a few transition animations built in, such as the 'blinds' effect. This lets you unhide content by revealing it as if a blind were being pulled open in front of it, and vice versa to hide content.

I've built a variant on this idea that gives the effect of a venetian blind:

read more ..

JSON Encode your Classes in PHP

22 Jun 15

The built-in json_encode() function doesn't by default include any of your own classes' properties, and all you'll see is an empty pair of curly braces.

PHP 5.4 introduced the JsonSerializable interface to rectify this. It defines a single method called jsonSerialize() where you specify how your class should be converted to JSON.

Whatever this method returns is what will appear in the encoded output of json_encode(). You can return a number, a string, an array

read more ..

PHPUnit Tests when a Class uses Multiple Databases

26 Jun 13

PHPUnit supplies the PHPUnit_Extensions_Database_TestCase class which can be extended by your tests when you want to run tests that check the state of a database after some or all tests. This is all well and good, but you will soon notice that its methods that you override in your test class to connect to and populate a database (getConnection(), getDataSet()) only support a single database.

If you want to test code that accesses multiple databases, you can

read more ..

Symfony 2 Crash Course

24 Oct 15

Symfony is a collection of over twenty libraries, called the Symfony Components, that can be used by themselves in any PHP project. The idea of these classes is to perform many of the common tasks found in web projects, such as encapsulating the request and response, creating forms and handling form submissions, handling security and templating. Various third-party libraries are incorporated into the Symfony framework along with the Symfony Components. The Symfony framework provides classes

read more ..

Linking Symfony to a Database with Doctrine

25 Oct 15

Now that we've covered the basics of Symfony and have created a project using the installer, let's move on to see how we can access a database from our Symfony app.

The Doctrine Project produces an Object Relational Mapper (Doctrine ORM) and the Database Abstraction Layer it is built on top of (Doctrine DBAL). The Doctrine Project is an independent open-source development team with no direct connecton to Symfony or

read more ..

Using SSH Tunnelling to Access a Local Network Remotely

6 Jan 10

First set up the tunnel like so:

ssh -D 8080 -N REMOTEUSER@REMOTEHOST
You can also add the -f switch to make this run in the background. What this does is to forward connections to port 8080 on the local machine to the remote server over SSH (i.e. encrypted).

Once it's active, you can configure applications to use the tunnel by setting up a SOCKS 4 or 5 proxy for them.

In Firefox, go to Edit > Preferences, then choose the Network tab on the

read more ..

Optimising MySQL

25 Jun 08

Natural vs Surrogate Primary Keys

The primary key (PK) of a table is a column or set of columns which uniquely identifies each row of the table. A natural primary key uses actual properties (ie columns) of an item. For instance, if you have a table of cars, you might choose to use the registration number as primary key. This would be a natural primary key.

A surrogate primary key on the other hand is one which has been created specifically for the purpose. Generally this takes the

read more ..

ENUMs, User Preferences, and the MySQL SET Datatype

6 Mar 10

The MySQL SET datatype is a very space-efficient way to store sets of binary flags. It's a little like the ENUM type, in that you define a range of possible string values, but unlike the ENUM, a column that holds a SET can have any number of the string values at one time.

It's useful to consider how MySQL stores SETs and ENUMs in order to appreciate what benefits they can bring.

Here's a simple table with an ENUM column and a SET column:

read more ..

A Simple ISAPI Filter for Authentication on IIS

12 Dec 07

The MDSN samples include a C++ project for building a ISAPI DLL which performs authentication for web resources against a text file. This project, AuthFilt, is one of the samples supplied with the .NET Platform SDK, available from here. Once you've installed the SDK, the sample code is located in the AuthFilt folder at Program Files\Microsoft Platform

read more ..

MySQL Changes from Versions 4.1 and 5.0 compared with 5.5

10 Feb 12

Under the hood, there are multiple performance improvements in MySQL 5.5. These mostly target the InnoDB engine, but there are several that will improve MyISAM tables. However, InnoDB becomes the default storage engine from version 5.5 onwards. InnoDB supports true ACID Transactions (groups of statements which are only committed if they all succeed), Referential Integrity (which enforces foreign key constraints on a DB level), and improved crash recovery. The cost is increased disk space usage,

read more ..

Setting up a Git Repository on CentOS 5

29 Jul 11

If you are setting up version control, and have access to a managed server, you may decide to create your central repositories on that server, so that all developers can access the repo from wherever they are: in the office, at home, on the beach etc etc

Many managed servers use CentOS, the commercial version of RedHat Linux. If you can find a source repo with git in it, you can install using yum:

yum install git
However, you're quite likely to come up against

read more ..

Using Multi-Byte Character Sets in PHP (Unicode, UTF-8, etc)

15 Oct 08

The following list details the PHP string functions which could cause problems when handling multi-byte strings. The multi-byte safe alternative is given when available:

Try mb_send_mail() instead.


read more ..

Using PHP pspell Spell Check Functions with a Custom Dictionary

2 Jan 08

The pspell_* functions are a very useful feature of PHP, allowing you to scan text and highlight words which are potentially misspelt. Pspell implements the open source aspell spell-checking routines in PHP.

Basic Usage

Before using the functions, you need to open up the dictionary you're going to use by calling the pspell_new() function, specifying at least the language to use. You can also specify a second argument, if the language you plan to use has multipleread more ..

inotify resources exhausted

11 Oct 13

inotify is a part of the Linux kernel which watches the filesystem for changes. It is used for many different applications that need to react when there are changes to files in a specific location. For each location an application wants to monitor, it has to add an inotify watch, so apps can easily need a *lot* of these watches.

The system defines a maximum number of inotify watches that can be active at any one time. To see what is set on your system, run this command:
[code

read more ..

How To Make a Firefox Add-on

23 Jan 14

There are two ways to develop a Firefox add-on: the old XUL way and the New SDK Way. The old way uses a combination of JavaScript and XUL, along with an RDF file to describe the extension so that it can be correctly installed. XUL is XML mark-up that's similar to HTML and allows you to define UI components, aka widgets, by creating a XUL Overlay, which is merged with Firefox's built-in 'master' XUL. It's not recommended to

read more ..

Changing Mailman Python Scripts for Virtual Host Support

22 Sep 09

Mailman is a tried-and-tested Open Source mailing list manager. It's robust and reasonably efficient when running, however it organises lists internally by their local name only. In other words, you can't have one list called maillist@domain.org on the same server as another list called maillist@somewhereelse.com on the same machine, unless you have a separate mailman installation for each domain.

Many production environments do appear to use the separate installation per domain approach,

read more ..

File Structure of ezmlm Mailing Lists

25 Nov 09
The ezmlm mailing list stores configuration options for a list as files on the file system (rather than using a config table in a database, or even a single config file).

In order to migrate a list from ezmlm to another list manager, such as mailman, it's necessary to understand the file structure in order to work out how the list is configured.

Changing Git Repos to Use an External Drive as Origin

20 Apr 18

I've always had multiple computers at home on which I do development work. Every time I start a new project on one machine, I will clone it from that machine onto any others as and when I want to work on it from another machine. The drawback of this approach is that in order to push and pull commits, the origin computer has to be turned on. There's also a minor annoyance in that the origin for different projects will be arbitrarily on any one of the machines I own. Right now I'm traveling away

read more ..

Enable 5.1 Linux Audio on Motherboards with Only 3 Jacks

22 Dec 11

If you're running Alsa on your Linux distro, without pulseaudio (e.g. Arch Linux, SUSE), and your onboard audio only has 3 Jacks - Line In, Speaker, and Mic - but supports 5.1 audio, follow these steps to enable it.

Add the line below to a file called /etc/modprobe.d/options. If the file doesn't exist, create it.

options snd-hda-intel model=3stack-6ch
Note that the model identifier you use will depend on the particular audio chipset installed on your system.

read more ..

Changing XFCE Settings by Script

5 Jul 15

XFCE can be configured through the usual array of settings dialogs, where you can alter settings for displays, power management, audio and more. XFCE also provides the xfconf-query tool for querying and setting the configuration on the command line. When run with just the -l argument, xfconf-query outputs a list of channels:
read more ..

Updating MySQL and PHP to Store IPv6 Addresses

16 May 15

More and more people are using IPv6 on their systems, and this longer format requires a larger datatype for storage in MySQL. IPv4 addresses can be saved in a MySQL or MariaDB UNSIGNED column with the INET_ATON() function. If you put an IPv6 address into this function though, it will return NULL indicating unrecognised (you'll see this as the address 0.0.0.0 if you're displaying it with INET_NTOA()).

The

read more ..

The iCalendar Format for Sharing Scheduling with PHP

6 Mar 15
iCalendar is a format for sending out meeting requests that are handled by email clients like Outlook and Thunderbird.

- iCalendar data has the MIME content type text/calendar
- The filename extension of ics is to be used for files containing calendaring and scheduling information
- By default, iCalendar uses the UTF-8 character set
- Each line is terminated by CR+LF
- Lines should be limited to 75 octets (notread more ..

Installing Xdebug for use with Eclipse or Netbeans on Linux

4 Jan 11

There are 2 recommended ways of installing xdebug: with your system's package manager, or via PECL.

Installing via Package Manager

If your distro includes Xdebug in the package repositories, this is probably the easiest way to install it and keep it up to date. For Ubuntu:
sudo apt-get install php5-xdebug
For Arch:
sudo pacman -S xdebug
This will install into the default location for PHP extensions ie /usr/lib/php/modules/. You will need to

read more ..

Enforce Coding Standards with PHP_CodeSniffer and Eclipse IDE on Ubuntu Linux

9 Apr 10

The PEAR PHP_CodeSniffer project provides an invaluable tool for enforcing a consistent set of coding standards across a whole PHP project. Thanks to the guys at PHPsrc, it can now be installed as an Eclipse plug-in, to provide annotations about code standard violations right in your editor:



In order to get this set up and running, you first need Eclipse 3.3 or greater. You can download the package with PDT incorporated from

read more ..

Native Linux Space Warfare: Freespace 2

31 Mar 12
Freespace 2 is an ace game, atmospheric, moody, with lots of huge spaceships squaring off against each other in epic battles teeming with smaller craft, explosions and mega-death blastrays. The sound effects are good, the story compelling, and even the voice acting is well done.

Or at least it was, when I first played it over 10 years ago. It's since been open sourced, and the community open source project is still livelyread more ..

Fix Ugly Fonts in Netbeans under Linux

11 Nov 13

By default, Java doesn't use anti-aliasing on fonts in AWT applications. It's been available for some time however, and can be switched on with the awt.useSystemAAFontSettings setting.

To enable anti-aliased fonts just for Netbeans, add -J-Dawt.useSystemAAFontSettings=on to the end of the netbeans_default_options line in /usr/share/netbeans/etc/netbeans.conf e.g.:

read more ..

jQuery Tab Select Control

3 Dec 13

HTML:

</p><div id="tabbar"> <div class="open">Details</div> <div>Package</div> <div>Databases</div> <div>Reviews</div> </div>   <div class="panel open"> Simple panel with Tabs </div>   <div class="panel"> Super Beauty Magic Rabbit Tab Panel 2.6.3 </div>   <div class="panel"> Mega Ultra Droingo Database 9.6.4 </div>   <div class="panel"> "I never thought a tab panel could change my life, until I tried Super Beauty Magic Rabbit Tab Panel 2.6.3" </div>
CSSread more ..

How to Run Internet Explorer 7, 8 and 9 in Linux with or without Wine

29 Jun 12

Microsoft have a wonderfully long history of badly designed software that they're proudly continuing to this day with the abomination of IE 9 and the ghastly sham that is Windows 7. It's a tribute to the skills of the many hard-working marketing heads over at Redmond that despite the poor quality and the easy availability of superior cost-free alternatives, people the world over keep coming back to Microsoft like hookers on crack.

IEs4Linux

IE's popularity has exasperated professional

read more ..

Customising Joomla

20 Nov 06

My first task is to investigate how we can create a single consistent look & feel for the admin GUI. I'll need to get a good understanding of how the admin GUI works and is organised.

When the admin first logs in, you have a grid of square buttons on the left, and some stats on the right. The page shows as index2.php in the address bar.

index2.php has the following structure:

  • includes
  • start session
  • get option and task request
read more ..

Mocking External Services with PHPUnit

20 Mar 12

The basic idea behind unit testing is that the different components of an application can be tested individually (as a unit no less) by calling each component from a test application passing in a range of suitably picked parameters. When these automated tests fail, the idea is that they will pinpoint where the problem lies and what causes it.

Unit testing is naturally suited to OOP systems, as classes are very modular components that can be readily instantiated and tested in isolation by

read more ..

Scaling and Cropping AVI with mencoder

14 Nov 10

The following are mencoder's video filter options, and must be specified after -vf. You can specify multiple filters, by separating them with a comma, and the filters will be applied left to right.
read more ..

Getting Set up with Ogre 3D on Ubuntu

25 Apr 11

The Open Source Code::Blocks IDE is the recommended choice on Linux systems, and it's available in Ubuntu's Software Centre. Install this first if you don't already have it.

On Ubuntu, you need to add the Ogre PPA and update your package list before installing the libogre-dev package (containing the Ogre 3D development libraries) and the sample projects:

read more ..

Installing Pidgin's Embedded Pictures and Video Plugin

24 Jan 13

You'll need the following dependencies:

sudo apt-get install pidgin-dev libpurple-dev libglib2.0-dev libwebkit-dev libcurl4-openssl-dev
Then get the plugin source code and extract it:
wget http://geekr.googlecode.com/files/pidgin-embeddedvideo-imageview.tar.gz tar -xvf pidgin-embeddedvideo-imageview.tar.gz
Finally compile it:
cd pidgin-embeddedvideo-imageview/ ./configure --prefix=/usr make sudo make install
Now enable

read more ..

Command-line PHP script to remove duplicates from bash history

29 Nov 12

For some reason, the erasedups option for bash history appears to have stopped working. Until I work out why and fix it, I wrote this PHP script to perform the same function.

read more ..

Upgrading the Root Filesystem from EXT2 to EXT3

24 Jan 12

Before starting, it's a good idea to run a disk check. Run the following command to create the necessary file and then reboot:

sudo touch /forcefsck
The following command converts the filesystem to EXT3, by creating the necessary journal.
tune2fs -c 0 -i 30 -j /dev/sda1
Edit /etc/fstab replacing ext2 with ext3 for the root filesystem mount.

Next we need to rebuild the Linux boot image using the mkinitrd tool.

Unrolling the

read more ..

IPsec and other jargon

13 Nov 05
Editing a book about creating VPNs on Linux with IPsec. 200-300 pages long, which works out at about £450.

Compiling and Installing on Ubuntu Linux

17 Oct 08

Compiling from .tar.gz

The archive contains the source code files and supporting resources (bitmaps etc). So we'll need to compile this to make our executable program.

First extract the archive somewhere. I use a subdirectory off my home called src:
cd ~/src tar -zxvf ~/download/newapp.tar.gz
If the archive is compressed with bzip (extension is .bz2), use option j instead of z:

read more ..

Restricting Bandwidth on Mac OSX

16 Aug 11
If you're on Mac, you can throttle your own bandwidth with the following two commands:
sudo ipfw pipe 1 config bw 200KByte/s sudo ipfw add 1 pipe 1 src-port 80
To remove the throttle, use:
sudo ipfw delete 1
Legal warning: Macs suck and are grotesquely horrible contraptions. Making intelligent healthy people use them is dangerous, inhuman and illegal in many countries.

Move home Folder from its own Partition to the System Partition

29 Nov 08

There's a lot of articles on the web explaining how to move a Linux home folder (containing all the user accounts) from the system partition onto its own partition.

I wanted to do the reverse procedure, and move my separate home partition to a regular home folder on the system partition. The only problem is that home can contain a variety of files and symlinks that wouldn't all get copied correctly with the mv command. The cpio archiving utility, available on a default Linux

read more ..

Using the JavaHL Native SVN Library in Eclipse

28 Apr 10

With later versions of Eclipse and/or the SVN plugin, you have the option of using the Java native interface (JNI) library for Subversion support. For performance and platform independence, Subversion is written in C. The JavaHL library is written by the Subversion team, and basically provides Java wrappers for Subversion's C API. You can use SVNkit, which is a pure Java Subversion library, but until you've sorted it out one way or the other, you're likely to see lots of error messages reading

read more ..

Oolite on Ubuntu from Source

31 Jul 11

Oolite is an open source space trading sim based on the original Elite game written by David Braben and Ian Bell in the mid 1980s. At its time, Elite was a ground-breaking game, with a seemingly enormous galactic map of stars to navigate, and loose open-ended gameplay.

The Oolite project has recreated the original game using OpenGL textured models, and the source code can be downloaded from

read more ..

G3D on Ubuntu Linux

19 Dec 09

G3D is a cross-platform OpenGL library in C++. I haven't used it in a couple of years, when I first experimented with 3D C++ programming. The current version is 8 beta 2.

To install on Linux, you'll need to compile the G3D code from source. In my case, on Ubuntu 9.10, I had to install the following dependencies first:

sudo apt-get install libsdl1.2-dev xorg-dev libglu1-mesa-dev libzip-dev libavutil-dev
Then compilation is a question of running the following command

read more ..

How to Cancel an fsck Disk Check during Boot on Arch Linux

11 Jun 12

It's worth routinely checking your hard disks to alert you in advance of an impending disk failure and to tidy up orphaned blocks should they occur (very rare). For normal home users, who of course keep back-ups of important files in other locations, running this check once a month is sufficient, which you set using fs2tune.

However, in Arch Linux the fsck disk checker does not offer the option to abort a disk check once it has started. In Ubuntu for instance, you are told to press Esc to

read more ..

Restore GRUB After Installing Windows XP

3 Jan 10

Note that when using grub commands, spaces are important. In particular, a space is required after the commands root and setup (but before the first bracket) and no spaces should be used inside the brackets.

1) Boot from a Live CD
2) Open a terminal window or switch to a TTY and enter:

sudo grub
3) At the grub prompt, use the following command to determine where grub is installed:
find /boot/grub/stage1
4) Using the hard disk and partition

read more ..

Constructing a Build File for Phing

31 Jul 12
Phing is a build system based on Apache Ant, and serves to automate the process of releasing code for a development project. Before a new version of a PHP project can be released, you may have to undertake certain tasks such as running unit tests and code analysis tools, compiling dependencies (e.g. SASS, templates, language files), changing file permissions, copying files and many more.

The actions to perform are defined in the build file,read more ..

Easy Electronic Circuit - Two Flashing LEDs

1 Apr 12

When a couple of colleagues got Arduinos, I finally got round to getting hold of a starter kit off ebay. It's a very simple kit, with a breadboard and a selection of components that include resistors, capacitors, LEDs and transistors. It also had a couple of circuits pinched off the web to get you started, and they seemed as good a place as any to get started.

With the first one, two LEDs blink on/off alternately. The circuit comprises the following components:

  • LED x
read more ..

Choosing an Arduino Variant

3 Mar 12

The Arduino is a microprocessor module released under Open Source principles, meaning that the designs are published and may be implemented with or without additional modification by anyone without having to pay licence fees. The core of the Arduino design is the Atmel megaAVR CPU, a proprietary CPU produced by Norwegian company Atmel Semiconductor. The Arduino board adds I/O support, exposing the megaAVR's I/O lines as standard connectors, which allow the board to be easily connected to a

read more ..

Introduction to Neural Networks

12 Feb 12

Artificial Intelligence begins with the study of intelligence in biological systems and takes the knowledge and theories gained from that to engineer systems which exhibit intelligence. Neural networks are a perfect example of this: abstract mathematical models of the neurons that make up the brain. In some cases, neural networks are used in research to model the brain, and in these cases the aim is to make the artifical neurons resemble their biological counterparts as closely as

read more ..

Generating documentation from phpdoc tags

25 Jul 11

phpDocumentor is a tool written in PHP to create complete documentation directly from both PHP code and external documentation. Well-written PHP source code practically serves as its own documentation. phpDocumentor taps into this by examining code for all kinds of structural hints, such as files, classes, functions, constant definitions, global variables, and class variables/methods. From this, it creates basic documentation in a traditional manual format. Note that you will need at least

read more ..

Turn Eclipse into a full-featured Perl IDE on Ubuntu

28 Apr 10

With all the plug-ins freely available for it, Eclipse is rapidly becoming the one-stop IDE of choice for all your programming needs. The Perl plug-in from EPIC (Eclipse Perl Integration) is compatible with Eclipse v3.1 and higher:



You need Perl installed on your system in order to make use of all the plug-in's features, such as syntax highlighting and source code formatting. If you're running Linux (why

read more ..

Pidgin Plugin for Jabber Chatrooms

10 Sep 10

I would like to have the following features in Jabber chatrooms:

- system notification when user says any one of a list of trigger words (i.e. nicknames)
- ability to 'silence' selected people, so that their messages do not trigger sounds
- ability to mark people as 'special', so that whatever they say a system notification will be created (regardless of whether or not they use one of the trigger sounds mentioned above)

The last two could be combined into a single 3 position setting -

read more ..

Eclipse and PHP: Which is the Best Plug-in, phpEclipse or PDT?

19 Apr 10

The differences between these two plugins are varied but subtle. After having used phpEclipse for the last couple of years, I decided to give PDT a proper try as I needed to do a fresh install in order to get the PHP CodeSniffer Plugin working fully.

PDT

  • Excellent HTML validation, and built-in CSS support (code highlighting, intellisense and autocompletion for
read more ..

Mailman Virtual Hosts Info Collected from the Web

17 Sep 09

From http://www.webmasterworld.com/forum92/3366.htm:

The situation is this: A single server with multiple IP addresses and related hostnames acts as a mailman server. Mailman is a mailing list manager with a builtin web archive and subscription management system written in php. As shipped it injects a file called mailman.conf into /etc/httpd/conf.d that uses mod_alias to redirect traffic of the form

read more ..

Development Resource Project

22 Feb 07

The aim is to provide a resource where developers can go in order to get code for a specific task.

Objectives

  1. To reduce time from design to deployment
  2. to help maintain code quality
  3. to reduce need for maintanence and support
  4. to help ensure code meets specific requirements (including FF support, security, performance)
  5. to facilitate group work through standardization
  6. to grant designers the ability to easily understand the functionality
read more ..

Carisma Running Problems

22 May 06

The main problem this car has suffered since I bought it has been its poor idle. For the first six or so months, it ran absolutely fine, but then it began to stall regularly when idling, and it's steadily got worse. Even now it's got warmer has not improved, and happens equally whether the engine is warm or cold.

The stalling problem did not appear to be a physical issue with the overall running of the engine which remained smooth and even when under power. It appeared to be more to do with

read more ..

The First G3D Example

22 Dec 05

Right, so now I've checked everything is set up correctly, I've decided to take a look at the examples that come with the G3D library.

There are seemingly eight, described on the G3D web site; it's not clear if there's any natural progression through them.

  • ArticulatedModel
  • loads models from files in 3DS, IFS, and PLY2 formats. Creates a scene graph, uses 'Pixel Shader 2.0' and 'fixed function' pipelines,
read more ..

The Other G3D Examples

28 Dec 05
The example I'd like to look at next is the ArticulatedDemo. It does a whole load of things, like loading a variety of models and placing them in a scene graph. It's this scene graph thing that I think I need to understand properly.

Unfortunately, I can't get ArticulatedDemo to run - it compiles and links ok, but fails an assertion, then crashes.

The next most interesting demo is Collision_Demo, which has a set of static objects in a box, then drops a load of different sized balls in, which bounce around the place.

It compiles and runs fine.

The IFS Modeller

22 Jan 06

This little program allows you to create IFS models suitable for use in G3D programs. An IFS model can be built from an array of vertices with an associated array of indicies. The indices refer to offsets in the vertex array, and are grouped in sets of three - representing the triangular faces of the model.

So far, my program allows you to:

  • Add a new vertex at the origin
  • Select a vertex with the TAB key
  • Move the selected vertex with the numpad arrow
read more ..

First 3D Game

31 Dec 05

I now feel I'm ready to have a go at creating my first simple OpenGL game. It's going to be pretty simple - there'll be no scene graph, just a simple array for storing objects in the world. I won't implement frustum culling either, at least not in the first instance.

My game will be based on space flight, so I will start with the player's ship. It should appear just in front and below of the camera, i.e. third person. It should turn and dive/climb in response to keyboard input, and have a

read more ..

The G3D Library

18 Dec 05
G3D is an open source graphics engine that can be used from VC++ 7. This means G3D projects can be developed in VS.NET, and make use of Intellisense and its debugger.

It requires the SDL library, which I've installed OK. G3D is also installed, but the test program isn't as simple as the SDL one, so I have not yet confirmed it is installed and available to VS.NET.

Finite Automata: The Theory behind Regular Expressions

11 Jan 11

Regular Expression Principles

.DotMatches every character
[]SetMatches the specified set of characters (hyphens may be used to specify a range of characters)
()BracketsGroups patterns together so they can be treated as one
|Alternativematches either the
read more ..

Big Data and the Semantic Web

29 Oct 10

Data Storage

Data Centers today require high performance, highly scalable designs. The options available to re-architect networks have grown dramatically in the last 3 years. Spanning Tree Protocol (STP) is a link layer network protocol that allows only a single link to be active between any two nodes. This helps ensure a loop-free topology but limits the total bandwidth of the network. Switch architectures were designed with limited bandwidth to support

read more ..