Skip to content


Per form stylesheet with Zend_Form

I needed to have certain form styles attached when a form is in use. I didn’t want to do this from the controller each and every time as it was really was only to do with the form and I might want to use the form with it’s own stylesheet in other places.
Continued…

Posted in Zend Framework.


jQuery Keyz Plugin

The purpose of this plugin is to easily facilitate the end user to create and hook key presses for their own use. Usually you would need to know what key links with which keycode etc.

Usage

It’s as easy as these steps:

  1. Include jquery – either from CDN or local source
  2. Include jquery.keyz.js
  3. call the following within your document ready or after the item exists
$('selector').keyz({
"enter": function(ctl,sft,alt,event) {
alert('you pressed enter!');
}
});

this will hook the enter key and raise an alert when pressed.

If you want to cancel the key either return false from the function or set the value to false like so:

$('selector').keyz({
"enter": function(ctl,sft,alt,event) {
return false;
}
});

OR

$('selector').keyz({
"enter":false
});

You can either use the key names in singular or in a grouping like so:

$('selector').keyz({
"enter": function(ctl,sft,alt,event) {
/* single key */
return false;
},
"F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12": function(ctl,sft,alt,event) {
/* mapped to all F-Keys */
return false;
}
});

Download jquery.keyz.js here: Full Source && Google Closure Compiled version

Visit the demo page here: Full Source

Planned Features

  • support for keypress chains .. passing a sequence of keys and an event firing upon completion
  • support for all three key states – presently only triggers on key down – Added in 1.0.2
  • to add some duck punching to add the keyname to the event for the three standard events

Supported Keys

The keys listed below are the current ones supported by the plugin.
They also support the hyphenated name eg numpad-1 or in upper case like “F1″ or “f1″

  • enter
  • return
  • esc
  • escape
  • numerics
  • upper
  • lower
  • alphanumeric
  • tab
  • shift
  • alt
  • ctrl
  • f1
  • f2
  • f3
  • f4
  • f5
  • f6
  • f7
  • f8
  • f9
  • f10
  • f11
  • f12
  • caps
  • capslock
  • numlock
  • winflag
  • winkey
  • windows
  • scrolllock
  • left
  • up
  • right
  • down
  • volumeup
  • volumedown
  • menu
  • contextmenu
  • backspace
  • pause
  • break
  • pausebreak
  • pageup
  • pagedown
  • end
  • home
  • insert
  • del
  • delete
  • numpad0
  • numpad1
  • numpad2
  • numpad3
  • numpad4
  • numpad5
  • numpad6
  • numpad7
  • numpad8
  • numpad9
  • *
  • multiply
  • +
  • add
  • -
  • subtract
  • .
  • fullstop
  • decimal
  • /
  • divide
  • ;
  • semicolon

Posted in jQuery Plugins.

Tagged with , , , .


Integrating PHP CodeSniffer with Activestate Komodo Edit

I’ve recently been looking into standards of code and how they would apply to myself and my code. To enable this, I’ve recently installed PHP_CodeSniffer and for a few days been using this on the command line.. which by itself isn’t bad, though I really wanted to have something inside my editor of choice (happens to be Komodo Edit). Continued…

Posted in Web Development.

Tagged with , , , , , .


Word of the Day: “Spalooch”

Yep another delightful new word you can add to your dictionaries.
Today’s Buzzword of the day is:

Spalooch

This is the sound that comes when you spill a liquid over the edge of its container onto your clothes.

When it happens, you have been Spalooched..  it is accidental and you can’t spalooch someone.

Posted in Buzzword of the day, General.


Active Module Based Config with Zend Framework

I’ve recently taken to using Zend Framework for a project that I needed to bring up to date. I won’t go into the pros and cons of choosing a framework as there are many much more qualified people who have done a much better job of this subject than I would or could. So Instead I bring to you How I managed to get Active Module Based Configuration within Zend Framework.

The Problem

The Concept I wanted to achieve was to have unique Configuration based upon the module that was active. The Issue with this is that the Bootstrap files and the _init functions for ALL modules are called with no bias as to which module is active. Thus if you created a 3 modules wanted to make menu alterations in one, those alterations will be applied to all. I also wanted to have a a system where if i added extra modules i could just add extra functions to the bootstrap file and it would work in a similar way.

With this in mind, I set about trying to figure out the solution.
Continued…

Posted in Zend Framework.

Tagged with , , , , , , .


Ada Lovelace day 2009 – @LornaJane #ALD09

Today is Ada Lovelace day and as such, we are prompted to write about someone we admire who is female and is involved in technology.

