Dev Notes

How to use vertical-align in CSS

Poor vertical align still gets a bad rap. While it probably wouldn't top the list of least used CSS properties (clip may have earned that title), it certainly should get an honorable mention as one of the most avoided and least understood.

I think this is because most coders would expect vertical-align to align an element vertically in its container. Instead it vertically aligns an element in relation to the line-height. For example, #div {vertical-align: middle; } would give us:

Importing frm, myi, myd database files

I feel like I should have known this but I didn't.

I co-worker gave me the files for a cms to install on my local server recently. I opened the directory with the database files expecting to find a nice fat .sql file but instead found an array or .frm, .MYI and .MYD files.

I recall seeing these before but I had alternatives and never dealt with it. This time I just asked.

Community makes for greatness

When we work as a freelance developer, either alone of with a multidisciplinary team, we can often find ourselves alone in our craft. It is easy to become isolated from the larger community of like developers, be they designers, web programmers, site owners, etc. Fortunately it can be just as easy to keep yourself a part of a community.

Dealing with time in terms of seconds

When adding in or subtracting seconds, such as when dealing with the number of seconds since epoch, I find it much more readable and useful to multiply the number of seconds in a minute by the number of minutes in an hour by the number of hours in a day and so on until I get the period of time I need.

  • 1 for one second
  • 60 for one minute
  • 60 * 60 for hour
  • 60 * 60 * 24 for day
  • 60 * 60 * 24 * 7 for week
  • 60 * 60 * 24 * 365 for year

Difference between htmlentities and htmlspecialchars

The twin functions htmlentities() and htmlspecialchars() both do the same basic job. You use them when you are displaying data, especially user input data, to:

  • prevent the use of JavaScript for cross site scripting (XSS) attacks
  • prevent the use of HTML that may otherwise break the page
  • permit the display of special reserved HTML characters such as angle brackets

Try dropping a series of closing div or table tags in the middle of your page and you will see your layout break in creatively horrifying new ways.

Passing a url with get

I recently needed to pass a URL in the get string as I redirected a form submission to an external server. The URL had parameters which clearly would have conflicted with the string and would have been perceived as additional parameters of the original string.


http://www.yoursite.com
/page.asp?redirecturl=www.mysite.com
/optin.php?thankyou=1

How to select only unique values in SQL

I was recently presented with the need to select only values that are unique. Shortly after finishing I came across someone asking how to pick off unique entries using SQL. The task is complicated when you consider it in terms of logic but SQL provides the tools to make it surprisingly simple.


SELECT `column`
FROM `table`
GROUP BY `column`
HAVING (
COUNT( `column`) =1
) 

Let's say you were using the test data below:

Should you use email for private information?

A partner of mine recently sent me an email intended for a client of his from his side business. I avoided looking at the details once I suspected it was a mistake but it was a lengthy conversation thread several emails long full of conversation about business deals and pricing. This of course got me thinking about how secure we should really feel about email.

MySQL and finding out if a value [NOT] EXISTS

One of the more useful tools in SQL especially for drawing up reports but by no means limited to this purpose, is the use of sub-queries and [NOT] EXISTS.

I commonly find IF NOT EXISTS used for INSERT statements to avoid overwriting existing data but this type of statement and use is very different.

You can determine if a value never occurs in a record set or you can very quickly and simply find out of a value does indeed occur.

To find if there are orphan products not assigned to a category:

Relationships with clients or developers matter

The relationship you have with your client or your developer determines to a large extent the quality of the resulting project.

I am convinced of this.

I have seen many projects developed where the relationship was minimal and the feedback and input from both parties was empty or unidirectional and the results were always lackluster. Whenever the relationship was vibrant and based on mutual respect or even admiration, then the results were not only beyond what either party had produced int he past, but also rewarding.