I use it quite often, especially when setting up database connections, as these are often pooled. The great thing about the using keyword is thaT once the final brace is run in the code the object destroys itself. When I have to make connections that might take me to different servers I use using to make the connection, run the SQL and close the connection. Exiting the final brace clears everything and I am ready to move on to the next connection.
The using keyword will clear all resources as it exits, so if I forget a .close() or want to have several consecutive connections this little helper makes life clean and simple; the other beauty of it is that you can see in the code everthing you are doing within that one session.
It is very, very useful.
With the new solar monitoring satellites in place it is nice to have early warning of impending solar activity. There is currently an ‘alert’ on a solar flare pointing directly at earth.
Apart from the ability to give Hollywood B movie makers a plot line, what on earth do we do? The storm flare will affect earth orbit satellites, so comms could be affected, we may have to fall back onto landlines and park our mobiles up for a day or two.
Power lines and switching stations could be affected, so get some candles in and have an early Earth Hour -or day.
Finally sat Nav systems could error, but who actually trusts these gizmos? I have heard stories of drivers following tracks into ponds and running across fields following ancient trackways still on maps and therefore on the software disk. Surely we can park these up for a while, use our eyes and maps, maybe even a bit of common sense.
Come to think of it, watching the hoards of motorists setting the systems as they leave the local supermarket, maybe solar flares should wipe these gadgets out completely, let us old grumpies get back to proper driving, no mobiles, no Sat Nav. At least I could relax and not keep having to watch my mirrors for the driver who is typing in co-ordinates from a friend on a mobile phone while travelling 2 feet from the rear of my car!
Although we do quite a lot of WordPress work it often happens that we need to look at a bespoke solution to a problem. Recently I was asked to put together a custom built ‘Articles’ page for www.lawschoolonline.co.uk. The articles needed to be easy to administer, and give the site administrator ability to edit articles once posted and allow the user to select articles by category without the need to keep asking me to make the changes.
Selected articles are served up in a solo page so there was a need to ensure that the title tags, header keywords and description could all be customised by the site administrator to fit the specifics of the article’s content.
The solution was was a simple protected admin menu page that allowed the creation of new articles, with form fields for excerpts, tags, headers description and keywords plus the title tags. An editing menu lists all articles by shortcode and then allows a full edit of all the data fields. All data is stored in a MySQL data table. Apart from the category tag joins
only one table was required as normalisation wasn’t an issue.
As PHP is a server side process it was easy to call the data for the individual article into the page so that the title, SEO keywords and description related to that individual article. As the HTML is rendered after the PHP processing it meant that the browser was passed the SQL data to form the required sections of the <head> tag and create an individual SEO specific article.
With the coming of ‘Open Government’ a project that it must be said is very laudible, there comes a danger that the overeagerness to get ‘stuff’ out there can sometimes lead to dangers.
I am not being melodramatic here, but data needs carefiul management, not censoring, but management. The new police.uk site shows hot spots of local crime, if you were actually lucky enough to get online. After several attempts I have given up and looked not at the data, but at the source.
It would seem that the data used is quite ‘raw’ that is comes from a variety of sources in a variety of ways. The data can be edited at any time, changed or removed. The key thing here though is that there are probably hundreds of end points all adding data using their own set of definitions. What is a crime? Where was the location (what about at a junction of two roads)? How many were involved? How old is the crime?
Data can only be useful if it has a core set of standards, and not as the case seems to be here - variable set of core standards.
As I understand it, users will have the Christmas period to move their entire backlog of email messages, and notify all senders of emails of a change of address. Come January 14 2011 all emails to that address will be bounced.
If, like us and most of the online community, you have decided to join the odd mailing list or two, you would need to track them ALL down and amend them. However, how do you deal with accounts that don’t allow you to change the prime email address?
Switching at such short notice is not going to be a quick or easy task. One of the reasons we use several email identities is to avoid this type of situation, so here’s hoping none of our independant service providers go the same way!
The recent attack on the Royal Navy site using SQL Injection techniques is a timely reminder to anyone still leaving their database unprotected.
The good news is you can quite easily reduce the risk of an injection attack. They take place when a site allows data input fields on a form access to basic SQL commands. By adding extra words to the end of a form input field SQL statements can be run in addition to the original designed statement. These commands can be quite simple for example, firstly select a list of tables, then select the data in the tables. As this operates at the database layer a connection has already been made by the software to the database so login details aren’t required.
There are simple functions that use basic escape mechanisms to protect the data input. The most common is escaping the data, which may not be the strongest security measure. The input string is read and if the function finds certain characters it will ‘escape’ or add a ‘\’ character in front of the relevant character. There are still ways around this so to be safe the query to the database should be ‘parameterized’ that is the input string is broken up and selected parts are passed to the SQL query. Basic functions exist in most programming languages to do this task.
Better yet, and good practice anyway, is to use stored procedures as these are totally parameterized. It isn’t particularly complicated, but it is a bit of a pain to do … if in doubt ask your web designer!
Why do certain harmless objects cause such stress?
I personally think that printers are the most likely source of ‘object rage’ that I can think of and this following clip – which contains VERY STRONG – not for the faint-hearted - language seems to agree -
It sums it all up for me. I must spend hours a day talking to screens, printers and various network boxes, all to no avail as if somehow, by giving them a life and personality, they will actually work better.
Basil never had this problem, he just lashed everything with branches – not a bad idea at that.