ThingyMaJig

Thingy Ma Jig is the blog of Nicholas Thompson and contains any useful tips, sites and general blog-stuff which are considered interesting or handy!

Connect

LinkedIn GitHub

Topics

announcement 25 apache 3 Apple 1 bash 8 code 7 cool 30 Days Out 8 Dark Basic Pro 4 design 12 doctor who 1 Drupal 74 E4600 1 EOS 400D 3 firefox 2 Flickr 3 free 21 games 5 geek 38 git 2 GreaseMonkey 1 hardware 7 Homebrew 1 How to 37 humour 5 iphone 1 javascript 1 jquery 1 K800i 6 k850i 4 lighttpd 3 linux 33 mac 9 miscellaneous 4 mobile phone 9 music 4 mysql 8 n73 1 n95 1 New Relic 1 Ogre3D 1 OS X 2 performance 3 photos 10 programming 40 Quicksilver 1 review 19 security 3 SEO 6 software 12 svn 2 technology 4 tip 7 tips 10 tv 3 video 3 vim 7 webdev 2 websites 33 wii 1 windows 1 YADS 10

programming

As a programmer by hobby and by job, I stumble across a lot of resources for programming, from websites to gaming competitions.

Quick Tip: Drupal Hook Commenting Using Vim

14 November 2011
vim Drupal programming

According to the Drupal Coding Standards for Documenting Hook Implementations, its considered a good practice to quickly chuck a comment before any function which implements a Drupal hook (eg, hook_menu). This helps someone reading your code quickly see that the function is actually linked with a hook in Drupal and isn't just a function in your module to be called directly.

But… Well… The thing is… Does anyone else get bored of writing the following over and over again? I know do…

Entity Encode Text Using PHP

07 February 2011
code programming

Ever needed to Entity Encode a block of text (maybe to partially protect it from spam bots or just hide/obfuscate the content?). I did. It’s pretty easy.

If it’s just basic Entity Encoding, you can always use htmlentities - however this only does the “important” characters such as quotes, ampersands and angle brackets.

MySQL: How to upper-case words

30 September 2010
tips programming mysql How to code

 I recently needed to clean up a MySQL Table which contained people's names. Upon searching the MySQL commands, I was surprised to find there was no equivalent of PHP's ucfirst or ucwords. There were commands to convert entire strings into upper or lower case, but not just the first letter.

Vim Tips: Replace 0px with 0

23 June 2009
vim tips programming Drupal

I like little wins. I was just looking through the CSS file for this site and noticed that - for some reason - I'd used 0px instead of 0 a LOT of times. Most values need numbers (10em, 10px, 10% and 10pt are all very difference sizes) however 0 is one of the few valeus which is the same in all cases (0px, 0pt, 0% and 0 are all zero!). This adds up to wasted data and bandwidth; admitedly not a lot, but still Every Little Helps!

So I fired up Vim. Initially, I just did:

PHP's display_error, not always a good thing!

19 May 2009
programming geek Drupal

I just hit an interesting issue while trying to upgrade a Drupal 5.18 site to Drupal 6.12. I went to the update.php page and noticed an error at the top implying the url_aliastable was having issues due to Drupal 6 expecting a language column which wasn't present in Drupal 5. "No problem" I thought, "That'll get fixed during the update!". This was the beginning of a long learning curve through the new Batch API system!

How to import users into Drupal using Devel

15 January 2009
tip programming How to Drupal

The first test is a valid email address test. The second test is if an account exists for that email address. The third is if the username, generated by the “user” part of the email address, exists. If there are any issues, the “error” is logged into and array and printed at the end.

Neat commenting in Vim

12 January 2009
vim programming linux Drupal

I am a bit of a "neat geek" when it comes to coding. Things should be indented neatly and should have well laid out comments! Why? Well… It's easy to do and in 6 months time when you look at your code you will appreciate it! It will also me even more appreciated by another developer in less than 6 months time ;-)

