Earth : Low Light Camera Time Lapse View

I still remember being amazed by the stunning video of Earth from space while watching one of the few IMAX productions I’ve seen in life. It was probably back in 1997 with the “Mission to Mir” IMAX documentary. Shown on a specially coated silver screen stories high shot with large format film; It was the beginning of high-definition video.

Since then we’ve grown used to being able to see house-wide images from space on our computer screens and smart phones. The view of Earth has become mainstream and lost a bit of its artistic appeal – until Michael Konig pieced together 18 time-lapse video shots from the International Space Station from August to October of 2011. These time-lapse videos where taken with a low-light camera and bring back the art of the Earth at night including clips of the Aurora Borealis.

This is a must see check it out in full-screen mode.

 

Adobe Flex Builder 3 Download

I had to track down a download location for Adobe’s Flex 3 install today. It was a little hard to find so I thought I’d share this link for a Windows install:

http://download.macromedia.com/pub/flex/flex_builder/FB3_win.exe

Why it’s at a macromedia.com address I have no clue, but hope this helps someone out. This defaults to a 60 day trail and you can enter your license as well.

Drop Test of the iPhone 4S and Galaxy S II

My opinion of the iPhone, while I’ve never owned one, was that the glass was not prone to much breakage due to their impact resistant glass. In the iPhone 4S Apple is stating it is aluminosilicate glass; stuff they use in the windshield of high-speed trains and helicopters. Unlike the older iPhone models, the iPhone 4 has both the front and back made of this kind of glass, which Apple says is chemically strengthened to be “20 times stiffer and 30 times harder than plastic.”

Acording to  “iFix your i” , the glass covering the display on the older iPhones was recessed and protected by a chrome bezel, while on the iPhone 4, the glass sits on top of the steel frame, which exposes it more to damage.

For reference I’ve never been a fan of the Galaxy S models because I’ve seen a lot of breakage in their screens as well. But check out this video:

So basically if you drop it from the height of your ear down to a solid surface after some prior abuse (which you could fully expect from any user), there’s a good chance your iPhone will be no longer usable without glass shards getting stuck in your ear.

Here’s another video to back that test up:

I personally own an HTC Incredible and have never broken my screen even after a number of drops. I remember going into Verizon’s store one day and the sales associate dropped the Samsung phones about 6″ and then the HTC phones 6″. You could hear how more solid the HTC’s where compared to the Samsung, also stating that the Incredible’s where using Gorilla Glass for the screen. So I’m glad I made that choice.

None of these drop tests where scientific, but it appears Apple really dropped the ball on durability with the iPhone 4. But I’m sure iFixYouri appreciates the business.

Proper Parentheses Placement In Ternary Statements

Consider the following code:

a = b = c = 1000000;
r = (a > 10000) ? a/1000 : a & "/" & (b > 10000) ? b/1000 : b & "/" & (c > 10000) ? c/1000 : c;

(if you think the first line is odd – see Chaining ColdFusion Assignment Operators)

My thought was r would return “1000/1000/1000” — however it actually returned “1000”. Where did I go wrong?

Now if I change a,b,c to 1000 it would blow up to a “cannot convert the value “1000/NO” to a boolean” error.

So what’s going on? The third argument of the statement becomes another ternary statement but can not convert the evaluated “1000/NO” to a Boolean – thus blowing up. If a,b,c = 1000000 then the operation never gets to the third argument and returns only “1000” never considering the ampersand in its logic.

So correct code would be:

a = b = c = 1000000;
r = (a > 10000 ? a/1000 : a) & "/" & (b > 10000 ? b/1000 : b) & "/" & (c > 10000 ? c/1000 : c);

Or depending upon your preference:

a = b = c = 1000000;
r = ((a > 10000) ? a/1000 : a) & "/" & (b > 10000) ? b/1000 : b) & "/" & (c > 10000) ? c/1000 : c));

Now there are three seperate ternary statements concatenated together with a slash between them.

Serving Files with Spaces in the File Name Using CFContent

I ran into an issue where using CFContent to serve a file with spaces in its name was truncating the file name. For example the file “Foo Bar.xls” was saving as “Foo”, lacking ” Bar.xls”.

<cfheader name="Content-Disposition" value="attachment; filename=#getFileFromPath(filePath)#">
<cfcontent file="#filePath#" type="application/octet-stream">

You can find many examples of this type of code out there for securing files using ColdFusion and its cfcontent, so apparently it’s a common oversight.

The fix to truncated file names is very simple but no so obvious.

What doesn’t work:

  1. Don’t wrap the file name value in anything
  2. Wrapping the file name value in single quotes
  3. Wrapping the file name value in double quotes

