Wednesday, March 27, 2013

Life with a Mac a few weeks in

At my new job my development machine is a Mac. Having been a heavy windows user for the last bunch of years but using a Mac on occasion to do some iOS development the change has been pretty easy.

Initial setup took some time as did learning initial command line options. Really everything else is pretty much just like on a PC. You run Eclipse, Sublime Editor, Chrome, Outlook, Finder, Terminal window, Evernote, a music player and various file viewers for images and PDF files. 

Once configured you just have to learn the proper shortcut keys to pull of frequent operations and off you go. This is a MacBook pro and I have a large second monitor. Everything is really fast.

I have been working on parsing XML and JSON files from security firms. Lots and lots of parsing of large files - will not HUGE but big as in 55+meg in size. I tried a number of JSON parsers and finally settled on Jackson as I needed to do streaming parsing and needed the ability to build simple JSON constructs on the fly as one provider uses JSON for request and response while the other two use standard HTTPS: requests with ?name=value params for requests and XML for responses.

Each API has its own set of oddities. Right now I have everything we need parsing and am using pagination to keep the response sizes to something reasonable. Next step will be hooking it all into the production code. Always good to iron out the bugs with simple test applications first.

At this point I really don't even think about being on a Mac. Sure the frame decorations are a bit different than in Windows but Eclipse looks and operates like Eclipse. Chrome is Chrome and sucked over all my settings, bookmarks and extensions. 

If I need a program I can generally find it but there are a lot less free options than on the Windows. Most things cost something or there is one or two free versions. Most programs have already made a number of decisions for you. Unzip something? Put it right where you unzipped it from. Don't ask where you want to put it. Download something? Yep, already gonna do it to the one directory I have chosen. Not a huge deal. I move things around expo facto but there is a lot more hand holding.

I have been kind of surprised at home much time I have spent in Terminal. Using Mac Ports to install software, dealing with CURL and Python etc. Some of this is for testing the API and some has been to get around Finder limitations. Of course I do the same when in Windows. Not that a normal schmuck would do this, as a developer I tend to need to do odd things.

There has been a lot of learning. I have never used CURL, xml_grep or JSON streaming parsing before. I had limited exposure to Python and Tree based JSON parsing. None of the sample code I have gotten for the APIs has been written in Java meaning I must learn CURL, Python etc. to know enough to convert to our target language. I love to learn so it has been a lot of fun for me. Gives you an appreciation for the other languages and utilities.

Working with vendors keeps you on your toes too. Good to have 3 going at same time otherwise you are waiting on one to respond while you have nothing to do which is never good. Keep me busy. Also allows you to spot differences and similarities in the APIs making some coding go faster. If this was split between 3 people that knowledge would not be shared as easily. I have shared many classes between the projects.

Wednesday, March 20, 2013

Other Mac things I have learned


Show hidden files in any open / save dialog  

As a programmer there are times you need to create files that start with a '.' (period / dot) such as .bash_profile. But what happens when you want to open that file to edit it? The standard Open Dialog does not show hidden or system files.

Press Cmd+Shift+.  (that is the period) when the dialog is open to show all those bonus files.

Change file association

I wanted to open JPG files in Picasa instead of Preview.

Right click on a file and selecte "Get Info"
Change default application to open it with, then click the button [Change All]


Use XML_GREP to quickly pull data from XML files

There are times you are given an XML file and you want to quickly pull small pieces of information out of it. No need to write a full SAX or DOM parser to do that when you can use XML_GREP.

Sample of a record in the XML file
<REPORT_TEMPLATE_LIST>
  <REPORT_TEMPLATE>
    <ID>1537005</ID>
    <TYPE>Auto</TYPE>
    <TEMPLATE_TYPE>Scan</TEMPLATE_TYPE>
    <TITLE><![CDATA[Executive Report]]></TITLE>
    <LAST_UPDATE>2013-03-08T15:37:07Z</LAST_UPDATE>
    <GLOBAL>1</GLOBAL>
  </REPORT_TEMPLATE>
  ...
