Archive for the ‘Code’ Category
DarkAuth for CakePHP
I thought I’d add a page to satisfy those of you who may have arrived here from the Cookbook, or anywhere else one of the DarkAuth pages was linked from.
I don’t really have much to do with this Component any more, although it still works great! I found that the built in Auth Component is plenty powerful enough, even if it doesn’t quite work work how I would have designed it.
Anyway, here’s the component (tested with CakePHP 1.2 RC3) DarkAuthComponent. Enjoy! It’s highly commented, so hopefully you’ll be able to work out what it does and how to use it…
jQuery SuperSelect
A little while back I was working on a project and wanted a selectbox to look a bit more pretty, but with complete backwards compatibility with regular select boxs.
I.E. If I already had a select box on the page, and it had various JavaScript events hanging off it already, I wanted that to function still but I wanted the box to be prettier.
The first idea was to use CSS to just style the box. But then I realised that each browser and OS has it’s own different way of rendering the controls. So I turned to JavaScript, and the always useful jQuery library. I wrote a plugin that will immediately transform any selectboxes into prettier ones, allows icons for the options, all with valid xhtml and works completely fine with JavaScript (or the plugin) disabled. Pretty cool, eh?
Well, I put the original demo page I designed for it back online, so check out the plugin!.
CakePHP Evangelism and T-Cake
So I’ve had this blog for 3 posts now and none of them has a “cakephp” tag yet. Shocking. So here we go…
If you don’t know what CakePHP is and you’ve ever created a web application, or even a website that did more than show a static page, then you should check it out. CakePHP is a web application framework designed for rapid application development using the MVC Design Pattern and with a focus on Convention over Configuration.
What this means in practical terms is that you can built an access controlled, database driven, dynamic web sites/applications in a fraction of the time that it would to start from scratch. A simple blog could be built in a matter of minutes. I could go on for hours. So I won’t, but really – if you make web apps, consider using a framework and CakePHP is excellent.
Regular Expressions in MySQL
I like regular expressions. Anyone who has tried to understand them will understand the learning curve involved and in no way do I claim to be an expert. However, I use them all the time. They are possibly the most useful thing I have ever learnt to do with programming and are more powerful I imagined at first.
So what does this have to do with MySQL?
Well, I was recently dealing wit a table in which there is some inline JSON serialised data. This makes sense for the situation but of course if you want to query on something within the data you have to be a bit more careful. You have two options as I saw it yesterday:
- Pull all the data and parse it out outside of the database - which seems weak and inefficient.
- Use some LIKE query to pull likely candidates and then parse out of the data base - again not so good, but a bit better.