Nuance Dragon NaturallySpeaking 10
So it’s pretty sad: I just got voice-recognition software but I’m trying to come up with things to say. I guess the first thing I can do is do a review of Dragon NaturallySpeaking 10. So far so good though there have been a few snags. Remembering punctuation is one of the hard things to get down. There are couple of gotchas if you use it on a computer with Comodo Firewall that you should be aware of. The NaturallySpeaking executables tried to interact with every other executable on the system and one really annoying problem was that when the executable tried to access the keyboard somehow locked out all the other keyboards attached the system. I finally figured out that I could control alt delete and things would come back. It may make sense to just bite the bullet and set the Dragon NaturallySpeaking executables as trusted.
Getting set up I spent about an hour reading dictation to improve my recognition statistics. I have to admit it was kind of fun reading Kennedy’s address as one of the options. It really brings home the fact that you don’t do a lot of reading and speaking at the same time in your general life, or at least mine, especially text that you’re not necessarily familiar with. But practice makes perfect and after a while you sort of get into a groove. I’m still not the point where trusted to really capture all of my thoughts as I speak them without any kind of delay, but I’m getting there. I do tend to mumble a little bit in my normal conversation so I have to be a little extra careful with my diction.
I could really see this becoming useful if I am able to incorporate it more into my daily life, particularly with my coding. There are a number of tools out there to help coders use voice-recognition, but I will have to see if they have anything for Ruby and/or ActionScript that is worth the effort to get set up, or possibly integration with TextMate. By TextMate I mean of course the E text editor on Windows, a sanctioned clone of TextMate, with all the bundles etc.
That’s it for now; I’ll keep you posted. In the grand tradition of all voice-recognition reviews, this review was done using voice-recognition.
Trick For Selecting Even or Odd pages in Finereader
For a long time I thought selecting all even numbered pages wasn’t easily doable in Finereader (whereas Omnipage Pro had a special option to do so). Sometimes this is necessary when working with Save & Load Blocks, when the even pages have a different layout than the odds. So recently when faced with this again, I realized I could do this in FineReader, and while a little less intuitive, it is actually more flexible then the standard way in Omnipage (though this technic could very well be usable there as well).
Here is the gist of it: Under View, select Batch Window->Batch Window Maximized. Then resize your application window so it only shows 2 pages, as in the window below. You can now use your mouse to drag select all of the even/odds, or only some of them if needed. Note, this only works if you don’t have any gaps in your page numbers.

