grab our rss feed  WarpConduit on Facebook
WarpConduit.Net

New Web Host

I’ve moved the site to a new web host, hopefully it will be more responsive for everyone.  I’ve already found some features that are lacking, but they aren’t big deals and for the price I can’t complain.

Interesting UNIX Time Stamps

For your reading pleasure, some interesting UNIX time stamps:

0 – UNIX Time Begins – Thu, 01 Jan 1970 00:00:00 GMT/UTC
2147483647 – Last 32-bit SIGNED INT – Tue, 19 Jan 2038 03:14:07 GMT/UTC
4294967295 – Last 32-bit UNSIGNED INT – Sun, 07 Feb 2106 06:28:15 GMT/UTC
9999999999 – Last INT(10) – Sat, 20 Nov 2286 17:46:39 GMT/UTC
99999999999 – Last INT(11) – Wed, 16 Nov 5138 09:46:39 GMT/UTC
999999999999 – Last INT(12) – Fri, 27 Sep 33658 01:46:39 GMT/UTC

UNIX time stamps converted using OnlineConversion.com.

PHP’s in_array() vs. jQuery’s inArray()

This one stumped me for a bit when i was trying to use jQuery to populate checkboxes with a list of items pulled from a database using PHP.

The fact of the matter is that PHP’s in_array() returns a boolean whereas jQuery’s inArray() returns the index of the matching element, or if the element is not found it will return -1 or undefined, depending on the browser.

Problem

If you are used to using PHP like me jQuery’s inArray() can give you a headache when you are using the returned value of the function in an if-else condition. This is because -1 evaluates as true, when you really want it to evaluate as false.

Solution

Make it so that your if-else condition checks for a value >=0 (greater than or equal to zero). Since array’s don’t have negative indexes you’re safe doing it this way.

What did i learn from this? When working with a new function check the documentation for what type of data it will return.

jQuery.inArray Documentation

Example

<script>
	var myArray = ['a', 'b', 'c'];
	document.write(jQuery.inArray('a',myArray) + '<br/>'); //returns '0'
	document.write(jQuery.inArray('b',myArray) + '<br/>'); //returns '1'
	document.write(jQuery.inArray('c',myArray) + '<br/>'); //returns '2'
	document.write(jQuery.inArray('d',myArray) + '<br/>'); //returns '-1' or undefined
</script>

RewriteRule and Trailing Slashes

Just a quick post today, i needed to redirect a URL with and without a trailing slash to the same destination, but didn’t want to create two separate rules, so I did some searching and found that it is very simple.

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^video(/)?$ http://video.somedomain.com [R=301,L]

The (/)? is the key to matching a url with or without a trailing slash.

Page 6 of 9« First...45678...Last »