Wednesday, July 25, 2012

Sharing a keyboard and Mouse between a Mac and PC

My main development box is a beefy dual screen PC. I do a lot of Mac work too. I test all our WebStart Java based code on the Mac to make sure controls are sized correctly, accelerator keys work as intended etc. That is all done with IntelliJ. I also write all the mobile code for iOS devices via Xcode and Android devices via Eclipse meaning I switch around a lot.

I tried VNC for a few days but ran into too many short comings. I have the Mac hooked up to my second LCD and switching video inputs is easy enough but hauling over the mouse and keyboard was annoying.

Yesterday over lunch I picked up a KVM at Microcenter. Box listed it at $29.99 but it rang up at $12.99 at the register. This is the TrendNet 2-port KVM Switch Kit TK-207K. Simple piece of hardware about the size of a deck of cards, just a little thicker and wider. I plugged in my USB generic mouse and MS Natural Keyboard 4000 to the device and plugged in the included outbound VGA (not using) / USB cables to the PC and the Mac. There is a 1 and 2 button on top of the box you press to toggle between machines. If I am on the PC I can hit Scroll Lock twice to go to the Mac but it does not appear to work from Mac back to PC, instead it dims the screen. Press the button is no big deal.

Both machines seem to be happy doing the switch. I can now run everything off the one mouse and keyboard which is making life much simpler. The other big advantage - the MacBook Pro only has two USB ports. I had the mouse in one and the keyboard in the other. I only need one for the KVM switch. This allows me to plug in a USB key, the iPad or whatever without pulling the keyboard.

Here are the minor issues:

1) On the Mac the main screen in the laptop screen. Everything wants to start on that screen even if a program is on the second screen it wants to show pop-ups / associated windows on the primary screen.

2) Just put Lion on the Mac so I could upgrade to latest Xcode. By default Lion does scrolling opposite of what Snow Leopard did. This makes it act like a iOS device which is fine when using touch pad but annoying when using mouse especially when you switch between it and Windows during the day. I turned off that setting.

3) Can't double scroll lock to switch back to PC side.

4) Wish I could run both my external LCD screens of the Mac even if it meant shutting down the laptop display. If that worked I could switch to just using the Mac for email, IM, IntelliJ for Java, Eclipse for Android and Xcode for iOS. The laptop display is OK but not positioned on my desk in a good spot right now. Once you get used to two 24" displays you don't want to go back to a 15" display.

Switched text editors


I had been using PSPad on the PC for the longest time. I then switched to NotePad++ and then after reading a number of glowing reviews of Sublime Text 2 I switched to that. Seems to work out nicely on both the PC and Mac. I had been struggling to find a good text editor on the Mac and was using JEdit. Using the same editor on both machines is very handy.

I tend to leave a text editor open on my machine at all times with multiple tabs going. Right now I have 5 tabs running - Work info, Android Notes, Charge Capture Mobile, Front Office, Tablet Calendar - one for each project I am in the middle of working on. During the day if someone stops by with a suggestion I type it right into the appropriate file. Maybe I come up with some wild idea - type it in. It is my way of keeping massive to do list, future notes, things to investigate and random thoughts all where I can find them easily.

The Mac will take over my Tablet Calendar notes as that is where I will be doing that work for the time being until I start the Android conversion. I also end up opening source code from other projects to steal code snippets so having a bonus text editor open is very handy. Its other big job is grep. Any text editor must have "find in files" to be useful to me.

Tuesday, July 24, 2012

Today's Apple Fun!

I need to test a new app on the iPad. iPad is 5.1x but I was on Snow Leopard and using Xcode 4.2. Can't run the iOS 5.1x SDK on this platform. I got Lion ready to go finally. Had to buy a new larger USB key so I picked up a $9 16GB at Microcenter over lunch.

