Custom Derived Classes for wxPython XRC resources

First of all, this isn’t a topic that is bran new or which requires new documentation. I have learned a few quirks about the process for creating custom controls, panels, frames, and other elements with XRC files in wxPython and I thought I’d write up a little post.

Let me point you to the two most important resources. The wxPython wiki has pretty much all you need to now to get started. First is the TwoStageCreation process that the XRC implementation uses to create classes. The second is the UsingXmlResources page.
There is also the XRCTutorial. But you should be past that if you’re trying to create custom controls.

Here is a summary of the basic process. Continue reading

Posted in Programming | Tagged , , , , , , , | Comments Off on Custom Derived Classes for wxPython XRC resources

Is human powered search the next big thing?

I’d be well within reason to suggest that it would be somewhat difficult to use the web without a good search. Google has been so successful that their name has become a verb in the English language that defines using their service to search for something on the web. Traditionally, search engines compile a ginormous index of all the data their crawlers can collect on the web and then provide the fastest possible way for you to compare a search phrase with the content in their index. As good as the services have become, they haven’t been able to truly differentiate between relevant and irrelevant results for a large number of search phrases. You still have to sift through a few pages of results a lot of the time.

Lately, I’ve come across a few search engines that are attempting to take a different approach to the content relevancy problem. Instead of a proprietary algorithm that attempts for calculate relevancy, e.g., Google’s PageRank, they are letting relevancy be determined by human review. I decided to give RankNoodle.com a try and see if I could get better results with something powered by a bunch of other people than I can by simply typing in the search phrase in the search box of my browser and instantly getting a bunch of hits.

Here are a few review criteria I decided to test out:

  1. Does it work?

    First things first. Can I find information with their service? I decided to try and search for a few things I was in need of while I was writing this post. I didn’t want to just type in random search queries and browse the results. I wanted to try and find specific things that I need. For instance, I’ve been wanting a WordPress plugin that will tell me the word count of my blog posts. I searched for “wordpress word count plugin” and was pleasantly surprised to find a good option as the 2nd result. There are not 1000s of results like when you search on Google or Yahoo. I’m not exactly sure if users contribute the results or if RankNoodle uses crawlers and then just lets the users vote the results up or down. Either way though, the results page contained perfectly sufficient resources and I found what I wanted right away.

    RankNoodle.com still has work to do on basic functionality though. All the search results I obtained, for all my different search queries, advertise as having 41 comments. Nothing happens when I clicked on comment though so I’m not sure what is going on there. For a search engine however, I’m not terribly concerned about what other people say about the URLs. I’d rather just see what I want in the title and description listed with the URL and be able to make a quick decision from that about which URL to click on next. For the record, nothing happened when I clicked on “Share” or “Bury” either. I don’t know if that is a browser problem (FireFox 3.0 on Mac OS X), or just that they still have work to do on the interface.

  2. Is it fast enough?

    I think to for any search engine to be competitive, human powered or not, it has to be fast. There simply isn’t time to wait for results to fetch and display when other options can do the same thing in fractions of a second.

    I noticed that common search items are cached on RankNoodle.com so I thought I’d search for something that isn’t likely to have many users searching for it. I spent a lot of time this week working with wxPython and XRC resources (Yes, I’ll probably be needing to write a post about this too.) I wanted to know how to extend a wxPython Widget and have it automatically be loaded with the XRC handlers. I searched for “wxpython xrc custom class“. As I expected, the search did take a little extra time. As it stands now, it’s a little too slow to be competitive with other search options but I imagine if the concept is something that users will like and use, that performance can be tackled as the service grows.

  3. Usability

    I think overall, RankNoodle.com adheres to what a typical user would expect of any search engine. There is a search box on every page and results are not obscured by other page features. It would be nice if your current search terms were still listed in the search box on the results page though. It’s difficult to remember exactly what you typed and retype all but a portion when refining search results. I do like how image, video and related articles are listed on the side. In my opinion, that is a lot more worthy usage of the extra white space than filling it up with ads.

    That brings me to another subject. Search result pages are considered “articles” by RankNoodle.com. In addition to your search results, you get a general description and comments/questions by users for that article. I found it funny that the wxPython search I did when I first started testing had a question that was answered with “This is not a good place to ask this question.” Perhaps certain articles will get better results.

Anyway, overall, I think social or human powered searching has a lot of potential. For me to spend more time with it, it will have to be fast, integrated into my browser, and get me to the results I want. I can’t think of a better way to go up against current major search engine players though than by taking a completely different approach.

Posted in Web | Tagged , , | 4 Comments

How much overhead does C++ bring compared to straight C?

