Thursday, July 23, 2015

ColdFusion and FOR XML AUTO

I had a task: given a SQL Server query using FOR XML AUTO, XMLSCHEMA, build a file using ColdFusion. Easy peasy, right? It returns one column containing the entire XML document. Get that and you're home free.

NOT easy peasy.

When the query is returned to ColdFusion, it is broken up into smaller pieces, each in its own row (I understand this is because of the database driver). The column name is dynamic; you can't depend on it being anything in particular, or even staying what it was yesterday. I found various solutions on the Web, using a number of weird techniques (Query of Queries, looping, etc.) but I ran across one that utilizes several powerful features of recent versions of ColdFusion to output the whole thing in one hunk.

First: In your <cfquery> tag, make sure you specify the "result" attribute. I believe this was added in ColdFusion 8. We need it to figure out what the name of the column is from its property called "columnlist". (I almost always call it "query_result", but you can name it whatever you want.)

Second: Understand that you can reference a ColdFusion query using Struct-like notation. So you can see the contents of any cell by referencing it this way:

query name: my_query
columns: column_1, column_2, column_3
fifty rows returned

my_query["column_1"][10]

This would return the information in the 10th row of "my_query", in the "column_1" column. (Never forget that this is not an array of struct - the row number comes last, after the column name.)

Third: I discovered that you can supply a blank delimiter to "ArrayToList" and all of the elements of the list are concatenated. So:

<!--- Create my_array[1]='A', my_array[2]='B', my_array[3]='C' --->
<cfset my_array=['A','B','C']>
<cfoutput>#ArrayToList(my_array, "")#</cfoutput>

Will output a three-character string ABC.

Now: Put those pieces of information together and you can do this:

<cfquery datasource="my_datasource" name="my_xml_query" result="query_result">
SELECT * FROM my_table FOR XML AUTO, XMLSCHEMA
</cfquery> <cfset my_xml_string=ArrayToList(my_xml_query[query_result.columnlist],"")>

I'm certainly no Uncle Ben, but I thought this seemed like a pretty cool trick.

Thursday, April 9, 2015

Cox and their "Nerd-Level Wi-Fi"

Cox Cable, your "nerd-level Wi-Fi" commercials are not only an insult to the intelligence of nerds everywhere, but they are spreading misinformation in the name of marketing.

For those who may not have seen or heard these breathless commercials, Cox has been advertising heavily that they have the "fastest Wi-Fi available", which they are referring to as "nerd-level Wi-Fi". Here's an example (double-click it to go full-screen):




Cox's offerings are fast, sure, but they're going over a line my saying they are giving their customers the "fastest" anything available. Here's my evidence:


1. My mom just got a brand new cable modem from Cox a month or two ago, just like the one in the TV commercial above. It is, I believe, a Ubee Ddw365 modem, and it supports the 802.11n Wi-Fi standard. This is indeed the fastest Wi-Fi standard which is in common use right now, but a true nerd is not going to be satisfied with that when it is easy enough to find Wi-Fi routers that use the newer and much faster 802.11ac standard. According to Wikipedia, 802.11n tops out at 600 megabits/second, and 802.11ac can potentially reach 1300 megabits/second. "Nerd level" on the Wi-Fi side: myth busted.

2. A true nerd is not going to be satisfied with the admittedly fast Internet access from the cable TV company if there is any chance that he can get a fiber-to-the-home connection, which can potentially run five to ten times as fast as the maximum speed of a cable connection. On top of that, what Cox isn't publicizing is that cable Internet technology relies on a shared connection to the Internet. When your next-door neighbor is watching movies on Netflix through his cable modem, there is less capacity for you to watch your movies on Netflix through yours, and your connection slows down a little. The more people around you have cable Internet, the less likely you are ever going to approach maximum speed with your cable modem. Best case, your cable modem will top out at around 100-107 megabits per second; business accounts may be able to get as high as 400 megabits/second. In my area, Cox's fastest residential package offers 150 megabits/second. Fiber can reach speeds of 500 megabits/second or more - in the area I live in, the newer houses all have fiber-to-the-home capability, and the ISP offers up to 1,000 megabits/second to homes (and 10,000 megabits/second to businesses!) "Nerd level" on the speed side: myth busted.

