Saturday, November 28, 2009

Adding RSS feeds in Google Chrome

Whilst in Google Chrome, I tried clicking on an RSS feed icon in Craigslist and was rewarded with a bunch of XML. To avoid figuring out which piece I needed to add a feed to Google Reader, I did the following:

  • Went into Firefox
  • Clicked on the RSS icon
  • For "Subscribe to this feed using:", I clicked on Google
  • Then clicked on "Add to Google Reader"

I haven't verified that this actually worked, so I may have to go back and wrestle with the XML, but I'm hoping I don't.

Sunday, October 25, 2009

Google Android ArrayAdapter vs SimpleCursorAdapter

I've been trying to create a "mover" interface in Android. I use the term "mover" to describe a interface displaying two lists where you can move items from one list to the other. This can be done with arrow buttons if you have enough screen real estate, but I don't think that will work on the small screen of a cell phone.

In any case, my first attempt contained two ListViews, one with an ArrayAdapter of Strings, the other with a SimpleCursorAdapter. For reasons which I haven't yet figured out, the items in one list were a different font size than in the other list. The SimpleCursorAdapter font size was smaller than the ArrayAdapter. I tried a number of changes in the layout file (e.g., changing weights and such), but none of them worked.

I ended up reworking my data storage so that I could use SimpleCursorAdapters for both ListViews, and the font sizes matched. I'm guessing that the Adapters (which I consider the "Controller" in the model-view-controller paradigm) are making some decisions "behind the scenes".

Onward to the next Android mystery...

Wednesday, October 21, 2009

The More Things Change...

I went to the StackOverflow DevDay in San Francisco on Monday. Lots of information, most of it useful. Mark Harrison's presentation where he "deconstructed" a Peter Norvig Python script gave me a few new pointers about Python. It also got me to thinking about list comprehensions, specifically the "why"? Performance? Possibilities for parallelization?

This morning's Google search was, therefore:

Python "List Comprehension" advantages

which turned up this:


He mentions performance (as well as parallelization):
Simple for loops implemented in python are handled by the interpreter, and are slow. List comprehensions and map() have a in-built, fast, internal C implementation which does away with the overhead of the for loop.
Good to know about, but mildly ironic in that it leads back to C code for performance. The 70's meet the 00's.

Monday, September 7, 2009

I miss my Java 1.5

I've been experimenting with the Blackberry development environment for the last couple of weeks.

On the plus side, it's great that:
  • It's a free download.
  • It integrates with Eclipse.
  • It provides emulators for various Blackberry models.
On the flip side:
  • I hit a problem using Subversion that I was never able to figure out (and no one posted any answers to my question on the Blackberry forum). I ended up doing a "dual-directory structure" kludge that allows me to continue development, but it's a klumsy kludge.
  • I miss some of the features from "contemporary" Java. The Blackberry system offers Java J2ME 1.2, which doesn't include features like String.split and reflection. I'm working around these issues, but I'm not sure what else I'll hit as I continue.
  • There are some anomalies with getting the sizes of controls such as edit fields and buttons. I'll figure it out eventually, but it's getting in the way of making my app portable to non-Storm Blackberry models.

Friday, August 28, 2009

"SQL for Smarties" Errata (part 1)

I need to learn more about SQL, and someone I respect recommended Joe Celko's book. I've been delving into it over the past few weeks. I'm learning a lot, but have hit a few typographical errors. Give the size of the book, it's not surprising. I would still (even given these errors) recommend this book for someone who has a good knowledge of SQL and wants to learn more. I would, however, caution them to run the SQL examples themselves to verify that the syntax is correct.

Here is the first set of errata. If any of these seem incorrect, don't hesitate to post a correction to my correction.

Code typos:

Page 73:
One of the "course_name" columns should be "course_code"
Page 461:
Condition "AND P2.salary_amt < P1.salary_amt" gives bottom n salaries, not top n.
Page 741:
I can't parse the example "color || = 'Purply Green')". I think it should be "color || '' = 'Purply Green')"
Page 746:
The two SELECT examples are inconsistent. One has a CAST operator and the other doesn't.

Non-code typos:

Page 33, bottom sentence:
"correction" -> "correct"

Monday, July 27, 2009

Technology for Education and Entertainment