The other day, I had a conversation about putting C code onto an embedded chip. I wondered if it was possible to put C++ code on there. The gist of the conversation was that the C++ libraries had a lot of overhead and the executable size would be too large for the space available on the chip. I’m not an expert on exactly how much space is available on such devices (although I plan on becoming one), but I thought I’d play around with a few things and see just what overhead a c++ program would have when compared with it’s C counterparts.

I should note that there is already comparisons of the actual language constructs of C++ vs C for embedded devices. A simple google search yielded me a few answers. I’m more interested here in library overhead. For example, how does printf compare to cout, etc. All my experiments are done on my iMac with gcc/g++.

Continue reading

Posted in Programming | Tagged , , | 2 Comments

Comment Spam and WP-SpamFree

I’m tired of comment spam. I guess my blog has grown to a popular enough size that I’m known by just enough bots to make things annoying.

The next plugin I’ll be trying out is WP-SpamFree. If you can’t post a comment, use my contact form to let me know there is an issue.

WP-SpamFree uses a JavaScript and Cookie based approach to break the bots out there. Apparently, it’s pretty successful but I don’t have any experience with it yet. I’ll post an update to this post when I have more input. I’m hopefully optimistic that I’ll be deleting less comment spam from now on.

Update I haven’t had a single comment spam since I installed the plugin.

Posted in Miscellaneous | Tagged , , , | 1 Comment

3 Optimizations for speeding Visual C++ compiled code.

For fun, I participated in a programming contest. Instead of describing the process this time, I thought I’d include a function. Can you guess what it does? I’m changing some of the variable names so it isn’t obvious.

unsigned short result [dim][dim];
void foo(const string& info1, const string& info2, string& ret_val) {
 
 for (int x=0;x=0;--x) {
  
  use_high=x=0);
  sum += carry;
  carry = sum / 10;
  ret_val.insert( ret_val.begin(), (char)(sum % 10 + '0') );
 }
}

Anyhow, now that that fun is over, I was reading comments on a C++ forum and someone mentioned a few tips to optimizing C++ code with Visual C++. I thought I’d do a quick comparison between these and see how much of a difference it made since I was interested in program execution time and already had timing code built into my program.

  1. Release build

    I was already doing this, but I thought I’d include it for the sake of being complete.

    Debug build running time: 0.09 seconds
    Release Build running time: .02 seconds

    Obviously, this is a big one.

  2. Optimizations

    Optimizations are usually the biggest difference between release and debug builds. By default, my compiler was adding /O2 to build for maximum speed. I decided I’d enable every other optimization possible

    Release build optimizations settings

    Release build optimizations settings

    Anyway, the funny thing was, it ran faster by leaving the settings as they were. Obviously, you’ll need to test these and know what they do before simply enabling them. One thing that did seem to make a difference though, was to link against the Multi-threaded library instead of the Multi-threaded DLL. (/MT instead of /MD)

  3. Disable secure stl

    I found references to adding /D_SECURE_SCL=0 to the compiler command line. I assume if you heavily use iterators with STL, this might make more of a difference. For my little program, it didn’t seem to do much at all. I’m not completely sure it was even working. I’m assuming for now though, that it will do something, but that my program isn’t a good test case.

Posted in Programming | Tagged , , , , | 2 Comments

Picking a Good Laptop

Friends and family often ask me what laptop they ought to purchase. My answer is always the same: “It depends”. Then I proceed to break down the pluses and minuses of different types of laptops and try to determine where to start looking. After that, I find out more about exactly what they want, how much they want to spend, and we begin to find a number of machines that may suit their needs.

Part of the process of picking a laptop, for me anyway, always centers around reading reviews of different models. There are certainly a lot of reviews out there, but it helps to find lots of details about the laptops you are interested in along with the reviews. One source for reviews that I’ve come across is Computer Shopper. Particularly, they have a number of reviews for Dell Laptops that are very insightful into the benefits, cost comparisons, performance, and overall value of Dells laptop lineup.

Computer Shopper has a great lineup of products and they provided an individual review for each of the products I looked at. Not only do they give you the key specs for each machine, they also provide insight into who the machines are good for. They have a quick overview listing pros and cons of the machine, and then you can dig deeper into the review to find out how an individual machine stacks up against your other possibilities.

If you are looking for a machine over the long term, and not interested in buying something immediately, you can also check out their blog format reviews. When a new machine is announced, Computer Shopper gives you a quick overview of the machine, lets you know where it will be sold and for how much, and how this machine is different from what is currently on the market. It is really a handy feature and I’ve added Computer Shopper to my list of resources for the next time the question comes: “Which laptop should I buy?”!

Posted in Hardware | Tagged , , , | 3 Comments