3. Real nerds don't use Wi-Fi for tasks that require serious speed anyway. A real nerd is going to have Gigabit Ethernet, which means that he will have his whole home network delivering a steady 1,000 megabits/second down the wire to his computers. His 802.11ac Wi-Fi access points may suffer temporary slowdowns due to radio interference, sunspots, or whatever, but his wired connection won't have that problem. If he has a great job and can afford the REALLY new hardware, he might even have 10gb (10,000 megabits/second!) running in his house; the technology exists, although his Roku 3, which is wired into his network and not using Wi-Fi, is still toddling along at "10/100 Fast Ethernet" speeds (100 megabits/second).  But his computers will be pulling down data so fast it will make your head spin. (Actually, he probably isn't using a Roku - he's probably built his own media streaming box from a spare computer, so he's streaming considerably faster than that. But that's neither here nor there.)


And don't even get me started about all that "writing binary poetry" junk, and the other flights of fantasy that are in the commercials in a clumsy attempt add humor. It only highlights the true fact: that these commercials are an example of something written by people at ad agencies who, instead of trying to learn the technology and speak intelligently about it, are trying to "talk dumb" so that people who deep down feel dumb about all this inter-network-mubo-jumbo will feel like Cox is all chummy, on their side, helping them to binge-watch HBO Go a little easier.