Run disk tools to create Lion installer on USB key
Lion install went smoothly.
Run Xcode, tells me it is too old. Drag it to trash and it crashes.
Install updates to Lion amounting to 1.84g of download and install.
Still wants to install iTunes update but it fails on two attempts - give up on that.
Try to install free application from App Store - Xcode for Lion.
Wants credit card information, nope, not on a shared work laptop.
Look on web and find you can set up your account under iCloud without credit card info.
Attempt to do that but it wants to verify email first.
Don't appear to be getting email to confirm.
Finally realize it came to my personal account, I have gone round and round with Apple over this and they can't fix it - I log in with my work email but can't associate my work email account to the Apple account.
Confirm iCloud email via link click and login on my PC to Apple website
Ask iCloud to try again but it fails.
Close iCloud.
Open iCloud
iCloud is now happy so I click into manage account and it has a NONE option for credit card.
Update and save info.
Get multiple Apple emails to my personal email about the updates.
Open App Store.
Click on Free on Xcode in search results
Click on Install
Nothing happens
Click on Xcode to move from search results to full screen Xcode information
Click on Install
States Installing... but no status visible
Click on Purchases so I can monitor 1.53 download
Get another email from Apple saying I am downloading stuff and if I did not do that I should change my password. 
Ignore the email.

Run Xcode
Asks to uninstall old Xcode (guess the crash really did fail even though Xcode did not appear any longer in Applications)
Install old Xcode
Xcode runs some extra updates
Xcode up and running and I am able to run the App on my test iPad.
App runs great, scrolls around at full speed.

Try a couple of times to update iTunes and it continues to fail
Search on Google and it is suggested I download the DMG directly from Apple iTunes site
Download 170 meg of iTunes fun
Start installer - asks to close Xcode
Close Xcode - run installer
Installs just fine this time
Run Update checker - no updates found

System is now up to date, well as up to date as it can be with Mountain Lion ready in a few hours, Xcode runs and I can go back to app development. It was a bit of a winding road to get it all to happen though. Felt like way too many hoops to jump through to install the few things I needed to keep working.

UPDATE
Java is not installed by default with Lion. I am now downloading and installing Java so I can use AppCode and IntelliJ to do development. The keystrokes in Xcode are driving me nuts so I am going to switch to AppCode to see how that goes.

Monday, July 23, 2012

Take time out to clean up your program's user interaction

Once a product has been around for a long time you will start to find little issues and inconsistencies. Our app has hit that stage and I am taking the time to fix as many of these issues as I can. It will make the whole thing look more professional. Hey, what about some examples bub?

Double click to Add / Remove

If you have side by side lists / trees on a screen with add / remove or move left / move right buttons people expect to double click on items and have them move between the controls. We try to do this everywhere in the product but missed some cases.

Prompt when an action can't be reversed such as deleting a row

No one wants to accidentally lose data. Make sure they can't without a prompt. This is a super easy fix, just adding a message box above and checking for YES / OK action. Make sure you don't check for NOT CANCEL as clicking the red [x] in the corner is not yes, not cancel but close. Checking for not cancel will have you perform the action which is not what the user meant when they dismissed the message box via [x].

Check for unique names

If users are adding name filters or other similar data to a table make sure they are using unique names. No need to confuse everyone with two filters named Kevin. Do the same check when renaming, cloning or any other operation that allows them to type in a new name.

Enforce permissions uniformly

If you have a permission, privilege or similar system make sure you are consistent in its usage. Don't block them from doing something in one place and not another allowing them to get around the rules. Back fitting a permission system can be a real bear but the users asked for it for specific reasons so make sure you follow through.

Consistent images / Duplicate images

If you use a lock for checked out don't use a door with an arrow in another area. Along the same lines don't have duplicate images scattered about in your directory structure, that will drive your graphics artist nuts and is a waste of install package space.

F1 Shows Help means do it every time

Don't have F1 work some of the time and other times not even if it can't bring up a super specific topic. Have it bring up the general topic for the area you are in until the help team has time to get the specific one ready.

Dirty checking needs to be accurate

When the user chooses to edit some data, they make no changes and hit [Cancel] make sure you are not prompting them with "Changes have been made. Save them?". Verify you prompt when things are dirty and don't bother the user when they are not.