</REPORT_TEMPLATE_LIST>

Would show:
Executive Report
...

To grab multiple tag values:
xml_grep --text_only --cond 'TITLE' --cond 'TYPE' assetDataReport.xml

Would show:
Auto
Executive Report
...

Remove the --text_only parameter if you want to see the TITLE tag information too.


How to install XML_GREP

 Visit: http://www.xmltwig.org/xmltwig/ and download latest version

  cd XML-Twig-3.42 (use version downloaded here in place of 3.42)
  perl Makefile.PL -y
  make
  make test 
  sudo make install


Format XML file (pretty print)

Let's say you have an XML file that is all one one line or has no indenting and you want to pretty print it. You can use xmllint which is already installed on you Mac to do that. Here I am converting Sample Report.xml to newfile.xml where Sample Report.xml is the original unformatted file and newfile.xml is the indented pretty version of the file.

  xmllint --format --encode utf-8 -o newfile.xml 'Sample Report.xml'  

Thursday, March 7, 2013

What I installed on my Mac at new job

Boy it has been a long and winding road to get the new MacBook Pro into a useful state. I realize Macs are meant to be super easy to use but that gets in the way of power users.

I have learned a lot of new terminal commands, where files reside on a Mac, naming conventions when reading Mac web pages and what not. I will try to share what I can before I forget it all and move on to the next thing.

I wanted to see hidden files. Executing this in terminal allows for that:

defaults write com.apple.finder AppleShowAllFiles TRUE

Change the TRUE to a FALSE to reverse the change.

~/ means your home directory when you are on a web site.

See the first five lines of the clipboard

pbpaste | head -n 5

Terminal is OK but I wanted a tabbed support as I use Console 2 on the PC. I installed iTerm to handle that situation. I also like a semi-transparent background on the terminal as I am generally monitoring things behind it too.

Finder is really not my cup of tea but I was able to get around most of my issues using xtraFinder. While this program is still in beta it fixes the major issues I have with Finder and it is free.

1) Tabs to open multiple directories instead of having multiple windows open on screen
2) Grouping folders first then files. Never understood why Finder does not have this option. Most of the time I am looking for a folder first then a file within second, I don't want to scroll way the heck down to find my Folder. I know I can sort by Kind to get them in group but that still puts them randomly somewhere grouped in a list.

I copied in my music files from a USB key from my Windows box. There was a stupid desktop.ini file left in each album directory. I wanted to delete all of them which on Windows is:

del desktop.ini /s

For the Mac I needed:

find . -name 'desktop.ini' -print -exec rm -fr {} \;

I realize this is a more powerful command but this is a simple thing I need to do a lot and what I had to type to make it happen was not straight forward. I will have that command in my pocket from now on though.

I had to tweak my security settings to allow me to install things not from the Mac Store. Good to stop a normal user from doing this and it was a one time change to make me happy.

Mac Ports seems to be the way to go to install 3rd party products. You need to know the name of what you are installing. You get to type your password a lot as you are using SUDO commands left and right to accomplish this. It works and the web sites are really good at listing the port name you need to use for the install.

Just found you need to do this after installing Xcode and the Xcode command line tools:

sudo xcodebuild -license

If you don't then you will get errors when attempting to install programs.

The company uses VMware Fusion so I had a license. I was able to quickly install Win 7 professional from DVD. Some of the production apps are written in C# thus the need for a VM to run them.

iTunes does not support common audio file formats so I used Adapter to convert music to MP3 so I can listen to it on my Sennheiser wireless headphones. I have had them for a couple of years now and still on first set of rechargeable batteries. While not perfect, an occasional hiccup due to interference, they have served me well.

At the prodding of the other developer who started on the same day as I did I installed Evernote. Nice app to type in random thoughts and to do lists as they hit my brain. I can see all that stuff on my Note II which makes it very easy to remember the crazy list of items I still need to bring in. 