The fact is, it IS a lot to understand. You have to do research if you want to have "the fastest". Heck, I had to do some quick research to make sure I'm more or less factual in what I've written here (and it's entirely possible I've got some errors or outdated information in what I've written). I don't have any issue with it if they are going to say "We are faster than DSL" (which, in general, barring heavy load, they can be). I don't mind if they say "Fastest Internet available in the area" (even though several parts of my geographical area do have fiber to the home). But don't tell me I can become a cool nerd by getting my new Cable modem. Just tell me it's fast enough that when I spend all night Friday watching episodes of Daredevil, I won't have to wait for them to buffer. That's fast enough for me.

Wednesday, July 10, 2013

Named Map Pins - get it right, Google!

Marking a location in Google Maps and remembering what it is has pretty much always been a pain in the neck.

Don't get me wrong... I know how to mark a place. I can pull it up in Google Maps on a computer and "star" it, or I can do basically the same thing on my Android. When I do, it comes up as a star on my phone or on my computer whenever I view a Google Map.

I also know the convoluted way to get the location to have a name. You star it in Maps, then of all places you go to Google Bookmarks (!) to change the name. Once you've done that, the place name comes up on Mobile when you view "My Places".

Sometimes it does, anyway.

Actually, more often than not, I still see the address in My Places, even when I've given the bookmark a name in Google Bookmarks. I've tried and tried to find a rhyme or reason to this, but I just can't figure it out.

Why, Google, why?

I don't know what person a specific address goes with, any more than I know what person a specific telephone number goes with. And if I want to find Bill's house, I'd darn well better know his address, even though the very reason I starred his house in the first place was so I would be able to find it later without having to look up the address!

Actually, that's not entirely true. I've figured out some work-arounds. If Bill is in my address book, I can put his address in there, and it's clickable to go to Maps. That's terrific as long as the latitude/longitude coordinates that Google resolves to for his address are perfectly correct. But I actually wound up resorting to installing a third-party Google Bookmarks app just for this purpose. So now instead of opening maps, I open that app, find my bookmark for the starred location, click it, and then the Maps app opens.

Don't even get me started on how the stars in the desktop version don't display my bookmark name... at all. Ever.

Come the heck on, Google. Knock it off fiddling with Google+ for just a day or two and get these technologies working together.

If you don't, I may never find Bill's house again.

Thursday, April 11, 2013

Sandisk Memory Zone: Bleah.

app logo of a squirrel
I'm a firm believer in backing things up. In my four decades of messing around with computers, I've lost things and had problems because of it often enough that when I finally caved in and got myself a smartphone, my first thought was to figure out a way to back it up with a minimum of fuss, preferably into "the cloud" instead of filling up my already bursting-at-the-seams hard drive. As a Google Voice fan, I knew that my contact information was safely stored in Google Contacts, but what about pictures? Videos? Ringtones? I wanted that stuff to be backed up in the cloud so that I wouldn't have to worry about it.

When I bought my spacious new Sandisk MicroSD card, I found a little piece of paper in the package that claimed it was going to solve this problem for me. It was a QR code with a link to an Android app made by Sandisk which can back up your stuff to any of a number of cloud providers. It could do it on a schedule, so I could set it and forget it. And copying things back to my phone is as easy as copying anything using a phone. Sounded great! (Here's the link.)

What I found was an app that does what the hype says... but does it slowly, awkwardly, and unreliably. I had so much trouble with it that I finally quit using it, but only after it apparently lost some of the information I was trying to back up!

First of all, loading up the app in the first place is excruciatingly SLOW. Apparently the app thinks that every single time it is loaded, it needs to fully index not only the contents of your MicroSD card, but the entire contents of your phone's internal storage, and also all of the files on any cloud storage you've configured (!) This takes an incredibly long time. A better strategy might be to cache the information scanned from the user's resources the last time the app was used and let the user get started poking on things, and re-scan everything in the background. That's more complex to program (I ought to know, I write software for a living), but it would be a much better user experience than "click to launch, go to lunch because it will take that long to start up."

I would be willing (but not happy) to tolerate the long startup time, however, for an app that performed well on what I wanted it to do, which was back up certain kinds of files at night when I'm asleep and not using the phone. I set up my backup schedule, and found that it backed things up to my cloud storage as expected... sometimes. I never figured out exactly what the reason was that it would back things up sometimes and not other times, but I did learn early on that if the app crashed, there was no easy way to get the darn squirrel out of my notifications tray. I rebooted the whole phone many times just to clear the icon so things I wanted to be notified about were more visible.

It worked often enough, though, that I would have been OK with even that, as long as it backed up the stuff I want to keep fairly often without screwing any of it up. Obviously, this was too much to ask. This app attempts to reduce backing up and restoring to very simple steps - there are categories for your photos, music, videos, documents, and so forth, without having to navigate your phone's folder structure (which is one reason for all of that initial scanning). So no matter where the app finds a picture, for example, it winds up in the "Photos" bucket. Picture of your children? Photo! Ad for beer from your browser cache? Photo! Image file used internally by an app you use once a month? Photo! MP3 of your favorite song? Oh wait, that's "Music". 10-second ringtone you bought three years ago and forgot you had? Music! Alarm sound that came preloaded on your phone? Music! "Ding" sound from your instant messaging app which you could recover by reinstalling the app? Music! There is no way I could find to select or unselect specific folders or files from being scanned, so every image on my phone was backed up to "Photos", and every sound on my phone was backed up to "Music" (I did un-select "Documents" and "Apps" because I keep documents in Dropbox and back up Apps with Titanium Backup, but those are two other stories).

I could have lived with this... after all, as long as the stuff I did want backed up was safe, having a few extra files is a fair price to pay, right? Well, I found out about that price the hard way when something - and I'm pretty sure it's this very app that's supposed to save me from disasters like this - deleted all of the photos and audio files from the phone. Eek!

The app is supposed to be able to copy files from your cloud storage back to your local phone storage with no trouble - Photos to Photos, Music to Music, etc. However, the app seemed to have forgotten where my backup on my Box.net account was (the default folder which the app itself had created), so I opened up the folders on my computer and took a look. When I realized that the app had backed up all sorts of superfluous information, my heart sank... this was going to be quite a job! But I set to work, and was able to find my ringtones and notification tones fairly easily and get them back on my phone where I wanted them. Getting my photos back, though, was another matter.

Ultimately, I restored less than 300 pictures that I had intended to back up. To get to them, though, I had to delete 2,476 superfluous images! These included hundreds and hundreds of album covers from Google Music, dozens of images of the covers of books from my Logos Bible software, images of the spaces and board layouts from Words With Friends, images from articles I had saved in Pocket to read later, pictures I've posted on Facebook, pictures I've saved in Evernote, and tons of stuff which appears to be from my browser cache, including a number of advertising banners. I literally had almost ten times the amount of garbage backed up as useful stuff. What a ridiculous thing to have to wade through!

One time doing that was enough for me. I actually had looked around for a different app to use, but hadn't found anything yet at the time, which is the only reason I put up with this stinker of an app in the first place. The concept is excellent, but the execution is lousy. The app is slow, buggy, and unreliable. It deleted the stuff I wanted it to preserve, and then gave me a hard time when I tried to restore it. I quit using it entirely months ago, and only yesterday did I look around for another replacement app - and I may have found one in FolderSync. I've installed the "Lite" version, and I'm trying it out. It takes a little more doing to get it configured (you actually have to tell it what you want backed up! It doesn't back up every file you ever touched!!), but if it actually does what it's supposed to, I'll plunk down a couple bucks for the full version. This free Sandisk thing is a mess. I love their memory media... maybe they should sort of stick to that.

Friday, April 5, 2013

The "Unlike" Project - First Month

Just over a month ago, I wrote this post explaining that I was beginning a campaign to "Unlike" things on Facebook. The idea was to start reversing one of my "Likes" on Facebook ever day, and then tweeting about it using the hashtag #UnlikeProject. The experience has been interesting in a lot of ways - I thought I'd give my "first 30 days" report (although it's actually been more than 30 days) and let you know what's been going on.

The first thing I noticed is that it is incredibly difficult to decide what to Unlike. Fact is, the things I've "Liked" are things that, in real life, I in fact do actually like! It feels a little bit like a betrayal, especially when you are Unliking things like The Bible or your favorite sports teams. It's also difficult to find the things that are less important to me so I can Unlike them first - I wound up making myself a list to make prioritizing easier. I don't intent to Unlike everything, so I need to make sure I find the things I want to free myself from first. (Pages set up by friends of mine, for example, or organizations that I genuinely do want to stay in touch with will probably stay in my "Likes".)

Some of the earliest casualties were Pages that post a lot. The reasons those got the axe first was that I was more likely to see their posts in my News Feed and remember "Oh yeah, it annoys me when I see them there!" or "Their posts are never interesting," and then I could wipe them out and be done with it. But even with the easy pickings of those frequent posters and with my "Unlike first" list, I still didn't Unlike something every day - once I Unliked two things in one day, and four or five days I forgot altogether.

Two different organizations actually saw my "Today I Unliked..." tweets and responded to them, apologizing for whatever they did that put me off. Fact is, they didn't do anything, and I told them so! This is all about cleaning things out and simplifying... and insulating myself and my friends from invasive advertising as much as possible. I do have a positive opinion of those organizations, thought... kudos for keeping an eye on your Twitter mentions (I didn't actually even mention them by @ handle, so they're watching keywords) and reaching out to people based on that! That's the way to DO social media!

During the month, I also discovered a few facts that back up my reasons for doing this:
I'm actually enjoying the project - there's a sense of freedom in it, like when you've cleaned out the junk from the garage or gotten all the bills paid for the month. Maybe you'll give it a try? If you do, make sure you remember to tweet your Unlikes with hashtag #UnlikeProject so I'll know you're in!


Is it nuts to just start Unliking things that you actually do like? Why will you be joining the project, or why not? Sound off below by clicking the "Comment" link!

Saturday, March 16, 2013

Google Collects Things People Shouted From Rooftops - Ordered to Pay Someone Else As Punishment

from DailyTech:

Google Ordered to Pay $7 Million to U.S. States for Wi-Fi Snooping Incident

Google is finally settling a three-year investigation this week into a Wi-Fi incident that occurred when compiling data for its mapping service.

Google's Street View mapping cars had accidentally collected personal data, such as home wireless network passwords, between 2008 and 2010. The cars were out collecting images and data for the Street View mapping system in Google Maps, and were using an experimental computer code in the cars' software while doing so. This led to the accidental collection of personal data.

The settlement orders that Google split $7 million among 38 states in the U.S. and the District of Columbia, which were involved in the incident.
Read the rest here.

First off, some background. A few years ago when Google's cars were driving around the country taking the pictures that are now part of the popular "street view" part of Google Maps, the cars were (accidentally, Google says) also taking snapshots of something else. As they were driving around photographing streets, businesses, neighborhoods, apartment buildings, and everything else, the cars also had software running that was recording Wi-Fi signals.

Why did this cause a problem? Because whatever you do with your wireless laptop, smartphone, tablet computer, or anything else that communicates over Wi-Fi could be intercepted and recorded. This is a basic principle of radio communication. This can include instant messages, emails, Web browser requests (like what URL you are visiting)... anything that you do on your Wi-Fi.

Does this creep you out? Well, it shouldn't. Because you should have the sense to do something very basic on your home Wi-Fi: put a password on it. Don't leave your Wi-Fi in the open. When you put a password on your Wi-Fi, it is encrypted, and although traffic can be recorded, it doesn't make any difference... because it's in a code which nobody likely cares enough to try to break. It's secure enough that recording it doesn't make any difference.

On top of that, if you are logging into a site... say, your bank, or your credit card provider... the URL on your Web browser should start with "https://" (and not just "http://" - the "s" is the important part). If it does not, it's time to choose another bank. The "s" means that the bank is encrypting (encoding) all of the communication between you and it, so even if you are on an unprotected Wi-Fi network, your password and other communication is still in a code that is too strong to be worth trying to break.

So despite the fact that most everyone has gotten the clue and set up passwords on their Wi-Fi, and despite the fact that even email services lik Gmail encrypt your password with https://. and despite the fact that Google admits that it recorded the Wi-Fi signals and says it was an accident, and despite the fact that they have promised to erase the recorded information... Google is being told to pay some sort of punitive damages.

But not to the people who had Wi-Fi signals recorded. Not to the individuals. Directly to the states.

How were state governments harmed by this? They weren't. Really, the consumers weren't harmed either. This is a tempest in a teacup. And how does a $7 million settlement teach anything to a $100+ billion company? It doesn't. Google probably contributes that much to the United Way every year. Heck, Google probably spends that much in fuel for the Street View cars every year!

This whole thing is silly. I hope at least part of that settlement with the states goes to pay the salaries for the judge and other people the courts employs to hear cases like this, so none of my taxpayer dollars paid for it.

Thursday, March 14, 2013

A Situation - And A Recipe

I just got an email. The email says "Your cell phone battery is getting low!" I checked my phone, and sure enough, the battery was down to 15%, so I plugged it in to charge during the afternoon so I don't run out of juice before bedtime tonight. Who emailed me? Well, the cell phone did, of course! Actually, it texted me... but let me start from the beginning.


A Locale Situation
One afternoon a few weeks ago I realized (when I was already on my commute home from work) that my phone battery had run down. I have charging cables in the car, of course, but my commute is only long enough to charge it partway... I ran out of power again later that evening. I realized that I had already set up something to check the battery level of my phone: a "Situation" in an app I use called Locale. In a nutshell, a Locale Situation monitors "Conditions" (such as your physical location, the time, or whether your phone is face-up or face-down) and when they match a set of Conditions you have configured, it activates "Settings" which can be settings on your phone or might be other actions. The app allows you to add new Conditions and Settings through a plug-in architecture. I've set it up to do things like make sure Wi-Fi is on when I'm at home and turn off the ringer when I'm at church.

I had also set it up to turn down the brightness of my display automatically when the battery power is below 15%, on the theory that this will stretch the battery just a little longer. That didn't help me realize that the battery was getting low that day, though, so I wanted to do something more.

Enter the Send SMS Plug-in. When you install the plug-in, you get a new "Setting" in your options - the "Setting" does not change a setting on your phone, but instead it automatically sends an SMS message from your phone to whatever recipient you like. This is terrific, but I didn't really want to be notified via SMS on my phone. When I'm at work and my battery gets low, I want to get an email... I monitor my work email closely when I'm at my desk, much more closely than I monitor the SMS stream on the phone itself. I tried sending an email through the Send SMS Plug-in, but even though you can do that through the stock SMS app, you couldn't do it through Send SMS. There are other apps (like this one) which I could have used, but SMS messages can often be sent even when the phone is having trouble connecting to the Internet. I wanted to send an SMS message, but receive an Email.

Enter IFTTT.

IFTTT (pronounced exactly how it looks, like the word "if" and then the letter "t") stands for "IF This Then That." And that adequately describes what IFTTT does - you associate it with things you do (Twitter, Facebook, blogs, CraigsList, Evernote, the time, the weather, etc.), and then configure associations so that if a certain condition exists on one of those things, something happens on another of them. The "things" are called "Channels" and they may act as either the instigator or the recipient of an action. For example, when this blog post is published, IFTTT will see it in the RSS feed and will automatically schedule it to go out to my Twitter stream via HootSuite. In this way (if a condition exists, do something) it is similar to Locale, except almost every IFTTT Channel can be checked (like a Locale "Condition") or do something (like a Locale "Setting").

IFTTT has Channels for SMS and Phone Calls. Once you've set them up to match your phone, an SMS message from you can trigger something (for example, automatically save the SMS to a new note in Evernote), or IFTTT can send an SMS to your phone. The Phone Call channel can either receive a call (which it then can transcribe) or place a call using text-to-speech. Finally, IFTTT can send an email, using the Email channel, to any address you like.

Bingo!

I set up an IFTTT "Recipe" to receive SMS messages from my phone with a Twitter-style tag which indicates that I am at work, and forward those messages to my work email address. Then I set up Locale to check my battery level and my SSID, and if I'm on my work WiFi network, Send an SMS reading "Your cell phone battery is getting low!" with the special "I'm at work" tag to the IFTTT SMS number. I also set up a separate Locale/IFTTT combo to actually call me via voice if my battery gets low and I'm not at my desk! In theory, I should never again discover that my phone battery is discharged below the point of no return... I should always know about it ahead of time.

So that's how I wound up today getting an email from my phone that the battery was low. Pretty cool? Yes. A little convoluted? Kinda. Pretty geeky? Definitely. Useful? ABSOLUTELY.

Do you use Locale or IFTTT? Have you set up any groovy Situations or Recipes that you'd like to share? Have you ever used synergy between multiple online services to build something cooler than the component parts? Tell us about it below in the Comments!