When things take a long time show a progress indicator

During testing with very small data sets everything moves fast. When a user gets hold of the product and starts adding rows a mile a minute initial table requests can take some time. Make sure you are showing a busy indicator of some sort so the user knows the system is busy and not locked up.

Make sure entry fields are wide enough

No one likes to see 5 characters when they generally type 10 or 100. Who wants the zip code cut off at 4 characters? Give them the room they need.

Support spell checking consistently

You finally added spell checking to your free form notes fields. Awesome, not add it to all of them not just in one part of the system. Users expect spell checking to work everywhere: email, IM, search text entry, etc. If ;you start providing it then finish providing it.

Pick a date entry control

Is it month / day / year or year / month / day? Is it a combobox? Can I pick or type? Does it support a short-cut key for today? Use the same format and entry style everywhere.

Use human Boolean strings

Programmers say True and False, humans don't. Use Yes / No and make sure you descriptive label is not a double negative like "Don't erase file at end of processing: NO". People don't like to scratch their head figuring out what you mean.

Term consistency

Don't call it a privilege here and a permission over there. If a menu item invokes a dialog have the dialog title be the same as the menu item so when support gets a call stating they are on the Update Patient dialog you know they got there from the Update Patient menu item. Please don't have the "..." in the dialog title though.

Don't allow crazy entry into specialized text fields

We all know to dollar amounts numeric only but what about illegal file name characters? Anything you DB of choice hates? SQL injection? Limit the users typing as much as possible or at least show a message when they press [Save] to let them know something is amiss.

Don't over prompt, show all possible errors / warnings

No one wants to fix issues one at a time. If 4 of the 6 entry fields have invalid data then tell them about all of them in your first message. Don't make them fix one then complain about the next one until they have fixed all the issues. Think how much fun this would be is your compiler stopped on the first error.

Put errors / warnings in a scrolling list at a certain size

A huge message box that does not even fit on the screen does little good. Some errors snowball into more errors. Put a reasonable limit on the text you show but let the user scroll through all the text. The key to fix 90% of the problems might be on the final line.

Don't call your user an idiot

Face it as programmers we tend to think in the negative. This failed, the build is broken, fecal matter has impacted with the spinning cooling device. Programmers tend to use negative language in their error messages. Try to avoid that. A good tech writing team will keep it from happening but programmers tend to put in the placeholder text and a lot of time it will make it into production. Don't get all sappy and just sprinkle in "Please" and "Thank You", actually work on the wording.  "User name is invalid" can be "User name must be unique" "User name has invalid characters - allowed characters are xxxxx". Try to be helpful and point them in the direction to fix things instead of just telling them they suck.

Use reasonable column widths

Zip codes don't need 50 characters of width but descriptions do. Try to show all the information in a cell if possible but it not make sure tool tips work. Users don't want to click on Edit just so they can see the values in a dialog box.

Resizable dialogs anywhere it is possible

Most of us have used MSCONFIG at some time to find out what sort of crap has decided it needs to run every time our machine starts especially when you are looking at a relatives computer which under the gun to "just make it work like it did before". Why is this dialog not resizable? It isn't because that was a bear to do in C/C++/MFC. Most of use probably don't have this excuse anymore.

Feel free to let me know about your favorite issues to address.

Friday, July 20, 2012

Looking forward to Jelly Bean

I really like my Android phone and tablet but the lagginess of the UI is a problem. It appears Google has listened to the masses and have at least attempted to address this issue with the Jelly Bean release. Since I have a WiFi only Xoom I should see the update by the end of the month.

Sadly I will not get Jelly Bean on my Samsung Galaxy S Vibrant phone where I really want it. I hate to get a call and not have the screen respond to me sliding to answer the call. The pretty much is a failure for a phone design, you must be able to answer a call especially when the phone is sitting idle on your desk. If I was in the middle of playing an intensive game them maybe they could have a minor excuse.

I have not found too much lag on the tablet and it is not a phone but I hope it improves enough that I can give Google credit for addressing this issue that has plagued Android from the start.