I use Sublime 2 as my text editor. I like it that I have the same editor on my PC at home as on the Mac. Some of the keystrokes are a bit different but I am getting used to that too.

All the other set up was configuring SQL settings, other environment variables, VPN, tweaks to various programs so they operate to my liking and doing web research on my first project and on tools they use here that I am not deeply familiar with yet.

I also need to find out coding style. Seems to be opposite of the last job no matter where I go. I am used to braces on same line but it appears that they are on separate line here. No big deal to me, configure Eclipse to do it that way and get on with life. 

Do wish I had a docking station for the MacBook, unplugging everything to take it home for the night is a bit silly. Was so easy to undock the Lenovo laptop at old job and put it in bag with extra power supply. Not enough USB ports and they seem to trickle charge my phone. I have the external keyboard in one port and my phone in the other leaving zero for anything else.

Wednesday, February 27, 2013

What to install on a new machine?

What do you install when you get a new machine? As a developer you have to install a lot more things than a normal user.

For a Window box I need the following:

  • Java SDK
  • 7 Zip
  • Eclipse
  • Android SDK
  • Sublime Text
  • Chrome, FireFox, Opera to test websites (IE is preloaded)
  • SmartGit, Tortoise, TFS (what ever version control you currently use)
  • Console2 (allows you to do transparent / tabbed command lines)
  • Greenshot to get easy screen shots, annotate and crop them
  • System Internals (lots of tools, need most of them)
  • Paint.NET (so far my favorite free paint program)
  • Hoekey (run things off Win+key combinations)
  • Pencil (quick wireframes)
  • MediaMonkey (music and other files)
  • Python (for quick scripts and easy file parsing)
  • Picasa (for fast photo viewing)
  • Various USB / ADB drivers for Android phones (Motorola, Samsung, HTC)
For a Mac I need the following:
  • Java SDK
  • Eclipse
  • Android SDK
  • Xcode
  • Sublime Text
  • GIMP (for painting chores)
  • AppCode (if company will pay for it, I like it better than Xcode)
  • Source Tree (if using GIT)
  • Chrome, FireFox, Opera (Safari already there)
Both 
  • Chrome extensions, FireFox extensions or both
  • Current set of bookmarks (auto imported by Chrome)
  • Existing code snippets I have collected over the years
  • Music
  • Wireless headphones (not really an install, just plug them in)
It can take a bit of time to get it all set up but it really is not that big of a list. Most things are already on the box ready to roll. If it is a totally fresh machine you have to install the latest updates from Apple or Microsoft before you move along too far. I try to carry most of my list on a USB key so I can hit the ground running instead of eating up bandwidth trying to get the required bits on my first day.

My new job will provide a MacBook Pro. I need to get used to GIMP again. I have been using Paint.NET mainly for the past year. I have had positions where I have both a PC and a Mac and I have cheated and used the PC for a lot of my graphics work just because I am familiar with it. I have Photoshop Elements at home and I use that too. I will also have to spin my head into Linux command line usage. Not that I need the command line very often on a Mac but when you need it you need it bad and don't want to have to look up every command.

In general it is not too hard to switch between a Mac and a PC. I will have the same keyboard - a Microsoft Natural 4000, at home and work. They layout just works better for me. Some of the keystrokes on the Mac will mess me up for a bit. I used to switch between the two every few minutes as I was doing Android work on one and iOS on the other or I was testing our main Java app on both so I would be testing layout differences.

Always interesting to start on a new machine then to start realizing what you are missing. Some program that you only use so often. Of course in the old days you had to dig out a CD or a floppy disk and install it. Now as long as you remember the name you can download and install it off the internet. Physical media is not used much. 

My wife got a new laptop and I was able to set it up pretty quickly. It is a Lenovo laptop I got refurbished from Microcenter as I did not want a machine with Windows 8 and I wanted something with a lot of RAM and a good processor. Save but sturdy. Why not Win8? Am I not a tech? Yes I am a nerd but she would be the only one in family with Win8 and I just did not want to mess with it. I have not heard good things at this point. Generally skipping every other release of Windows has been a safe bet.

