Posted April 25, 2012 by Nick Vogt in Miscellaneous
In Windows 7, numbered file names are sorted based on numerical value:

In previous versions of Windows, numbered file names were sorted literally, based on each digit:

Continue reading...

In previous versions of Windows, numbered file names were sorted literally, based on each digit:

Continue reading...
Posted April 17, 2012 by Nick Vogt in Web and Internet
Due to the extremely high resolution of many new mobile devices like the iPhone 4 and Galaxy Nexus/Note, low width websites may be displayed zoomed out or with large empty margins. These three meta tags will allow most mobile browsers to properly display your mobile website in full screen:
Continue reading...
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="400">
<meta name="viewport" content="width=400">
<meta name="MobileOptimized" content="400">
<meta name="viewport" content="width=400">
Continue reading...
Posted April 5, 2012 by Nick Vogt in Programming
The ternary operator is a short-hand way to write out "if/else" condition checks on a single line, and allows you to perform condition checks inline with echo statements, variable assignments, and more!A ternary condition check takes the form:
CONDITION CHECK ? IF_TRUE : IF_FALSE;
Continue reading...
Posted April 5, 2012 by Nick Vogt in Programming
Any data that comes from the client-side needs to be properly validated and escaped before using. This is extra important if you're using that data to form part of a database query. Always assume that your users will try to input incorrect information and special characters into fields, and do not rely on HTML or JavaScript to prevent this.Take a look at this simple, unprotected sign in script:
$q = mysql_query('SELECT * FROM users WHERE password = "' . $_POST['pass'] . '"');
if(mysql_num_rows($q) == 1)
{
// Signed in!
}
if(mysql_num_rows($q) == 1)
{
// Signed in!
}
Continue reading...
Posted April 5, 2012 by Nick Vogt in Programming
PHP is a fairly loose programming language, which causes many new developers (and experienced ones) to get lazy. If you suppress errors, you can get away with ridiculous things like using undefined variables, without anyone being the wiser. But just because you can get away with it, doesn't mean you should.Continue reading...
Posted April 5, 2012 by Nick Vogt in Web and Internet
Want to see how well your web server is performing? It's a good idea to have some sort of 3rd party monitoring program that regularly pings your web server and logs the response time and timeout events. If your server is not being nice (or not meeting their claimed uptime), you can use this data as leverage for negotiating or just to inform them that you're seeing more downtime than you'd like.Continue reading...
Posted April 3, 2012 by Nick Vogt in Web and Internet
You can spoof the user agent on your Android phone fairly easily, using Firefox and the Phony plug-in. This allows you to make websites think you're browsing on a desktop computer, iPhone, or something else. The Phony plug-in interfaces directly with Firefox's settings panel, and gives a convenient drop-down list for user agents (so you don't have to know the actual user agent string). I use Firefox with the desktop user agent spoof, which allows me to browse sites as if I were on a desktop PC.
Continue reading...
Posted April 1, 2012 by Nick Vogt in Programming
When comparing two values against each other, it is common to use the "equals" operator (==), and this is fine as long as you have control over the values that are being compared. But what if you're comparing user input against a value, such as in a sign-in script or captcha? Using the equals operator can potentially leave you open for security issues, since PHP handles comparisons between different data types non-intuitively. If you compare an integer to a string, PHP will evaluate the string as a 0 integer unless that string starts with a number, in which case it will truncate the non-number characters. This may be over-simplifying things a bit. Here are some examples:
var_dump('asdf' == 0); // true!
var_dump('asdf' == '0'); // false
var_dump('3sdf' == 0); // false
var_dump('3sdf' == 3); // true!
var_dump('asdf' == '0'); // false
var_dump('3sdf' == 0); // false
var_dump('3sdf' == 3); // true!
Continue reading...
Posted March 23, 2012 by Nick Vogt in Programming
This method relies on the HTTP_USER_AGENT value in the $_SERVER super global. Since this value ultimately comes from the client's browser, it can be spoofed, though don't expect a large portion of visitors to know how. I wrote a post on how to spoof your user agent on Android for those curious.
Continue reading...
Posted February 26, 2012 by Nick Vogt in Web and Internet
The style of a text link on a web page (hyperlink) should do two things effectively. It should clearly distinguish the link from normal text, so that users can see it at a glance, and it should create a clear hover effect, so users know when their mouse is hovering over it and that a click will activate the link.The default link style in most browsers is blue with an underline. There is usually no default hover effect, other than the mouse pointer turning into a hand. The blue color and underline are widely recognized as links, so when designing your links you will want to keep that in mind. You don't have to stick to these conventions, but you can design very intuitive links by building off of them.
Continue reading...