SVN + NFS = svn nfs cant get exclusive lock

25 November 2008
svn programming linux How to geek

Last night I was trying to configure SVN on a server. The setup was that the SVN Repo was on "srv2" and the frontend and code I wanted to import was on "srv1".

I created an NFS share on srv2 and mounted it on srv1 in /mnt/svnroot. The mount worked perfectly and I could touch and remove files from srv1.

So I tried to create a "sites" folder where I wanted to import a site I wanted to version control. This is where I started to have problems… The sollution was to add "nolock,bg" to the mount options on the client. Read on for more details!

Relevant Content gets some love

25 September 2008
SEO programming Drupal announcement

I while ago (almost a year!) I released a module called Relevant Content to the community. This module executes a relatively lightweight SQL query which pulls up other nodes and sorts them by how many terms they have in common with the current node you're looking at. This provides a rudimentary method of suggesting other content to visitors to the page. It also provides a way of teaching search engines about other potentially relevant content.

Vim and Drupal Modules

18 August 2008
vim programming linux geek Drupal

I just finished upgrading a server to Ubuntu 8.04 which came with Vim 7.1 rather than 6.3 on the older server. It seems 7.1 does things slightly differently to 6.3.

In 6.3 I could create ~/.vim/filetype.vim and in there define a line as follows:

au BufRead,BufNewFile *.module,*.install,*.theme setf php

However in 7.1, it looks like a line similar to this has to go into ~/.vimrc instead…

Node Quick Find

06 April 2008
programming Drupal announcement

I've just committed another module - Node Quick Find. That brings my projects to a nice round 10!

This module is a pretty basic one though. It simply provides a block which has an autocomplete field. This field is linked to the Node Title field. You start typing the Node Title and it will start suggesting possible nodes you might be interested in - sort of like a primitive search box.

It features primitive configuration, allowing an administrator to easil configure the title of the prompt, the size and the types of nodes returned in the autocomplete list (eg, you may want to limit the list to blogs only).

The price of sucess - too many users!

25 October 2007
programming linux geek Drupal cool apache

Recently at work we had been having issues with spiking server load. One of the potential suspects was the Apache configuration as it was allowing 256 MaxClients. Combine that with Drupal eating RAM for breakfast (say a minimum of 12Mb per page) and you have a recipe for disaster - too many visitors cause a RAM shortage, lots of swapping and eventually a server meltdown. After speaking the Rackspace Technical Support Team, one of the guys there (Daniel) wrote a VERY useful script for us to run on the server to monitor Apache usage.

Hidden Drupal development functions

02 October 2007
programming Drupal

I was browsing around the Devel Module the other day and I noticed a few functions that are not mentioned in any documentation that I've seen but make life even easier, as if Devel doesn't make it easy enough! Almost everyone that's used Devel will be familiar with dprint_r (A debug version of the popular print_r function in PHP). Well who has used these ones?

How to weigh terms alphabetically

07 August 2007
programming mysql Drupal cool

Following on from my Numbering Rows in MySQL article, today I needed to populate the weight column of the term_data table for about a hundred terms so that they incremented in alphabetical order. This was, on the face of it, a very tedious task; click edit, select weight from drop-down, submit, 'goto 1'.

As I said in my Numbering Rows in MySQL article, I don't like tedious - but I do like over-complicated methods which actually make my life more interesting and less tedious... Enter a nifty MySQL script!

Force a PDF to download

06 August 2007
software programming linux cool apache

I recently needed to force a PDF to download using Apache. The default behaviour for most browsers is to try to open the PDF inside the browser itself. This is fine for a small PDF or for powerful machines - but a large PDF on even a modest machine can often lock the browser up. This needed fixing!

After 20 minutes of perusing the Apache documents, I happened across the FilesMatch option which takes Regular Expressions. Regular Expressions are cool things which pattern match; you give it a rather complicated (yet logical) pattern and it matches it for you. Initially I used something like this...