I was able to install things quickly. I had to dig out or Quicken CD but everything else came off the web including an install of Office 2013. She was up and running easily and does not use the machine for development so my list about was cut pretty short. She does a great job keeping her documents and what not on our home server so everything was there. Calendar, Contacts and emails are done through Google as they sync with her phone so all of that was ready too. The cloud sure has made things much easier. The home server, which is backed up Mon, Wed, Fri, also helped a lot. It serves as a printer server too.

Ready to get my new Mac going. I will add to the list if I find other things I needed to install.

Sunday, February 24, 2013

What programmers want

I had a recent one on one with my boss and he was baffled about something. Multiple programmers, including me, had asked for larger monitors. Well it did not have to be a ton bigger but we wanted a better pixel count. The company standard is 20" monitor using a 1440x600 resolution. That is pitiful. Heck the 15" laptop has 1440x900. For him to order better monitors it was going to take some effort on his part and he really did not feel like doing it.

First off he said everyone in the building wants a bigger monitor. I am sure that is true. He did not want to start a trend. Boy have I run into this in the past. At a previous position I asked for a second monitor and that ended up in a big tussle. I final got one by submitting the fact clients had dual screens and we were not testing against them. In fact we knew we had dual screen issues that were not being resolved. When the big boss was out of town the next guy down was willing to sign off on me getting one. Of course other developers wanted one too. They got it in their head they had to order then all at once. I suggested they order a couple a month and hand them out by seniority. It took them a full year before they decide to do this. How much productivity was lost during that time?

You are much more productive when using multiple screens. I have two at home as do both my sons and my wife. I use the dual screen mode on Note II. We are constantly cutting and pasting between multiple apps. I have tons of apps on a screen when developing: Outlook, SmartGit, IM client, Chrome, Command line, File Explorer, IDE, Sublime 2 text editor, TFS, Paint.NET and other apps as needed. Running all that with not enough pixels is silly. My main screen at home is 1920x1080 and my second screen is 1680x1050. My previous job had dual 24" monitors at 1920x1080. As a programmer you use all the room. We don't live in Outlook + Word or Outlook + Excel all day long. Even using TFS on that little screen stunk. Not that TFS is UI to love, but man did I have to scroll around a lot to see anything. I want to have the email client running that I can quickly glance at to see if an incoming note is important or not. If it can be dealt with later or I am just on a big CC list then I easily ignore it and keep coding. If I have to ALT+TAB toggle windows to read it then I have been interrupted.

If you are a manager take a look at what your developers have open at any point during the day. If they don't have a dual screen set up by now then shame on you! If you have crappy little monitors then fix it! I bought my 23.6" main screen for $119 at Microcenter. That is a very tiny investment. Spread it out over time if you have a big pool of developers but take care of them or they will leave.

Leave is just what I am doing. I asked for a bigger monitor, promises were made but it never happened. I asked for a tablet to test our Android code against and that never happened either. One of the devs has an older MacBook and his compile times suffer and no upgrade in site. The other Android developer was promised a MacBook Pro on the day he started and 4 months in it never happened. Other developers have asked for larger monitors and have not gotten them.

They day after my one on one, first I had in my four months as a contractor, I was offered another job. They all have dual screen setups with large monitors. I have been in that sort of environment in the past and really missed it. When my home layout beats the pants off my work layout it is time to move on. During my resignation meeting I explained why I was leaving. There were a lot of other issues but I did reiterate that developers need bigger monitors and proper equipment. This was not news to my boss. Others have complained and left too.

The boss is very non-technical. He still did not get it but was willing to get people what they needed. I was one of three to resign in a few week time period and more are going to leave as they are looking hard right now. When people leave it is because little things add up. Sure big things play into it to but it is when you start to total up all the issues that you decide to move along. At the very least as a manager you have some control over the equipment your developers are using. Do yourself a big favor and make sure it is up to snuff.