I don't use an iPhone other than for testing code I wrote but just from the interactions I have had with iOS is does seem to be more responsive. Background tasks can take longer to complete but when you are using the UI it is snappier. Cleaning this up should help Google ship on more devices. Not all devices will get the help they need which stinks. Of course older iOS devices don't get iOS updates either but they tend to get updates in a larger time frame than Android devices.

Close to rooting my phone so I can at least get Gingerbread on it. Will not solve all my issues but I could delete the apps I don't care about T-Mobile and Samsung shoved on there.

I downloaded the Jelly Bean SDK, tools and updated Eclipse today. I like the new Eclipse look, more modern but still clean leaving most screen space for coding. Don't have any Jelly Bean apps in mind but I like to keep my tools up to date. At least with Android I am able to target old and new SDK versions without an OS upgrade and a multiple gig download of an IDE I don't care for to keep working with my devices.

Monday will be the Lion upgrade and Xcode upgrade on the MacBook Pro. Then I can finally test my new iPad app on the actual device to make sure the UI is responsive. The simulator shows my paint / scrolling code to be very fast but the simulator is in now way a reflection on what happens on the device as far as speed is concerned. I really wish you could tweak its speed to be realistic.

Why Lion and not Mountain Lion? We will upgrade to Mountain Lion but I know the servers are going to be hammered when it is released. I can do Lion now so I can get Xcode updated allowing me to test the code on the iPad then when things have calmed down, some reviews have been published and maybe an update or two occurs we will go Mountain Lion.

I am running the MacBook Pro with and extended desktop onto a second screen. I have the simulator and Xcode running on the second screen but anytime I change the emulator - zooming or orientation - it pops back over the main laptop screen. That is crap way of doing things and very annoying. Leave the window on the screen where the user placed it. The simulator also paints odd at times. Not the app area but the border area they draw to make it look like the iPad. I am unimpressed with the Apple developers tools.

Wednesday, July 18, 2012

iOS developer woes

I am working on a new iPad program. It will allow an anesthesiologist at a facility to shift around the appointments of the providers in his group. Scheduled surgeries run late and there are a variety of other reasons to shift things about.

I got back into the CGContext side of programming under iOS and have the time margin, row headers and basic grid painting up and running. I wanted to see how this looked on the physical device before I got much farther along. Not allowed.

My iPad has been updated to iOS 5.1x. I am targeting iOS 5.0x but since the iPad has received the OTA updates it is past that. You are not allowed to get the iOS 5.1x SDK without Xcode 4.3.x and you are not allowed to get Xcode 4.3.x without Lion.

A couple of things stink here. Before Apple moved Xcode to the App Store you could download the DMG file and extract the iOS 5.1.x SDK files and use them with Xcode 4.2.x. That is no longer the case. In fact it appears you need to uninstall Xcode 4.2 before you install 4.3 as the new install directory is App Store based and not developer based like it was before.

Reviews of Xcode 4.3 are not glowing. Appears to be more crash happy than 4.2. Xcode has always been a flaky IDE but it is the only one in town. Yes you can use AppCode from IntelliJ but you still need Xcode installed for debugging and Interface Builder.

We need to upgrade to Lion but that is silly to do when Mountain Lion is due out in a week for $20. That means I need to wait but there will probably be an onslaught of others upgrading at the same time and it will not be a small download. Servers will be hit hard and heavy.

Xcode is a massive download at 1.43g but am I allowed to get that now? No, the App Store will not allow me to download that since I don't have Lion. I will have to fully upgrade before I can start the next monster download. This is going to take multiple days with me leaving the laptop on overnight for downloads. I can't queue things up either.

I think this will be my order of execution:
Uninstall Xcode 4.2
Upgrade to Mountain Lion
Install Xcode 4.3 from App Store
Hope all my projects still work, Mountain Lion is stable and Xcode is not super crash happy.