My Problems with Vista
I recently had to downgrade from x64 to x86 on Vista, to deal with a number of problems, like my scanner not working, Eclipse issues, and just general pain in the ass stuff that always made it just a little more difficult than it needed to be. So I’m giving up 800MB of RAM for my scanner, which I have to hack the drivers for anyway since shamefully HP doesn’t provide drivers for older hardware. Scanner tech simply does not change that much from year to year, and building drivers shouldn’t be that hard if they are competent at all. Spending another 400$ when the Automatic Document Feed scanner I have still works fine is a retarded ‘solution’. Anyway, I am still being annoyed by Vista x86.
So this is my own version of ‘Vista Annoyances’ only without the solutions generally:
- Vista tries to reconnect network drives before the network is connected, which is retarded. It dutifully points out that it can’t reconnect all network drives. And rather than simply connect when it does find the network, I am forced to open up Windows Explorer and click on the disconnected drive to have it reconnect.
- Sleep simply doesn’t work. Oh, it puts my system to sleep alright. Just nothing I do will turn it back on once it is in sleep mode. This probably corrupted my Search Index when I had to hard reboot my system, so I was getting ‘Search Indexer’ had to close error messages every minute or so. Lovely.
- Windows’ continued inability to deal with network folders in Windows Explorer. How many billions of times do their users have to sit there wondering why there folder tree won’t expand while a green bar goes across the top of the screen. Reboot seems to be the only option here… See reconnect bitching.
- UAC: User Access Control. Does it really need to pop up two dialog boxes? One to ask me if I want to acces, the other to actually access? Is there really no way to combine those into a single dialog? Seriously? I know the general mantra is to just disable UAC, but I run pretty fast and loose on my system, with minimal reliance on AntiVirus software, and maximal reliance on questionable software, so I figure a little insurance may be worth the pain. But damn…
- Years and years later, and the Taskbar still cannot do what I tell it to. It won’t remember that I like 2 rows of programs. It won’t rememebr that I use Autohide. It won’t show the Taskbar half the times when I move my mouse to the bottom, I have to prress the Windows button to get it to show. Why in god’s name must the Quick Launch toolbar resize handles make me guess if my icons are going to all be visible when I lock the task bar, or if a few will be in a side menu.
- Dear god enough with the Windows System Tray Notification Area (say that 5 times fast) popup notices! Nothing more annoying than when those things popup and simply don’t go away. Or take FOREVER.
- Just because I like a lot of ‘recent programs’ to show up in my Start menu, why does the stuff on the right side of the start menu also have to move all the way to the top? Wouldn’t it be better to stay closer to the Start button if possible?
More soon…
Are you CALM enough?
Seems like a weird question right? I was taking the subway home and one side of the car was filled with ads saying:
- Are you CALM enough?
- Are you STRONG enough?
- Are you COOL enough?
- Are you CLEAR enough?
What were these adds for? NYS Child Protective Services looking for people to apply. I wanted to add a couple:
- Are you ROBOTIC enough?
- Are you EMOTIONALLY CRIPPLED enough?
because it sounds like they are looking for people with cast-iron stomachs who don’t feel anything. They probably are, that’s what’s sad. Every face on the ads was stoic, mask-like. Made me want to curl up into a ball, not apply for a job.
Bad Bath & Beyond Oddyssey
So I made a trek to BB&B yesterday, on 6th Ave and 18th St. (NYC). I hadn’t been in several years, so my list of things I needed had gotten pretty long. Plus, it is impossible to go in there and not walk out with twice as much as you expected. (As I was standing in line to have my purchases scheduled for delivery, the woman in front of me was saying the same thing to the delivery coordinator, who I’m sure hears that at least once a day.) My goal was to spend less than $1000, and I pulled through with only $850.
I got a humidifier, which I’ve been needing as it just gets dry with my boiler heat in the winter, even though winter is officially over. Nothing worse than itchy skin. I probably could have gotten it on sale in a week or two, oh well.
But the coolest little things I’ve found so far, are these little metal cans with magnetic bottoms, and clear tops that I put my vitamins and a couple of spices in and then stuck to the fridge door, clearing off the Boos prep table of those 4 jars/bottles. Only $2 a pop. And then I got a combined pepper mill/salt shaken, to knock down the number of things on my prep table to just the one.
Also got a coffee maker, as decaf coffee has replaced cigarettes as my vice of choice since I quit smoking. I know, I know, ‘DECAF??!?!?’ I’m sensitive to caffeine in general, so decaf, which still has like 1/6th of the caffeine of regular coffee, gives me a little buzz. Plus I drink a lot. And with my sleep patterns so messed up, half the time I wake up at 2am and have to wait for hours until my local cafe opens, or I wake up at 6pm right after they closed. And the nearest decent coffee is about half a mile away. Not that I don’t need the exercise…
Rails Active Record Lameness
I know this is sacrilegious, but there is some serious lameness going on in ActiveRecord I’ve dealt with lately. Maybe I’m drawing outside of the Rails lines (going off the tracks?), but ActiveRecord seems to go out of its way to make things a pain in the ass.
AR::Base#sanitize_sql being a ‘protected’ method has always been a burr in people’s sides. This means you can’t call it yourself on your own piece of SQL. Presumably it is done this way so people HAVE to do it the Rails way, whether that means duplicating a bunch of code, or taking a lot more time for a one-off project, etc.
Currently I’m working a report generator for Flex, where the Flex app handles the SQL generation and passes back an XML version of the sql options like:
<query>
<name>
</name>
<sql>
<select>
<![CDATA[Date(created_at) as date]]>
</select>
<select>
<![CDATA[count(id) as total]]>
</select>
<from>
</from>
<conditions>
</conditions>
<group>
<![CDATA[date]]>
</group>
<having>
<![CDATA[date >= :start_date and date <= :end_date]]>
</having>
</sql>
</query> Now we can argue all day about the best way to do this, but the reality is that only Admin authenticated people are going to see these reports, so the fact that someone could send arbitrary sql against the database is outweighed by the Flex-ibility of being able to dynamically adjust the query values in Flex without having to create a custom server-side method for each report. It is easier in my case to let more readily available/cheaper Flex programmers handle this than more expensive Ruby coders.
Getting this accomplished in Rails led to 5 workarounds in the code:
def replace_named_bind_variables_no_quotes(statement, bind_vars) #:nodoc:
statement.gsub!(/:(\w+)/) do
match = $1.to_sym
if bind_vars.include?(match)
bind_vars[match]
else
raise ActiveRecord::PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
end
end
end
def query
# from_xml puts it in something like { queries => {query => [{name, sql}, {name,sql}....] }}
queries = Hash.from_xml(params[:queries])['queries']['query']
# logger.dbg queries.inspect
# generate the report structure
report = []
queries.each { |data|
query = data['sql']
logger.dbg query.inspect
# Now we need to get around a bunch of ActiveRecord lameness....
# Presumably it is done this way to satisy someone's idea of 'how you should do things'
# rather than, 'let's help them do it, no matter how they want to get it done'
# first, AR doesn't do bind variables for anything but conditions...
replace_named_bind_variables_no_quotes(query['group'], params) if query['group']
replace_named_bind_variables_no_quotes(query['having'], params) if(query['having'])
# second, we need to join the select clauses, as :select doesn't accept an array...
query['select'] = query['select'].join(', ')
# third, AR doesn't support a separate HAVING clause, you have to attach it to GROUP BY
if query['having'] and query['group'] # you always have both...
query['group'] = query['group'] + " HAVING " + query['having']
query.delete('having')
end
# fourth, we need to intern the keys so that they pass 'inspection' by AR
interned_query = {}
query.each { |key, value|
interned_query[key.intern] = value if(value != nil) # AR doesnt like :conditions => nil either...
}
logger.dbg interned_query.inspect
# fifth, we need to use Creative instead of just ActiveRecord::Base because there is a bug/weirdness in reset_table_name
# where it can't find the abstract_class
report << [data['name'], Creative.find(:all, interned_query)]
}
# output the results xml
str = ''
xml = Builder::XmlMarkup.new(:target => str, :indent => 1)
xml.result {
report.each { |query|
xml.query {
keys = []
xml.name query[0]
xml.cols {
exemplar = query[1].first
exemplar.attributes.each { |key, value|
xml.col key
keys << key
}
}
xml.rows {
query[1].each { |row|
xml.r {
keys.each { |key|
xml.v row.attributes_before_type_cast[key]
}
}
}
}
}
}
}
render :xml => str
end
Rolling back to NETCF v1.0 from 2.0+
So on a little side project I am working on, I realized that I needed to roll back to .NET Compact Framework (NETCF) v1.0 from a newer version. Why, you might ask? Well, it seems that even on my fairly recent Windows Mobile 5 XV6700 HTC Apache/Mogul whatever (only 2 years old, hey now), that not even NETCF v2 is available. Now you can always just install NETCF 2 or 3.5, but those take up 5+ MB of precious space on your device. Even worse, when you start even the simplest app, your RAM usage can balloon to 3-4 MB with just a few simple controls.
Using the built-in NETCF (v1.0-ish) can help reduce those issues dramatically.
I was never able to figure out how to create a new NETCF v1.0 project in Visual Studio 2005, so I went back and installed VS 2003. Created the project, then opened it in VS2005 and added all of my old files. I need to use VS2005 because I am using Vista x64 and the device emulator in VS2003 doesn’t work in that environment it seems (drivers wouldn’t load). It is also my understanding that you can’t move forward to VS2008 either, that you are forced to upgrade the framework version.
So once I got my files included, I tried to compile. Ooops! Quite a few problems I had to fix popped up.
- The shorthand for property get/set (get; set;) didn’t work. I had to go back and redo all of my properties that used this. There is still a ‘prop<tab><tab>’ helper though.
- My resources were all messed up. I had to basically rebuild my forms from scratch, then copy in all of the stuff from the newer NETCF versions. I took the opportunity to simply move a lot of my resources into a skin folder and just load them at runtime with FileStream and Bitmap.
- I had a splash page that was just another form, and used TopMost to make sure it was on top. This isn’t available in NETCF v1, and it really isn’t clear to me at all how control paint ordering occurs by default. BringToFront/SendToBack didn’t really do much for me, and the order of creation of the controls didn’t help either. There is supposed to be a way to do this with SetWindowPos.
- List<string>-style templates aren’t available, or anything from System.Collections.Generic. You need to use ArrayList or similar instead, and some occasional casting from object.
- The MenuItem.Tag(and Tag from other controls) is missing, which is where you store your user data for menu controls. For instance you might create a list view of files, and each file would have a Tag object containing its FileInfo object. You have to come up with another solution here, like keeping track of the order/array of MenuItems, unless I figure something else out.
- Enum.Parse isn’t available.
It seems a lot of these problems can be solved by using the OpenNETCF Smartphone Device Framework v1.4. For instance EnumEx.Parse is available in that framework addition.
Static Events for Decoupling Communication Between Classes/Forms/Controls in C#
So I’m new to C#, but I have to admit that the ‘simple’ examples out there really aren’t simple and they really don’t cover what I would consider to be the most common use for events: Communication between forms and controls without having to resort to directly linking one class to another. I’ve been using Cairngorn Events/Delegates for awhile now in Flex/ActionScript3, so I’m not coming at it from a complete novice standpoint. But it seems every example I could find only showed how to raise and use events within the creator of the event. None of them showed how to use events to decouple, or reduce the linkage and increase the usability of your code.
So here goes: Imagine if you will, that you have several forms on your application and you want to allow the user to exit from any of them, while still doing that last minute clean up like saving any data or config, etc. ( I realize there is a way to do this using the Application event handler, but this technique applies all over the place, and this example is easy to understand.)
So first you want to create your event class. I put mine in a handy folder called Events in my C# project.
using System;
namespace Demo.Events
{
// Declare a delegate for an event.
public delegate void ExitAppHandler(object sender);
// Declare an event class.
class AppExitEvent
{
public static event ExitAppHandler evtExitApp;
// This is called to fire the event.
public static void OnExitEvent()
{
// ok so this calls the handlers we have +='d to listen the event
if (evtExitApp != null)
evtExitApp(null);
}
}
}OK, so this sets up a separate event class that has a static handler variable and a static method. This is the glue between our classes. Now we can reuse a form that calls this event, without having to worry about any other code.
Now we want to listen to this in our forms that want to do something when this event is triggered.
namespace Demo {
public partial class Demo : Form
{
public Demo()
{
Events.AppExitEvent.evtExitApp += new Events.ExitAppHandler(this.ExitEventHandler);
InitializeComponent();
}
// An event handler.
private void ExitEventHandler(object sender)
{
// TODO: Do cleanup/save/etc
this.Close();
}
}
}This could be your main application form for instance, with a lot of other stuff going on in this class, like adding controls, etc. Multiple forms that need to respond to the exit event would simply do the same thing: Add Events.AppExitEvent.evtExitApp += new Events.ExitAppHandler(this.ExitEventHandler); to their class/form, along with an ExitEventHandler method.
Now all we need to do is show another form/control/class calling this as well. In my case, this is a custom toolbar, or a sub form’s right click menu:
namespace Demo
{
public partial class Caller : UserControl
{
public Caller()
{
// If you wanted to have this form respond to the exit event as well, you could simply uncomment this
// Events.AppExitEvent.evtExitApp += new Events.ExitAppHandler(this.ExitEventHandler);
InitializeComponent();
}
// this is in response to a button click NOT SHOWN
private void pbExit_Click(object sender, EventArgs e)
{
Events.AppExitEvent.OnExitEvent();
}
}
}
And finally, we show how to call this static event:
Events.AppExitEvent.OnExitEvent();
This is called in response to a button click, that button not shown in this example, but you should hopefully get the idea. I’ve also shown commented out, that this other form could also be a consumer of the same exit event if you wanted.
That does it! I needed another similar event to occur when I minimized the app, and when I wanted to open a popup form from a number of different locations, so this technique is very useful.
Obviously, the above example doesn’t really show how to pass additional info with the event, like mouse coordinates or other data.
To do that you would need to create a class derived from EventArgs (CustomEventArgs let’s say) that held your custom data, and change the declarations to add in your custom event args. The existing examples out there show this aspect pretty well.
Why the iPhone is Destroying Windows Mobile in the Market
Ok, so this post is a little premature, but it just has to be said. The reason the Windows Mobile (WM) is dying on the vine lies firmly on the shoulders of the .Net Compact Framework( the C# library used for many application ) and the main WIN32 CE API in general. Now this is a little unfair of a characterization, because Apple has yet to release its SDK for the iPhone, but it is obvious that it is running a real OS. So many things have been stripped out of the Windows Mobile OS, that it is an effort in frustration to do even the simplest things. The documentation is a nightmare as well, with everything from the full .Net Framework listed with the Compact stuff, and there are no/few examples. To be fair also, as with all Microsoft products, backwards compatibility is always one of the main skeletons in the closet. WM has been around for 10 years now, and that legacy, along with the WIN32 legacy in general, has really held it back. But there is also this sense that they said: “This is what we think you should do, so we won’t give you any other way.”
Here is a hit list of issues that I’ve come across:
- There is no Rich Edit control, only a RichInk control. And for some retarded reason they decided not to support full justification in the RichInk control, so almost no WM apps do either, from PocketWord on. This means if you want justified text (like for an eBook reader), you have to roll your own. It would have taken maybe another 100-200 bytes to support it.
- Little transparency support. Any decent design takes advantage of transparency these days, and I am spending an hour googling trying to figure out why my toolbar buttons look like shit.
- No animation support. Think Flash here (move button A to X,Y over 1 second and add a drop shadow) . I imagine that Vista Aero has some better animation now, but WM has none.
- Just plain missing API calls, like OemToChar, and some other Unicode/Wide character support. I’m trying to compile an unrar DLL for WM and it just isn’t pretty, even though unrar doesn’t use much craziness.
- The WebBrowser control is completely crippled.
- And because it is all closed source you can’t see a damned thing about how it is done. This would solve almost any problem out, there, making the Compact Framework source viewable so you could make your own versions without having to start from scratch. [Updated: I have since discovered that you can look at a lot of the underlying NETCF (and .NET Framework in general) source code using .NET Decompilers like Reflector.
I have a C/Win32 API app I need to modify, and I would like to port it to C# but it is turning into a nightmare. And of course I would even consider getting an iPhone once the SDK comes out if they had a Verizon version, but I get no GSM reception in my apartment in NYC. I’ll keep you posted.
UPDATED: So I’ve gone ahead and just started from scratch with my project (an eBook reader), in C# NETCF v1.0. I’ve got pagination down within 30 seconds for a 300 page paperback on a mobile device, and it now does full expand/squeeze justification of the text.
Put Your Monitor To Sleep at the Press of a Button (Windows)
Here is a little AutoIt script I found while trolling their forums that will put your monitor into sleep mode at the push of a button. Both the script and a compiled EXE version are included, so you don’t have to install AutoIt to use. I put a shortcut to the script into my QuickLaunch bar, then changed the icon to the power button icon, and now whenever I am done with my computer for the time being I can press this button and my monitor goes off right away! There are plenty of other shareware, etc. tools out there to do this, but this one is so simple, it’s basically a single line of code. I grabbed this off of the AutoIt forums, and commented out some of the existing code. That code originally would turn off the monitor after 10 seconds of non-use (which is usually useful in a Network Operations Center but not much else).