What does work:

  1. Wrap the file name value in escaped quotes (doubled up such as “”#filename#””)
  2. Wrap the file name value in character valued double quotes (chr(34))

The new example would look something like this:

<cfheader name="Content-Disposition" value="attachment; filename=""#getFileFromPath(filePath)#""">
<cfcontent file="#filePath#" type="application/octet-stream">

Thanks to Ben Nadel for providing this solution.

See my previous blog on serving files with CFContent at https://christierney.com/2009/08/12/securely-serving-files-via-cfcontent/ .

Chaining ColdFusion Assignment Operators

Thanks to Mike Henke, I found out you can chain assignment operators (“=”) in ColdFusion.

An example of this would be:

var1 = var2 = var3 = 123;

Resulting in:

var1 = 123
var2 = 123
var3 = 123

Behind the scenes it’s interpreted such as var1 = (var2 = (var3 = 123));
(It is right-associative, being the last assignment operation is evaluated first and propagated leftward. Also, don’t try that interpreted code in CF because it will fail.)

While not a major find in programming history, this little flick of keystrokes can save you some repetitive typing should you ever need to set multiple variables to the same value.

Read XML from a HTTP POST

I program scripts to read XML posts just every once-and-awhile, and although very simple, every-time I forget how to do it.

Let’s say that we receive a XML HTTP POST via this code:

<cfhttp url="http://yourdomain.com/xml.cfm" method="post">
<cfhttpparam type="XML" name="MyXML" value="#myxml#">
</cfhttp>

This is what you would use to read that POST:

<cfset xmlPOST = GetHTTPRequestData().content>
<cfset xmlDOM = XmlParse(xmlPOST)>

The key here is the GetHTTPRequestData().content. Notice how we do not use form.MyXML.

Now we can manipulate the XML data using standard dot notation such as xmlDOM.Content.Value.XMLText.

jquery.validate Range Method Patch

If you use the range attribute inline to validate against using the jquery.validate plugin 1.8.1, your validation will probably always fail and receive the message “Please enter a value between NaN and {1}.” or “Please enter a value between {0} and NaN.”.

This drove me nuts for almost a whole day looking for a fix. I finally got smart and looked at the current issues in the Github project. “markusblair” submitted a patch, but that was also incorrect.

To correct this issue, modify the jquery.validate.js file on line 852:

		$.each(['rangelength', 'range'], function() {
			if (rules[this]) {
				rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
			}
		});

and replace it with:

		// Patch by Chris Tierney (CF Webtools 7/13/2011)
		// Issue logged at https://github.com/jzaefferer/jquery-validation/issues/112
		$.each(['rangelength', 'range'], function() {
			if (typeof rules[this] == 'string') {
				rules[this] = rules[this].split(",");
			}
			if (rules[this]) {
				rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
			}
		});

Be sure to update your minified version as well and this should solve the range and potentially a similar rangelength method issue immediately.

jquery.validate Better Date Method

The jquery.validate plugin currently has the validation method “date” which will correctly validate the format “xx/xx/xxxx”. However you can enter a date such as “40/01/2011” and it will pass. Obviously there is no month 40 or even day 40.

Borrowing from the “dateITA” validation method in the additional-methods.js I created a “dateUS” validation method that will detect for not only a correctly US formatted date but a valid date as well using the “mm/dd/yyyy” format.

Add this to your additional-methods.js file or load in another methods file (ex:my-methods.js):

/**
  * Return true, if the value is a valid date, also making this formal check mm/dd/yyyy.
  *
  * @example jQuery.validator.methods.date("01/01/1900")
  * @result true
  *
  * @example jQuery.validator.methods.date("13/01/1990")
  * @result false
  *
  * @example jQuery.validator.methods.date("01.01.1900")
  * @result false
  *
  * @example <input name="pippo" class="dateUS" />
  * @desc Declares an optional input element whose value must be a valid date.
  *
  * @name jQuery.validator.methods.dateUS
  * @type Boolean
  * @cat Plugins/Validate/Methods
  */

jQuery.validator.addMethod(
	"dateUS",
	function(value, element) {
		var check = false;
		var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
		if( re.test(value)){
			var adata = value.split('/');
			var mm = parseInt(adata[0],10);
			var dd = parseInt(adata[1],10);
			var yyyy = parseInt(adata[2],10);
			var xdata = new Date(yyyy,mm-1,dd);
			if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) )
				check = true;
			else
				check = false;
		} else
			check = false;
		return this.optional(element) || check;
	},
	"Please enter a date in the format mm/dd/yyyy"
);

Use “dateUS” as your validation method.
Example: <input type=”text” class=”dateUS” name=”myDate”>

Context Menu In CF Builder Team Synchronizing – It Exists!

Today I filed a bug with Adobe #2903404 – No file context menu in Team Synchronizing (right-click)
 – Go vote for this bug if you have the same issue  –

I was made aware by a co-worker of mine about the fact that you could not get a file context menu in ColdFusion Builder 2.0 while in the Team Synchronizing perspective (right-click on file). Though I thought I remembered that context menu before in v1, I just though it was what it was and it sucked. Come to find out there’s a workaround.

Thanks to CFgears here’s the workaround:

  1. Look in the plugins folder of the CF Builder install. There is a plug-in folder called “com.aptana.ide.syncing_X.X.X.XXXXXX”.
  2. Open up the “plugin.xml” file in there.
  3. Change all occurrences of “synchronize to “aptanasynchronize (include the initial double-quote… there should be 16 replacements).
  4. Save the file.
  5. Start eclipse/cfbuilder from the command line with a “-clean” flag.

Update 2/23/2012 : 2.0.1 Public Beta ticket 3121975