For my Post today I have chosen LornaJane. This stems from many reasons, which over the course of this post I hope to explain.

Continued…

Posted in Personal.

Tagged with , , , .


PHP – Chmod-ed to Windows hell and back

Today has not been a good day.

With various things going wrong, I was please that I had got the file upload code done for a site i’m working on. All I needed to do was make sure that the file had the right permissions and then edit it via GD (via an image editor class i have). Here’s where the trouble started..

I started off by chmoding the file to 777 and then trying to do the resize.. this threw an error with permissions.. so i looked at the file.. Read Only.. strange I thought.

Then I checked the folder and that had a weird green square instead of the checkmark in the checkbox. I tried to remove the read only attribute off of this and hte file.. and it kept coming back.. I went all around hte houses, trying all sorts of techniques .. to no avail.

@auroraeosrose in the PHPWomen IRC channel helped a lot as did Dreis.. (thanks muchly)..

After backing up the files and formatting the drive, to reinstalling the Apache/PHP/MySql stack I was no clearer to the answer as to why the file was always ending up with read only permissions..

Finally it came down to the 1 thing that I had overlooked.. the chmod in the code .. the second parameter was 777. I thought this was correct. Aparrantly not. The second parameter of the chmod function requires an octal code.. thus prefixing the 777 with a 0 (zero) fixed the whole issue.

Boy did i really feel dumb today.

So to wrap up, remember to always pass a FOUR digit code through to chmod or face the annoyance and headache I got today.

Posted in PHP.

Tagged with , , , .


MySQL – Conditional Joins

For the most part I’ve used many JOINs in my queries since I leartn how to use them and what they were good for, I much prefer to use an Inner Join over the the Implied join of a WHERE statement.

For those who haven’t yet learnt about JOINs you might be using an implied join in your queries even now… lets take this example:

SELECT table1.field1,table2.field2
FROM table1,table2
WHERE table1.table2_id = table2.IDField

This is an Implied JOIN, you are telling MySQL to get the 2 fields from the 2 tables but only return the ones where the field in table1 is in the field in table2. This works, but using Joins we can improve it.

Ok, Lets take the above example and apply the join mentality to it:

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on table1.table2_id = table2.IDField

This Links in only the rows that match the ON criteria which in theory should be less than the whole table, which again in theory should make the query faster.

Ok, now we have the JOIN theory out the way, we can get down to what this blog post is actually really all about, Conditional joins. Just Like the WHERE Clause in the SELECT statement you can use AND & OR in the ON part of a JOIN. Usually it’s used to add more constraints to the join, but you can use it in interesting ways,

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on (table1.table2_id = table2.IDField) AND (table1.itemName = 'foo')

Only JOIN rows that have the matching ID and where the itemName from table1 is equal to foo;

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on ((table1.table2_id = table2.IDField) AND (table1.itemName = 'foo')) OR (table2.item = 'xx')

Only JOIN rows when the IDs are matching and the itemname is foo, OR when the item in table2 is ‘xx’

Baring in mind that the more complicated you make it, the harder it will be to maintain IT still can be a great method of Reducing the amount of rows that need to be processed.

Hopefully this will help someone, if so or if you have anything to add/point out/criticise etc.. please do comment.. I Don’t Bite.

Posted in MySQL.

Tagged with , , , , .


MySQL – Conditional Updates

Just a quick blog post in an update related way,

Recently i’ve needed to toggle multiple rows in a database from 1 value to 1 of possible 2 values dependant on the contents of a field on the row. I wasn’t sure if this was possible, so i asked in #PHPWomen IRC Channel and the general response was that of “Don’t Know”.

So After a backup of the table in question, i decided to try it and see. After all, the worst it could do was just not work. So I tried the following:

UPDATE `tble_name` SET `field1`=IF(`field2`='arbitrary_value',1,0) WHERE `field3`='other_value'

And Voila updated all the rows exactly as needed.

So, It is possible to update all rows in a table, limited to a group and update value based upon a field matching a certain Value.
So all in all MySQL For the WIN!!!

Posted in MySQL.

Tagged with , .


jQuery Plugin: Element Existence

Just a Quick little snippet really..

Over at JqueryForDesigners.com @rem mentioned about checking if an element exists or not, I’ve been doing this for some time using the following snippet:

jQuery.fn.exists = function() {
    return (this.length > 0);
};

to use it you can now do this:

if ($('#elem').exists()) { /* do something */ }

Hope this is helpful to some people

Posted in jQuery Plugins.

Tagged with , , .



Get Adobe Flash playerPlugin by wpburn.com wordpress themes