Categories
Uncategorized

Charts & Graphs

I’m in need of graphing some data, and since I looked at the Google Chart Tools long ago but never did anything interesting with it, I figured I’d give it a spin.

Google’s API is pretty simple to use, you feed it a URL, and you get an image in return. Here’s an example expanded out a bit:

http://chart.apis.google.com/chart?
  cht=lc&
  chs=600x400&
  chg=10,5,5,5&
  chco=ff0000&
  chxt=x,y&
  chxr=1,0,100,5|0,0,24,1&
  chd=t:3,3,3,3,3,3,3,65,38,46,60,59,56,58,36,21,13,62,2,3,3,3,3,2

Each parameter controls some part of the image you get returned. (Want to see it? View the URL.)

You should get something that looks like this:

Chart

Wow… but not really. This is probably one of the simplest examples of a chart, but it serves my purpose.

Of course, since I’m not always content relying on others to host my data, I wanted a way to generate and store the image. You can do that too…

curl -o 20101130.png 'http://chart.apis.google.com/chart?cht=lc&chs=600x400&chg=10,5,5,5&chco=ff0000&chxt=x,y&chxr=1,0,100,5|0,0,24,1&chd=t:3,3,3,3,3,3,3,65,38,46,60,59,56,58,36,21,13,62,2,3,3,3,3,2'

Just use curl to make the request and store the image in a file named 20101130.png (or whatever the date is, or file name you’d prefer.) Obviously you’ll need curl installed. If you need to generate a new chart everyday this is ripe for automating.

I also looked at jQuery Visualize as an option. It’s quite different than the Google Chart API as to how it functions.

Chart

With jQuery Visualize you don’t actually create a chart. Well, you do create a table of data, and jQuery Visualize does all the heavy lifting and creates the chart based entirely on your well-formed tabular data.

I sort of like this approach because there’s no external image files to generate, host, or worry about. You just make a table, and include a bit of Javascript. (Of course there are other concerns/issues, but simplicity is pretty high.)

I’m still evaluating what my final choice will be for my current project. If this were 10 years ago, I probably would have used Perl to generate the image files. If it were 5 years ago, I probably would have used Perl to generate some SVG files…

jQuery Visualize uses the HTML 5 Canvas element, so they get some points in the “innovation” column I guess… Also, jQuery Visualize requires less math, and in my world, the less math I have to do, the better!

Categories
Uncategorized

Chrome Annoyance #137

View Source

Here’s a Chrome annoyance… I don’t like that the ‘View Source’ command is under a menu titled ‘Developer.’

It’s bad enough that it’s a submenu and not readily apparent at a top level, but to stick it under ‘Developer’ seems almost as bad as putting it under a menu titled ‘WARNING!’

I’m sure the people behind Chrome believe they are making things simpler for users, right? I mean, such things should be hidden from the “normal” people, as they wouldn’t understand it.

But the thing is… when I learned to write HTML, the number one tool to aid in learning was the ‘View Source’ command. I know this was 15 years ago, but I’m not convinced a better method has come along yet. (If it has, let me know.) I’ve always liked that the ‘View Source’ menu was up front, easily available, calling out to anyone curious as to how a web page worked. Just a click away…

I always feared that a browser would come out that didn’t include a ‘View Source’ option, but I’m pretty sure even Internet Explorer has one.

Oh, and another thing (consider this #138) why do they hide the protocol? I actually like to know if it’s http or https and have the ability to easily toggle between the two. I guess I’m just a developer and these things scare and confuse normal people though…

(And yes, I know the screenshot is Chromium and not Google Chrome but the UI is the same in both.)

Categories
Uncategorized

Evil-O-Mator

Evil-O-Mator

I unveiled the Evil-O-Mator during the September 2010 Web414 “Mystery Show!” It will tell you if your favorite web company is evil.

You may want to ask about Google, or Facebook, or maybe even… Twitter!

I built the Evil-O-Mator because I needed a small project to play around with HTML5 and also because I couldn’t sleep one night. (And also because we had nothing planned for Web414 and I figured this could chew up a good 5 minutes of time…)

So go on, ask me about evil, and when you’re done, think about how you can contribute to Web414. Thank you, and good night.

Categories
Uncategorized

Mac OS X Text to Speech

I recently worked on a project that required making audio files out of text files, which is something I’ve done before, but haven’t done regularly since 2000 or so when I was making cassette tapes of web pages. There’s a simple way to do this using Mac OS X.

Keyboard System Preferences

Open you System Preferences and go to Keyboard and select the Keyboard Shortcuts pane. Click on Services and scroll down to Text until you see Add to iTunes as a Spoken Track and check that box.

TextEdit

Now open TextEdit and select some text and control-click (or right click depending on your computer input device) and you’ll see a contextual menu item for Add to iTunes as a Spoken Track. Select it.

iTunes

Now jump over to iTunes and you’ll see the track. It’ll be called Text to Speech.

M4A audio file

In iTunes you can highlight your track and select the File menu and then Show in Finder (or just hit command-R) and the Finder will open the folder containing your file. It’s an MPEG-4 Audio file (also known as an AAC file) with an m4a extension.

ITunes can obviously convert the file to an MP3 for you, but if you want another format (like OGG) you can use Audacity. You should be able to do whatever you need to do with it from there, (And that whatever you need to do with it bit was the deciding factor for this specific project.)

I was really hoping to use an existing test-to-speech API on the web to automatically generate the audio. Google has an unofficial Text-To-Speech API (go on, try it.) Seeing as it’s “unofficial” and didn’t work in the way I wanted to use it, and there is an awesome group where people ask about APIs and ToS and no one answers, I skipped it.

AT&T also has a great text to speech demo online, which clearly spells out how you can’t use it, which is quite helpful. (Basically you can’t use it for anything public or commercial, which sucks, but I’m glad they come right out and say it.)

There are other options (almost all commercial) including services like iSpeech, which I may look into. There may be some open source text to speech options, but as to how good they are, or how easy they are to get up and running, that is yet to be seen… or heard, as it were.

(Note: I’ve got a follow-up post coming about Mac OS X Text to Speech via the command line.. stay tuned!)

Categories
Uncategorized

I Googled Apple

I Googled Apple

I swear I won’t use the word “evil” or “conspiracy” in this post, but…

This seems weird to me. I used Google to search for “Apple, Inc.” and I got a search result for “www.apple.com” with the title showing “Apple Computer, Inc.”

Now, as you know, “Apple Computer, Inc.” recently changed it’s name to “Apple Inc.” so I wasn’t sure why Google showed it as “Apple Computer, Inc.” I then went to www.apple.com and the title of the page is just “Apple” not even “Apple Inc.”

So that begs the question… What’s up? If they indexed the page the same as they index every other site on the web, why does it not match? Is Apple feeding a different result to the Googlebot? (A quick test with Perl’s LWP::UserAgent says probably not.) So really… what’s going on? I’d like to know…