iPhone: Background Lookup and Dictionaries

Posted: June 1st, 2009 | Filed under: iPhone | Tags: , , , , , | Comments

First of all, for those who don’t follow me on twitter (@spyromus), this year I’m working on my Cocoa / Cocoa Touch skills. Love it immensely so far and especially how things are nicely done in the iPhone department. A sheer pleasure.

During the last few weeks I tried several iPhone dictionaries and surprisingly all of them ( I mean ALL ) are coded in a strange way. The one of the most important parts — word entry — is implemented in a totally unimaginative straightforward way where it either looks up whatever you enter against their huge databases after every new letter or does that periodically. Both versions block the search box every now and then and don’t let you enter your searches quickly.

No finger pointing here certainly, but you guys know who you are. I tried to contact authors and share this bit of knowledge, but it’s either http://localhost/ as the support link or no link at all, so… the least I can do is to share it here. Hope it’ll be of some help.

Here’s the part of a XYZViewController:

- (void)viewDidLoad {
  operationQueue = [NSOperationQueue new];
  [super viewDidLoad];
}

- (void)searchBar:(UISearchBar *)searchBar
    textDidChange:(NSString *)searchText {
  [operationQueue cancelAllOperations];

  SearchOperation *op = [[SearchOperation alloc]
    initWithText:searchText dictionary:dictionary controller:self];

  [operationQueue addOperation:op];
  [op release];
}

Where SearchOperation is a subclass of NSOperation and its main method looks something like this:

- (void) main {
  [NSThread sleepForTimeInterval: 0.25f];
   
  if (![self isCancelled]) {
    // Do your searching magic here ...
    [controller performSelectorOnMainThread:@selector(searchResult:)
      withObject:...
      waitUntilDone:NO];
  }
}

The idea is that when the user types a letter, the searchBar:textDidChange: is called, but it doesn’t do the search right away. Instead it creates an instance of the SearchOperation which represents a lengthy dictionary lookup and queues it. Each SearchOperation sleeps 1/4 seconds before it starts doing any work. In fact, before the actual start it checks if it was canceled and does that periodically during the search.

So when it can be canceled? That’s why we have the cancelAllOperations call in the queuing code. If the user types, every next letter results in the cancellation of previous search operations and none of them will complete or even start. Moreover, the user interface will never be blocked and your users can type away freely and only if they stop, the GUI will follow and show the results.

You see? Simple.


Knees… fixed

Posted: May 16th, 2009 | Filed under: Personal | Tags: , , | Comments

I’ve been playing streetball for more than 17 years now and, no question, hard surfaces started to take a toll on my knees. They began to creak last year during the city championship and, shortly afterwards, falling out of sockets. The pain is terrible. All this beauty rendered me basketball-useless for quite some time. Doctors suggested to calm down a bit and leave active sport; and I couldn’t believe all is that bad.

Early this week a physician I know suggested a simple set of exercises to strengthen knees. A really simple one that takes only 25 minutes. So I did two of these with a little break each evening when watching NBA Playoffs, and you know what? Pain goes away. I still can’t believe I suffered so long and all I really needed is to strengthen my knees a bit.

I know there will be a long recovery period during which the remaining pain echos will fade away and I’ll get back on courts at full speed, but hey… it’s a start, and instead of a wheelchair I’m now shooting jumpers for an hour almost everyday in my recreational training.

The set is really simple:

  • Sit on the floor, back to the wall — make a letter “L”
  • Put a rolled towel under your knees to keep them bent a bit
  • Now slowly strain your knee muscles (but keep your knees motionless) and keep it that way for at least 30 seconds
  • Relax muscles and rest for a few seconds
  • Repeat the set of straining and rest 25 times

I chose the 45-15 scheme for myself that is easy to count and takes exactly 25 minutes (~1.5 quarters of a game; so I can do 2 sets during one game).

Many thanks to Dmitry Skuridin (Sevastopol, Ukraine) for getting me back on courts!


NR Time 1.2

Posted: January 20th, 2009 | Filed under: NR Time | Tags: , | Comments

Just released an update to NR Time with some really cool enhancements.

New in version 1.2:

  • Preference to switch the time display format (’2:06′ or ‘2.1′). It allows you to see your times either in billing- or human-friendly format.
  • Preference to show all / active tasks total in the status bar. Lets you control whether in the status bar you see the total time spent on all tasks or only those that are active at the moment.
  • Automatic updates. Checks for updates periodically and shows the message when a new version is available. It can be configured with different periods or disabled to let you check for update manually.
  • Manual entry of time as ‘H:MM’ in addition to ‘H.hh’. To complement the human-readable time view, this feature lets you enter time in the common format.

NR Time


Selling FREE eBook on Merb

Posted: January 15th, 2009 | Filed under: Sites | Tags: , , | Comments

Can anyone correct me on this, but so far it looks like the eBook is apparently not free (taken from here):

What do you need to do?

Simple.

  • All you need to do is vote for RubyLearning at the Shorty Awards. The full details are available here.
  • Write me an email at mail [at] satishtalim [dot] com mentioning your Twitter id and I shall email you the Merb eBook.
  • This offer is also valid for those who have already voted for RubyLearning.

You just need to give your vote for the site to get that book. What is it called… when you buy votes… let me think… bribery? You don’t need to do it so openly, someone could see it. Oh, I guess I just did.

Look people, the whole point of voting is to show your sincere attitude towards the subject. If everyone just rolls the numbers, it’s no longer useful.