I could downgrade my iPad to iOS 5.0 to do my testing. That would work as a temp solution but it is not my iPad, it is used by QA and Technical Writing. Since the update is OTA and it will ask about it there is a very strong chance it will be updated again once it is off my desk for a few minutes.

I just hope nothing goes wrong during all these changes. I was using VNC on my PC to do Mac programming. It is my understanding that VNC is rather broken under Lion and I have not heard that they addressed that under Mountain Lion. My whole development environment is being turned upside down.

Monday, July 16, 2012

Using TightVNC for Mac development

My main PC machine is a nice dual screen setup with a fast process and lots of memory. All of my email and IM processing happens on that machine. When I use the MacBook Pro for iOS development I run into multiple issues:

1) Screen is smaller (nice screen but smaller)
2) MacBook Pro keyboard is missing keys I use a lot for programming such as Home / End
3) Company Global Policy times out / locks my PC after 5 minutes
4) With PC locked out I have a blank screen and don't see incoming instant messages and emails

I enabled screen sharing and set up a password for it on the Mac. I then fired up TightVNC on the PC and connected to the Mac. I now get to use my PC keyboard and mouse and have Xcode up in a window on my PC. The PC has a large screen at 24" vs. 15" and more pixels thus I can run the Mac OS in a window and not lose any of my PC context.

So far TightVNC has disconnected a couple of times but a simple click on the taskbar icon brings it right back up. The Mac seems to be happy about the whole thing. I am not seeing any issues with typing, mouse or screen lag. iPad emulator appears to work fine too. On occasion it can be a bit tough to get the Mac taskbar to appear. Since the Mac is sitting on the desk right next to me I can quick swivel my chair and pull it up there. Probably just need to find the sweet spot to let the mouse hover.

At times I think about getting a used Mac Mini to continue iOS development at home. I have not wanted to do that as I thought I would need to set up KVM switch. Did not want to buy a Mac laptop due to cost but the Mini is pretty cheap and setting it up to do VNC is simple. I would have no need for the KVM which can get pricey if you want digital monitor connections. What's a little network bandwidth between friends?

** UPDATE **

I think I am giving up on using VNC with the Mac. TightVNC was crashing a bit too often. I set up UltraVNC and I was able to get the keyboard confused too many times. UltraVNC did not crash but you can't properly use the Windows key with it either. It is just getting to be a bit too much of a headache which means my dreams of a Mac Mini sans KVM are going out the window too.


Friday, July 13, 2012

We just need to update the animated GIF...

Our splash screen shown while loading our WebStart application is an animated GIF. Simple file that happens to have the copyright date. It was showing 2010. I did not create the original nor did I have the original artwork and the guy who created it no longer works here and they have not replaced him. There is a chance we could have sniffed around on old hardware long enough to find but our network tech is on vacation.

I figured this can't be too hard. I found a tool for creating animated GIF images called PhotoScape. It showed the 13 individual images as a time line. I was able to right click on each image an save it to the clipboard. Since I am not familiar with PhotoScape and I did not quickly discover how to edit the images there I used Paint.NET. I copied the 2 from 2010 and put it were the final 0 was for a 2012 copyright. It is a gradient background meaning I had to take some care to make sure it looked good. I updated all 13 images, added them back into the PhotoScape and saved the new animation. Looked great until I looked at the file size. It had gone from 54k to 604k which is simply not acceptable.

Must be a way to optimize a GIF so that frames are deltas instead of the whole image. Hitting up Google for answers showed that to be the case but of course finding a tool to do it was not easy. After trying a number of them out with various forms of failure I saw a post about GIMP supporting what I want. I had version 2.7 which did not appear to have the GIF optimization menu items so I grabbed 2.8. It had what I needed and a quick export to GIF with the proper delay between images had me back down to a 54k file.

I probably could have used GIMP for the entire process and saved a lot of time. I don't have a license for PhotoShop at work but I could have taken it home and done the processing there. Just seemed like a good thing to polish off on a Friday afternoon and once you get started with the investigation process you might as well finish it up.

Lessons learned, new tools learned, mission accomplished. Not a bad way to end the week.