During any interview I ask what type of equipment I will have. Now I know I need to ask about monitor size and pixel count. Of course they can easily lie during the interview just as they did to the other developer about getting a Mac. I generally want to walk back and see a typical developer setup so I can confirm things. Are they sitting on a folding table? Are they low, mid or high cube walls? Do they allow headphones? Does anyone over decorate their space or is it all super minimal decoration meaning they probably move around a lot. Funny cartoons on the wall or all business? Notes, screen shots, white boards with collaborations? If they don't have any white boards that is also a red flag to raise. You can tell a lot about the environment with a quick glance at a typical work space.

What do developers want and how should I manage them?

1) Proper equipment - dual screen setup, and yes one of the screens can be the laptop screen but if that laptop is 13" they you really need a docking station and two big monitors. Mac laptops tend to have really nice screens so I am talking more about a Windows system here. A Mac user still needs a second monitor. Try to have both monitors be digital is possible. VGA stinks at higher resolutions.

2) Monitors with high resolution. Don't go super cheap here, they stare at them all day long. Get a name brand and a matching set if possible.

3) White boards or some way to collaborate with others. A quick flow chart, screen mock up or drawing simple notes can go a long way towards solving issues that need visuals.

4) Access to a printer. I don't print often but there are times it is very handy to print out a document or series of screen shots to jot down notes or to compare for consistency issues.

5) Fairly open internet access. I don't care about using Facebook at work. I don't even have a Facebook account but if I keep getting blocked from finding answers to technical questions on the web because some blog with the perfect answer has a cuss word on it then I am blocked from doing my job. When I worked at a large telcom company it was hard to get to any website at all. Never, ever block stack overflow or you can just forget getting anything done.

6) Special equipment. If you are doing iOS you need an iPhone / iTouch and an iPad. Yes it can be a shared resource but not something you only can have for an hour. If you are doing Android you need a crappy small screen phone, a normal phone, a Note or Note II and a tablet of some sort. The emulator only gets you so far.

7) Uninterrupted time. If you have meetings all through the day a developer does not have time to get is train of thought out of the station. Programming is not something you start and stop on a dime. Once you are in the flow you want to just keep going. Morning stand ups are fine but meetings all through the day are silly.

8) Time to test. Sure we love to pound out code but if there is always another big feature on our plate we tend to just get what we have running and not hit it hard with testing. There needs to be down time between large projects. It gives us time to clean up the code, find our own bugs, fix graphical glitches have seen from time to time. Code lives forever it seems. Nothing is ever done, it just ships.

9) Some real desk space. Yes we need to spread things out when we have documents to scan and screen shots to look at and people to sit next to us to code review and work together.

10) Comfortable chair. I have been at too many places that roll old conference room chairs at the developers. Ratty torn up furniture. Yes, that chair may have cost big bucks when it was new but it is now better off in the trash than handed to someone who sits most of the day.

11) The sense that we matter. Sales and Marketing my have all the flash but in the end without the software there is nothing. The rest of the company generally depends on what the developers produce. The sales staff tends to run feast or famine but when they brag up the big sales bonus it really does not help developer morale unless they have a bonus system too. Little things add up here. A staff movie afternoon works wonders. Doughnuts on a Friday. Gift certificates. Action figures. Free sodas.

12) Ask about the little things that are not going well and try to fix them. Stand up for your team.

13) Don't shoot down cool ideas because the proper team / person did not think of them. This was another sore area and the job I am leaving. The Android team was last in line. Some one designed the product and the iOS team implemented it. That team was not much on the idea front. When it got to us we had some cool ideas to clean up the interface, eliminate taps and full screens. It would have worked just as well under iOS but since it was already done we were told STFU. It was going to be hard for them to adjust the user story, to admit it was wrong to start with and to do new screen shots. The iOS app is not shipping, things are not done in fact they had a 2 to 1 developer advantage. The iOS team even wanted to make the changes, no developer push back but instead management decided not to do the right thing because it was not their idea. Aim for that 2 star rating! They originally hired a code monkey off shore team to do this and it failed. They decided to bring in senior level developers to do the project but now don't want to listen to them.