I like the resource, but couldn’t walk by this silently. You’ve just lost one reader, Satish.


NR Time 1.1

Posted: January 14th, 2009 | Filed under: NR Time | Tags: , | Comments

NR Time was updated to version 1.1 and you can grab your fresh copy from the site.

It’s a small followup release:

  • Added ⎋ keyboard shortcut to quickly hide the window
  • Added “Buy” button to the license dialog
  • Fixed a tiny memory leak

NR Time


NR Time for Mac OS X 10.5

Posted: January 12th, 2009 | Filed under: NR Time | Tags: , , , , , | Comments

It’s an awesome day, really. I just released my first product for Mac OS X 10.5 Leopard — NR Time — and it’s available for trial downloads and license purchases of course.

NR Time

NR Time is a tool that makes your time logging completely transparent. Period.

As a freelancer, I always needed a tool that could tell me precisely how much time did I spend working for one client or on one task and what was it for another. If nothing else, the earnings depend on this and having no convenient tool meant that I was stuck with the paper notepad where I recorded the beginning and ending times for every task.

If you ever did that, you can imagine what kind of headache coffee breaks are. You need to record the time when you go out, and then remember to jot the time of return. Finally, the calculation time comes when at the end of the day you juggle with numbers to figure what it was that you spent working today. It gives me creeps every time I think how I lived all these years.

So what does NR Time do for you, briefly:

  • Let’s you enter as many tasks as you like
  • Let’s you start and stop any number of them at the same time
  • Updates the time for each task in real time and shows it in tenths of hour (1.1 stands for 1 hour 6 minutes and is easier to operate with hourly rate)
  • Updates the total for all tasks and displays it in the status area in hours (1:06)
  • Let’s you pause all running tasks by clicking on the notification area icon and resume with the same gesture
  • Gives you an intuitive keyboard controls over the tasks
    • ⌅ – to enter / exit the task name edit more
    • 0-9, “.” – to start entering the time spent manually
    • SPACE – to toggle activity flag
    • ⌘ + N / ⌫ – to add / remove selected tasks

The trial version is fully functional for 15 days. If you find it useful, consider purchasing a license for only $10 (details on the product home page).

NR Time

Give it a spin! It’s a very simple application solving a very simple task, but it saved me lots of silver hair. Hopefully, you will find it useful.


Typography numerology

Posted: January 10th, 2009 | Filed under: Music, Graphics, Video, Sites | Tags: , | Comments

Recently I was working on the design of the page for my new product — Time Tracker for Mac — which is to be deployed soon, by the way. I’m by no means a professional web designer, but like to fiddle with colors, layout and font faces. At least no one can fire me when I do it to my own sites.

Scanning through my web-design blogs for an inspiration, I stumbled upon a couple of interesting places. Both are dedicated to typography, but where the typography is good, everything else thrives. So get your notebooks and start taking notes.

80-typefaces

80 Beautiful Typefaces For Professional Design

It seems I spent my entire life wandering around that page. The amount of information is simply overwhelming. If you ever make it to the comments section, leave a quick note there. The author will be pleased to know. Yes, I’m sure. Scanning through the comments, I noticed that many disagree with the selection and claim not enough scripts, sans, whatever. People, if this list to contain every font family everyone found useful during their important designer carrier that would bump the counter to 1,363,203 beautiful fonts and you probably won’t expect it to be for professional design either. So calm down and let it go.

20-websites

20 Websites with Beautiful Typography

A great collection of great looking sites with short comments. Lots of inspiration, so you may want to use your tea spoon here not to grab too much at a time. I found it immensely useful… and the site too.

P.S. Hey Pito, did you like that Puppia business card layout (20 websites with beautiful typography #17)? We did… very much. :)


Blog theme change

Posted: January 9th, 2009 | Filed under: Personal | Tags: , | Comments

For all of you who read my blog in their feed readers, the web theme has changed to something less standard, to something lighter and breathing. I have simply fallen in love with this theme at first sight. It’s clean, it has lots of space, elements are all bold and meaningful, it’s based on my favorite grid (3 column 950px, the main part takes 2 columns). Oh yeah, and I tend to like white color…


Low-fat twitter, blogs and no-list

Posted: January 5th, 2009 | Filed under: Personal | Comments

Habitually, in a new year I expect big changes. People like changes, don’t they?

Today I started my own changes with removing 90% of people I follow on Twitter. I noticed that it has really no value to me to read “went off the grid” or “what a nice couple of toasts I had this morning”, but wastes precious time. Yes, I speculated on this before, so not really going to expand on this.

Removed the blogs I don’t read or don’t pay too much attention to, especially high-traffic ones. This one is quite obvious — why spend time reading something you don’t appreciate.

Made a list of things I don’t need: iPhone, iPod Touch, hardware synthesizers, new vinyl records, new books and movies, new tv series, a car (don’t have one and don’t need one), coffee. These are things over which I had an internal discussion every now and then. Now I don’t and it’s a good thing as it removed just another thing to worry.

This is just a tip of the iceberg of changes I’m planning…


Great Gatsby by Francis Scott Fitzgerald

Posted: January 2nd, 2009 | Filed under: Books, Language, Tips | Tags: , , , , , | Comments

Check at Amazon

Just finished the Great Gatsby by Francis Scott Fitzgerald. Great story, clean and eloquent style, lots of infrequently used words. A must for every language learner and simply an educated man.

You’ve got my recommendation on this.