Programming, CakePHP and commentary from Britain.

Popular

CakePHP Livesearch
CakePHP Sessions
VBScript & Excel
VBScript & Oracle

Search

E-mail

kdobson@gmail.com

Subscribe

RSS 2.0

Viewing posts in the ‘Tutorials’ Category

Conditional debug statements in Visual Studio

It has taken a me a long time to finally get this neat Visual Studio trick working. Despite it being a very powerful addition to the development and debugging process, there doesn’t seem to be much information about it, apart from the small entry on MSDN discussing the preprocessor.

To perform different actions or execute different blocks of code depending on your build configuration (think debug or release), you will need to define a new symbol for your build configuration. In my scenario, I was interested in executing a block of code whilst in debug mode, but not perform it in release.

  1. In Visual Studio select the Project menu and click “(Project) Properties” at the bottom of the menu.
  2. Select the Build tab on the left. Make sure your Configuration is set correctly - it should be debug for this example.
  3. In the Conditional compilation symbols text box enter: /define DEBUG
  4. Save the configuration and close the properties window.
  5. In your code, where you want to run a commands depending on the current build:
    #if (DEBUG)    
      Console.WriteLine("You'll only see me in debug mode..."); 
    #endif
  6. Then give it a quick compile and witness the magic!

There are a couple of uses that spring to mind - debug trace messages to help monitor what your code is doing, only deleting a file in release mode (if you’re downloading a file from the Internet repeatedly), outputting detailed exceptions in debug, but nice error messages in release.

This is possibly a very basic trick that everyone has been using for years, but I’ve only recently been making the most of it.

If you’ve used this before - in what context do you employ it?

CakePHP Livesearch

This is an updated version of “CakePHP Livesearch” - published here in 2006. That version was designed for CakePHP 1.1, whilst this is a more polished and modern solution for CakePHP 1.2. The two tutorials are not compatible with each other due to changes in the framework. It is recommended that you stick with this one, and use CakepHP 1.2.

A while ago I wrote a tutorial covering how to get livesearch functionality working in CakePHP. A lot has happened since then - new versions of the framework have been issued, my knowledge of all things Cake, PHP & Ajax has deepened. Here’s hoping that my ability to communicate has, also.

There was a lot of positive feedback from the last tutorial which has spurred on a newer, revised tutorial. The contents of this post relate to Cake 1.2 (still in beta, but very usable). Whilst much of the steps are the same, there are a few subtle differences, and I have tried to clean things up a little better. So, without further ado…

Read the rest of this entry »

MySQL backup in OS X

I recently took ownership of a shiny new Freecom 400GB USB drive, and with it a renewed understanding of how important data backups are. Automating the backup of files and settings in OS X is pretty easy - I went with iBackup (mainly as it was free) and have been pleasantly surprised at the backup flexibility it gives. MySQL — something I use pretty heavily — is not something it can do. Nor can many other backup tools.

Read the rest of this entry »

CakePHP Livesearch (CakePHP 1.1)

This is now an outdated tutorial. It has been replaced by a more polished version designed for CakePHP 1.2. Whilst the tutorial you’re looking at now still works in 1.1, you’d be best of upgrading to CakePHP 1.2. It’s much cooler.

Want to get a AJAX-ified live search working in CakePHP? So did I, but struggled to track down the relevant tutorials in English. There are two prominent tutorials out there; one by Marcus Jaschen, and another by Nio. Unless you’re well versed in German or Chinese (respectively) you might struggle to decipher these. I’ve adapted ideas seen in both tutorials and present one in plain (ish) English.

If you want to see what this looks like before getting started, try the demo.

Demo is offline at the moment, waiting to move it over to the new host, sorry!

Read the rest of this entry »

Understanding CakePHP Sessions

CakePHP is a PHP framework which is turning out to be most useful, and very flexible. I’ve embarked on a few little projects with it, and thought I would spread a little understanding with regards to the session component - as I struggled to find a concise set of examples to help me on my way.

Read the rest of this entry »

Genetic Algorithms For The Rest Of Us

Part of my Software Engineering undergraduate degree involves an optional final year unit - Genetic Algorithms & Neural Networks. Needless to say, I volunteered myself for said option. My main drive for choosing this unit is that it’s some of the most unusual, yet cutting edge stuff you can realistically explore as a Software Engineer - the subject matter is quite “out there” but remains in the domain of practicality and usefulness. As much interest as I might have in say, quantum computing, I am unlikely to dedicate part of my education to it as, unless I want to go into computational research, it’s not terrifically useful. (A narrow mind, I know.)

Read the rest of this entry »

VBScript and Oracle, Redux

A while ago I attempted to document what was needed to get VBScript to interact with Oracle. That piece covered how to insert rows into an Oracle table, and how to execute a stored procedure. Now I’d like to tackle the task (illiteration, awesome) of getting data OUT of an Oracle table and into a VBScript process.
Read the rest of this entry »

VBScript and Excel

Whilst I’m the mood to share VBScript experiences with the world, I thought I would put up a small piece about how you can use VBScript to get data out of Excel. You may think it’s a bit stupid using VBScript to access Excel when you can script directly into Excel with VBA (Visual Basic for Applications) - but I find it can be pretty useful as it requires minimal interaction (double clicking a file instead of opening a spreadsheet and running macros).
Read the rest of this entry »

VBScript and Oracle

Fairly recently I was approached to create a system which parses data out of a CSV file and dumps said data into an Oracle table so that it could be reported on. The standard procedure for this is to send the source files to a Unix system and run them through with SQL Loader, but I didn’t fancy going down that route…
Read the rest of this entry »