I’ve decided to share a little snippet of code that I’ve used for some time now on my web projects. This snip of code allows one to place any value they desire inside a form field and have that value disappear when the field is in focus. When the field is blurred the value reappears IF the field does not contain any user input. It is applied to any field using the class selector of your choice. I’ve chosen .prefilled as mine, but you could make it any class you wish. Continue reading
PHP: class_exists() results in an uncaught Exception
I know they say it’s not a bug, but the other day I was using class_exists() and the spl_autoload() functions to load my libraries. I discovered that class_exists() automatically returns an Exception when the class indeed does not exist! This was a problem, since I had created a custom exception MyException. Continue reading
Remove white background in Photoshop
I’ve been working with a website design that includes a black background. Part of the challenge has been taking some of the clip art files that were made to work with a white background and convert them to work with dark backgrounds. Sure you can use the magic want or a clipping mask, two ways that work pretty well when the image is limited to primary shapes like circles and squares. But they are a pain in the rear when you’re working with, say, a three dimensional scene. Continue reading
Use a PHP class to connect to a database
Often times I’ve found myself wanting a quick and easy way to set up a connection to a MySQL database in PHP. In procedural code this was often accomplished by adding a few lines of code atop the first PHP file in the program.
I’ve decided to write an object that uses the constructor to connect to a database and the destructor to disconnect. All I need do now to connect to a database is update the class properties and instantiate the thing. Continue reading
Dangerous trend: huffing
So the latest trend in the everlasting pursuit of a high is huffing. A lot of people are surprised when I explain what this is. Since it’s basically getting high where no one though a high was possible, it’s pretty misunderstood. And because it can kill you in under a ten seconds the first time you do it, it’s probably something a lot more people should know about. Continue reading
Create a PHP Object
Object oriented programming was a foreign concept when I first started with it. I grew up writing procedural code all the way back to when I was 6 and coding in BASIC on my Atari 400! Procedural code was the way, but no longer. I am all about OOP now that I’ve grasped the basics and have started creating code for some pretty complicated objects. And as I get more and more into coding, the complexity abounds — but OOP makes complexity fairly straightforward, organized and easy to work with. Continue reading