I recently talked about adding code to blogs and comments to Wordpress and making sure that certain characters are encoded properly. So to simplify things I thought I would create a little set of regular expressions that takes a sample of code and convert it into a Wordress friendly format. It consists of the following function, which takes the value of a text area called tochange and runs some regular expression replace functions on it.
Wordpress is a pretty neat blogging platform, but it falls over quite spectacularly when trying to write code in posts. I write a lot of code for #! code and so I have understand what needs to be encoded to make code examples work.
For code example on #! code I use the <code> tag and I encode the following characters.
- < into <
- > into >
- " into "
- ' into '
Note: You must be in HTML mode in your Wordpress editor or everything will be double encoded.
By default, Phing will look for a file in the current working directory called build.xml when you run it. This document tells Phing what it will be doing during the build. You can change this by using the -f or the -buildfile property of phing and giving the build file as the parameter. The following code makes phing look for a build file called wibble.xml.
phing -f wibble.xml
Assuming that the project is called myProject, then a minimal buildfile would be look like the following:
Yesterday I talked about creating some simple Flex elements in your application. Today I will introduce a new element called Script.
The Script element, if you haven't already guessed is used to run your application function and should be contained within the Application element. You can either put script inline like this.
NOTE: This bit of code is potentially very dangerous and should NOT be uploaded to your web host. I only use this function on my localhost to quickly check that a snippet of code works.
If you want to quickly run some PHP code, and don't want to have to go through creating a file just to see the outcome of a simple calculation is then this snippet might be of some use to you.
Last month I started writing functions in a particular way, which has made my life as a programmer much easier on more than one occasion. No matter how many comments or verbose parameter names you put in you can end up writing code that you will get lost in. The reason is simple. Lets say you had a function that took in a couple of parameters.