14) Have one on one meetings. This is the only way you will hear about the little issues that are adding up. My first meeting was way too late. Yes, I brought up all the issues via email or hallway conversations. There were no surprises to anything I said during my resignation meeting but it felt like everything was so informal leading up to me leaving that nothing was ever resolved.

15) Don't treat different teams differently. The Android team always felt like a step child. They loved iOS and even Windows tablets but made us feel like dirt. The UI team was Apple fanatics and hated Android and let us know. All screen shots were iOS with total Android afterthoughts. Your clients don't care about your opinion here. If you ship an Android version it better be the best darn Android version you can produce. It better not be iOS UI on Android. It better not ignore the back button, the action bar and other Android givens. Same on the iOS side. Don't be so generic it could run on anything. Use the iOS UI and be as iOS friendly as possible. It is is new code run on the iPhone 5 full screen.

16) Do code reviews. Being an programming army of one is tough. A code review can bring up better ways of doing things, find areas where objects can be created or removed, find duplicate resources, strings that are not in tables, code not following naming conventions and many other issues. They don't have to be this massive formal setup. Two developers looking at their dual screen set up just talking over the code works. Do them often so this does not get out of hand.

17) Don't let one developer "own" something. Ever piece of code should be cross trained. Yes, you will have a developer that specializes in JSON parsing and one that does custom controls but they should each understand what the other is doing and be able to fix bugs in the code. I don't own any code I write. I type it up, comment it and check it in to source control. They company paid for it and it is theirs. If another team needs to take it over then have at it. To me if they never have need to ask me a single question about the code then I have done my job. There should not be anything magical about it, it should be standard easy to understand code. I should have commented any weirdness and things like "must call in this order to get around known bug in SDK" etc.

My next job will not be perfect but I know it solves a number of issues I have at the current one. I have learned how to interview the company I am applying at. I have reasons for asking for the things I do and I will continue to fight for the best, most productive environment I can have. We should all fight together so we don't have to fight anymore, all these things will just be a given.

Switching wireless routers

I had a Linksys WRT54G wireless router that I had been running for a number of years. My family started complaining of wireless dropouts on various devices, PC, tablet, phone, Wii, DVD player etc. I changed channels and tweaked other setting but nothing seemed to fix the issue.

Since you are not in the market for a router very often I polled my other technical friends and decided upon the NetGear R6300. This is a big step us as I tend to be pretty frugal and I have always dealt around the $50 range on a router. Microcenter had this baby on sale for $179. It was highly recommended and appears to have enough features to future proof me a bit so I went for it.

It has worked flawlessly. I have some devices that use the 5G side of things. Set up was very easy and it seems to have all the features I need. I have no idea why the old router was annoyed but I am guessing it was fighting with other routers in the area. Nice to have the problem solved. Not a single drop that has been reported to me at least. Printer hooked right up to it as has every device in the house.

Felt like changing clocks to DST. Run around the house and try to remember where every device is that uses the router and configure them. Was interesting to see which ones saw the 5G side and which did not. My main desktop is hardwired in so I did not have to worry about that, my son's machine or the Dish network wireless access point.

Wednesday, February 13, 2013

Eclipse dependency not found in workspace fix

I was getting the old dependency not found in workspace error in Eclipse. The other Android developer was not having this issue. We have multi-project workspace set up using Maven and POM.XML files. We had tweaked so many things and done a boatload of rebuilds and reboots of Eclipse with no luck. This error was staring us in the face.

dependency=[com.{problem class here}] not found in workspace

Finally I just selected the errors, right clicked the mouse and selected Delete. The errors went away. Full rebuild and they were still gone. Restart of Eclipse and yep, not there.

At some point in the process those errors got STUCK on and would not go away even though we had fixed the root of the issue. Seems stupid to Delete error messages but in the case it solved our problem.