I hadn't had an eye exam in a couple of years, and my doctor has recommended once a year. I made an appointment at the UC Berkeley Optometry Center and showed up at the appointed hour.

To show the eye charts, they now use a flat screen connected to a Windows computer instead of a projector. In the middle of the exam the screen saver kicked in and the screen went black! I just started laughing. The intern was relieved that I found it funny instead of vexing. I actually looked at her computer to see if I could fix it. The screen saver interval was locked down, however, so I left it up to her and their IT department.

They decided to take pictures of the insides of my eyes. It added a little to the fee, but (after I asked) they said they could email the pictures to me. To take the pictures, they had a device made by Canon with a digital camera back (that was then connected to a computer). They tried a couple of times, but couldn't get the picture to show up on the computer. They then called the tech guy. He just unplugged the camera from the computer, plugged it back in, turned off the camera and the device and turned them both back on. And it all worked.

I could have done that!

Monday, June 29, 2009

Is someone gaming Google "Web Clips"?

In GMail today, I noticed that the "web clip" at the top of the list of emails just said:

Dictionary.com Word of the Day - Presented By: - 18 hours ago

Unclear as to what that meant, I clicked on it, and found myself on what looked like a cleverly-disguised ad for one of these "work-at-home" marketing scams, complete with misspellings:

"We knew we had to do something, so we put our heads together and started trying online job opporuntities."

Can we trust Web Clips any more?


Tuesday, June 9, 2009

AOL to Google "conversion" project

I know a couple of folks who are still using AOL as their email (and contact and favorites) service. Some of them are receptive to moving to Google, so I've started working on helping them. A few weeks ago I actually put together a "business plan" for a service that would provide this functionality:

http://docs.google.com/Presentation?id=dgjndsm4_0c68v7vcn

In the meantime, however, Google came out with their conversion service:

http://gmailblog.blogspot.com/2009/05/import-your-mail-and-contacts-from.html

It's not complete, but it's free, and thus that business plan hits the dust. I am, however, going to continue my efforts to help folks that do want to move their data from AOL to Google:

http://www.chriskeith.me/ck/Home/overview

I probably won't be updating this blog with every change that goes here, but will occasionally mention significant milestones. Feel free to pass this on to anyone that uses AOL (if you actually know anyone who does...) but wants to move to Google.

Monday, May 25, 2009

Erratum (part 3) for D. S. Malik's "Data Structures Using C++"