Sprucing up your User Profile Pages

12 June 2007
programming Drupal design cool

I recently launched a Drupal Codebase site for a programming community and wanted to have the user profiles to be more than just a "signed up on..." and a Tracker Tab. I wanted them to have structured and customisable blocks, dynamic content, a Peer to Peer Message Board (almost finished)... I can have my dreams cant I?!

I recently wrote a book page on how to programmatically create a view. I wanted to do this as it would allow to me control almost an entire website with multiple content types, terms and users (as well as combinations of the three) along with RSS feeds - all powered by the Views Module + a bolt on module consisting mostly of a menu callback and a function to make and configure a view. This worked pretty well for a first try and principle test!

I then realised - hey, if you can do this with Views - why cant you do it with Panels too? Panels are fantastically useful for structuring multiple blocks, views and nodes onto a page. So I tried… And you can!

New Drupal Site - Codebase

06 June 2007
YADS programming Drupal Dark Basic Pro announcement

Today I officially launch a new Codebase for Dark Basic Pro. I'm a big fan of Dark Basic Pro and this Codebase is one of the ways I'd like to help the community back. There is a codebase which The Games Creators provide and it is a good codebase with a LOT of content. This codebase, however, offers more  "Web 2.0" features such as free tagging, comments and rating (and I've only just got started - more to come!).

Codebase Large Banner

My first project using Ogre

20 May 2007
programming Ogre3D games free

With some help from a good friend, I took my first steps into game-making using C++ last night. I used a graphics engine called Ogre3D and tried to mimic a game I started making in Dark Basic Pro a few weeks ago. To my astonishment, within a few hours I'd managed to replicate the basic layout of the game using tools which cost absolutely nothing!

Which modules use hook_cron?

14 May 2007
programming linux geek Drupal cool

I recently needed to find out a list of modules which used hook_cron. I have SSH access to my server. Instead of writing a module (or using devel to execute some PHP) which returned the result of module_implements, I turned to grep. Simply cd into your modules folder (can be the Drupal install, but you end up recursing through unlikely folders) and run this:

grep -R "^function.*_cron" *module

Drupal gets a $100,000 injection thanks to Google!

12 April 2007
programming Drupal announcement

Google announced today that it will be sponsoring 20 - yes twenty - projects for its Google Summer of Code program this year. From what I've seen, Drupal is one of the top "winners" if you use project quantity as a metric, with only Apache and KDE beating us (I couldn't see any others with any more at a glance). We got more than Joomla, PHP & The Mozilla Foundation and I believe this is a real achievement.

I'm also thrilled that Konstantin Käfer and I am mentoring one of the projects this year - the Taxonomy Manager.

Pongis - a new game I made!

20 February 2007
software programming games free Dark Basic Pro cool announcement

I've just released a new game - its a VERY simple adaptation of the classic, pong, but it has a twist in the form of tennis. You must rally the ball back and forth - the ball gaining speed slightly on every return. Players win points (and serve) by knocking the ball past their opponent, either through a cunning move or by making them lose out in a game of reactions.

Checkout the game here - Pongis - Where Pong Meets Tennis

Cloggy's D3D Plugin

14 January 2007
programming games free Dark Basic Pro cool

I just found this plugin (again) on The Games Creators Forum. Basically it adds new features to Dark Basic Pro. I'd used an older version of it but this one seems to have plenty more! Hopefully I'll put the project I'm using it for up soon - a resource management game

Drupal 5.0 beta 1 released!

31 October 2006
Drupal announcement programming

Drupal 5.0 beta1 has been announced.

It comes with many new features, including a web-based install system, improved administration tools, and a shiny new theme! There are also tons of under-the-hood improvements, such as the inclusion of the jQuery JavaScript library, node access system improvements (ACL), and many improvements to the Form API.

read more at drupal.org