On page 738 is an explication of Dijkstra's shortest path algorithm. Everything makes sense to me except step 2:
Set smallestWeight[vertex] = 0
This is because step 1 is:
Initialize array with smallestWeight[u] = weights[vertex, u]
Unless I misread something (or the weight from a node to itself isn't zero), I assume that step 1 subsumes step 2. Or am I missing something?

See also other errata.

Time to stop trusting Google Spreadsheets?

Somehow Google Spreadsheets lost the most recent version of one of my documents. I had edited it (and actually printed it out). When I went back, however, my changes were gone.

I cleared my Firefox cache and restarted my machine, but still didn't get the version that matched my printed version.

I had shared it with someone, so maybe there's a bug somewhere in their sharing code.

Autosave is a nice feature, EXCEPT when it doesn't work. At least I lost less than an hour of work.

I don't think it's a virus or other malware, because I run reasonably heavy security on both my machine and my router.

How about giving us a "Save" button, Google folks?

... a few minutes later..

It looks like a display problem. I can see some of the old documents in the revision history, but they (Firefox? Google?) won't display my changes.

Thursday, May 21, 2009

Google doesn't like my domain name?








Does Google automatically reject any domain names that contain the string "google"?

Tuesday, May 19, 2009

Visual Studio C++ Release vs. Debug

Timings for anagram program that was the final assignment in my data structures class:

Release:

Found 199741 words.
Built multimap in 532 milliseconds.
Created anagram file in 125 milliseconds.

Debug:

Found 199741 words.
Built multimap in 2796 milliseconds.
Created anagram file in 3891 milliseconds.

Thursday, May 14, 2009

Erratum (part 2) for D. S. Malik's "Data Structures Using C++"

I know this isn't real code (only pseudocode), but I still think it would be clearer to say this on page 540 (4th line from the bottom)

if (HT[hIndex].key == insertKey)

Unless, of course, I'm completely missing the intent of the example.

See also the first erratum.

Wednesday, May 13, 2009

Fricasse of Crow

In my last post I showed a 2-buffer merge sort that I thought was fast. In support of that claim I now offer this picture:

http://picasaweb.google.com/chris.keith/AcademicStuff#5335363116849662498

However, I did some more work with other sorts (and my professor changed his random number generator) and now I get this (be careful, the horizontal scale is different):

http://picasaweb.google.com/chris.keith/AcademicStuff#5335363118138126626

Note that both quicksorts beat my mergesort (thus I anticipate crow for dinner tonight).

Also note that the recursive quicksort is faster than the iterative one, which doesn't seem right. I just pulled that code off the web (and recoded it from C# to C++). Perhaps there's a better iterative one, but that's an investigation for the future.

Thursday, April 30, 2009

MergeSort with minimum allocations

The most recent assignment in my data structures class was writing a sort comparison, including a MergeSort. I realize that MergeSort can't be in-place, but I wondered if there was a way to keep the memory allocations to a minimum. I came up with this, which uses one extra buffer (the same size as the source array). After each pass, the source buffer becomes the target and vice versa. Timings indicate that (for arrays containing random numbers), this beats a quicksort. (Apologies for reformatting introduced by HTML...)
int *IterativeMergeSorter::Sort() {
int* src = mArray;
int* tgt = new int[mLength];
for (int swapSize = 1; swapSize < mLength; swapSize *= 2) {
for (int j = 0; j < mLength; j += (2 * swapSize)) {
int start = j;
int sizeOfSrc1 = min(swapSize, mLength - start);
int src2Index = start + swapSize;
int remainder = max(0, mLength - src2Index);
int sizeofSrc2 = min(swapSize, remainder);
Merge(&tgt[start], &src[start], sizeOfSrc1,
&src[src2Index], sizeofSrc2);
}
int* temp = src;
src = tgt;
tgt = temp;
}
if (src != mArray) {
memcpy(mArray, src, mLength * sizeof(int));
tgt = src;
}
delete[] tgt;
return mArray;
}

Monday, April 27, 2009

Erratum (part 1) for D. S. Malik's "Data Structures Using C++"

I am currently taking a Data Structures course at Chabot College. Let's just say I'm aspiring to be a Junior Programmer (only half-kidding...). The course uses the textbook (copyright 2003) mentioned in the title of this post. I realize that no textbook is perfect, but there is at least one error that will have repercussions on the grades of the students that use this text.

In table 5-7 on page 331, the text describing the pop_front method on the STL list container says
Removes the last element from the list.
Unless I'm missing something, this should read "Removes the first element from the list." See also this.

This will have repercussions on student's grades because there is a question in the on-line materials that was directly lifted from this sentence. When I took that quiz I kept getting this question wrong, and couldn't understand why. I then went back and re-read the chapter and saw this.

Caveat Emptor.

Monday, April 6, 2009

Going Paperless: Day 5

We get three newspapers at my house: the New York Times, the San Francisco Chronicle (as long as it remains in business) and the weekly freebie San Leandro Times. I go for the NYT first and my wife goes for the Chron. I will scan the headlines of the main and "Local" sections of the Chron, and (more often than not) read the comics in the lulls during preparing dinner.

The laptop just won't work for this.

First, it sleeps too frequently (probably because it's on battery). This can be changed.

Secondly, I don't like the idea of getting food on it (as opposed to the physical paper).

Thirdly, I read articles in the paper by first scanning them, taking in the first sentence of each paragraph. If I then want more information, Ithen go back and read the article in more detail. The laptop screen isn't big enough for this.

So I'm 1 out of 3:
  • Not really worth reading the news on the laptop
  • Not worth replacing pencil and paper for jotting notes
  • Definitely worth watching Hulu (and whatever comes after)

Going Paperless: Day 4

I have a habit of jotting notes to myself. These notes are usually list of items (sometimes related items, sometimes not) that are just reminders. Each item is usually only a few words, but just enough to put me on the path to the full idea.

The second part of this "paperless" test was to determine if I could use the laptop for that purpose. Most of the notes that I jot to myself end up in electronic form anyway (usually expanded with more context). Wouldn't it be good to avoid that intermediate step?

I don't think this is going to work. It's like the time you realize (when trying to write a networked application) that bandwidth is not enough, you also need low latency. Laptops (and TVs and cellphones) are getting slower to "boot up," not faster.

I don't consider this test a failure. Learning something always counts, so I don't consider the experiment a waste of time. Perhaps if I ever find a cellphone I like and can afford, that will replace pen-and-paper.

Friday, April 3, 2009

Going Paperless: Day 3

This morning I read the whole front page of the New York Times paper edition while my laptop was installing the latest Windows updates.

I also realized that the primary reason I don't like the NYT web site is that it is too hard to quickly scan the headlines, unlike the paper edition. Hello, Google News?

Thirdly, while making cheese & tortillas for breakfast (I'm a FIFO kinda guy when it comes to the refrigerator), I realized that getting cheese grease on the keyboard was probably not a good idea. (Also, I can't afford to spend thousands of dollars on a Toughbook.)

It looks like the laptop is losing as far as reading the paper is concerned, at least for the way that I like to absorb the news.

Thursday, April 2, 2009

Going Paperless: Day 2

Today I read some of the paper edition of the local freebie weekly while waiting for my laptop to reboot after a failed shutdown. After the laptop came back up, I went from the main NYT page to "Today's Paper" and read some articles from there. I also tried to get to the New York Times "Reader" (which looks like it shows images of the paper edition) but couldn't find a version that I didn't have to pay for. I already pay for the paper edition. I'll give the Reader another try tomorrow.

Last night I plugged the headphones in and watched some TV on Hulu. Enjoyable, but I wonder how Hulu is going to stay in business with only public service announcements for "advertising?"

Tuesday, March 31, 2009

Going Paperless: Day 1

As an experiment I've decided to try to reduce the amount of paper that I consume. As with all experiments, it may or may not work. But what does "work" mean here? I may, for example, be able to read the New York Times on-line. Will that experience allow me to read more, or to understand more of what I read?

It's not like I use a lot of paper, and my family is conscientious about recycling. I'm not, therefore, expecting to save a lot of paper.

Today I read a few articles using NYT on-line. I feel like I read less than I do from the paper, but I liked the fact that (with my ageing eyes) I didn't need an extra light source to read the articles. It also seems like the font size in the browser is slightly larger than the font size in the paper edition.

My issue today is that I like the NYT editors making choices for me. I find the web page has a lot on it, and I have to "think more" about what I really care about. With the paper edition, I sort it as follows:
  • main section
  • arts
  • business
  • sports (which I never read anyway)
Now I have to look at each individual article title to figure out if I want to read it or not. I feel that slows me down, and I read less of each actual article.

We'll see what happens tomorrow.

Thursday, March 12, 2009

Beward of tilde characters in file and directory names

I work on an application that occasionally goes across the network to look for files. I had written some code that used the GetFiles and GetDirectories calls from My.Computer.FileSystem. One of our test-beds was a remote computer (going across the public internet, rather than within a company intranet). The calls to GetFiles and GetDirectories using the SearchAllSubDirectories option were agonizingly slow on some networks, but not all.

I tried many different workarounds (including writing my own recursive GetDirectories on the theory that something was wrong in the Microsoft implementation). None of them worked until I took a deep breath and made a long list of things to try (many of them actually just data-gathering under different configurations).

Luckily, the first item on my list fixed the problem. I had been using a tilde character ('~') to help directories and files sort in a certain order. I remembered that the "shortened file name" workaround in Windows used a tilde to generate "intermediate" filenames for older applications that used fixed size buffers for 8.3 filenames.

I changed the tilde to an equal sign and the problem went away.

Friday, February 20, 2009

VBScript vs the Rest of the World

I tried using VBScript since I was tired of the lack of control structures, functions, etc, in the CMD language. I spent a few hours rewriting (or trying to rewrite) a couple of CMD scripts.

I ended up going back to CMD. My reasons (in no particular order) are:
  • VBScript is different enough from Visual Basic that it really qualifies as a different language. Very few of my VB habits worked for VBScript.
  • I hit a security issue when I was trying to copy files. I had written a CMD script, a Cygwin shell script and a Python script that all worked, but VBScript refused to do the copy. It wasn't worth the time to figure out which security setting to tweak.
Also, I don't really want to learn yet another language that locks me into Windows. So I get to live with CMD (whose behavior I do understand) until I can convince myself that my team can deal with Python.