Archive

Archive for the ‘Programming’ Category

Wearing a sysadmin hat

February 14th, 2010 No comments

In the past weeks I’ve been doing some temporary sysadmin work for my day job and this new role extended to my night-time job. Yeah, I joined a startup but I’ll talk more about that some other day.

I had to move one of the web services we offer in my regular job to its own server. It was a good change, we moved the entire app from a CentOS/cPanel box hosted on the Planet to an instance running Ubuntu on AWS.

CPanel is a really good product and saves you a lot of time but it is a pain in the butt if you are serving more than shared hosting accounts. If you have ever tried to automate tasks that handle virtual domains, email accounts and DNS entries you know what I’m talking about.

Anyway, I must admit that I’m having a blast wearing a sysadmin hat during part of my day. I’m learning a lot. I have this great excuse to read some books that were on my TO READ list for a long time.

One of these books is Pro DNS and Bind by Ron Aitchison. I have had this book on my desk for months but I finally finished reading it. The book gave me a nice introduction to DNS servers, resolvers, zone files, resource records and diagnostic tools. Highly recommended.

A matter of guidance

December 9th, 2009 No comments

LasVegas Cloudy days are perfect for productive leisure, so in March before moving to the US I spent a lazy-cloudy-Sunday afternoon packing. Moving is always exciting and a good chance to get rid of everything that is not necessary in your life anymore. You can even leave bad vibes behind if you are spiritual. We tend to gather too much junk. Keep it simple.

The cleanup included my bookshelf. My mission was to dispose of as many books as possible. Boy, books are heavy to carry and physics does not apply when it is part of your luggage.

While running through the titles I started to compare dates of purchase against subjects. I have had this habit since I was a teen, every time I buy a book I sign and date it.

Anyway, my small library was another lead to an obvious issue: my quest to become a programmer is a mess.

Here’s one good example. I wanted to code games when I was a teen. After some research I concluded that C++ and DirectX were the right tools for the job. I decided to start with C++ and ordered “C++ How to Program” by Deitel. Back then, a small number of web pages would advise: “You have to learn C”. My mind discarded that advice as fast as I could read it. Why would I learn C? Isn’t C++ not only C but PLUS PLUS! It is the future. Yeah, I know you are laughing at me.

I read and tried all the examples from “C++ How to Program” before reading or writing any line of pure C code and felt ready to dive into some DirectX books and code the best tic-tac-toe ever!

Turns out my ambitious plan needed a detour. You have to go through some Windows programming before you can dive into DirectX (I don’t know how it works now a days). Gosh, 70 lines of C code just to print Hello World in the Win32 API world.

I can’t just copy and paste code so I ordered “Programming Windows” by Petzold to become familiar with Windows programming. BTW, Programming Windows is a great book — and I found a minor mistake in the text! (Erratum #5).

I read the book, tried the examples and the fact is: Win32 API is C Code.

Because of that I finally ordered the classic “The C programming language” book to fill this awful gap in my skill set. Comparing the dates of purchase I realized that I bought the C book 2 years after the C++ one. Sad.

I now remember that after going back and forth I finally achieved my goal. The best tic-tac-toe game ever written did compile and run without crashing. The euphoria lasted for almost 5 seconds!

Before writing my first line of code I was already humble and comfortable with the idea that it takes a lifetime to be a great developer. BUT, it took me a long time to have a better overview of the skills set you need to build in order to be a software developer.

It’s a matter of proper guidance.

It doesn’t matter if it’s a CS degree or guru souls willing to show you the way.

Windows Day Experience

October 27th, 2009 No comments

vegasI always try to have at least one small toy project that I can play with at night. Sometimes it consists of only reading the source code and mailing list from a big project and sometimes my toy project involves writing code and playing with different tools than the ones required by my daily job.

A few months ago I added to my schedule a Windows Day. Brand new world. I dove into Vista, ASP.NET, C#, IIS, MSSQL and Visual Studio one day per week (and occasionally weekends) for a few months.

I was excited because of the novelty. I read a few books on the subject and had  to play with it.

Here are some random thoughts about my experience.

Right on the first day I got frustrated using the mouse for simple tasks like moving and copying files around so I installed cygwinA difference between two worlds.

I learned later that there is a Windows option for the command line: Powershell. Although I didn’t try it the Wikipedia article gives me the impression that learning Powershell is probably a good investment for Windows developers.

Back to random thoughts.

I was then ready to try Visual Studio. It is amazing to try examples from books just dragging and dropping icons that build some correctly written snippet of code. I just doubt that experienced developers would follow that approach.

One problem I had with Visual Studio was trying to set the Emacs key bindings. Leaving the keyboard home row to reach keys like arrows, page down and page up is disturbing. I followed this post advice and installed Emacs Everywhere.

P1050196

The next step was the database. Oh boy, choosing a MSSQL version is so damn confusing! I’m probably getting older and dumber but I couldn’t understand which option to download from the MS website. Installing MSSQL in Vista was quite painful, too. Had to follow some MS black magic recipes to get it running. Installation on Windows 7 Beta was a breeze though.

After setting up the database I went to the HTTP server. IIS is pretty straightforward. You can setup a working environment with just a few clicks.

Working environment ready and I started to follow the books’ examples. A few ASP.NET web forms later and I was ready to start learning C#.

Talking about computer languages is somehow a taboo so it should suffice to say that C# is verbose.

Well, a few months after my first Windows I’m back to a Linux side project but I’m glad that I took some time to get an overall idea about the ASP.NET world. It’s not for me. Once you go open source you never go back.

If you are only interested in building your client project it doesn’t really matter the platform you pick but it’s a disturbing feeling that you can’t build IIS or poke Visual Studio’s source code. There is this sense of being a powerless and passive consumer always trying to catch up every .NET update.

Ancient bank institution file formats will make you bald

September 5th, 2009 No comments

computer museumThis past week I was documenting part of the system from the company I work for in Brazil, and while running through the payment options code I was again confronted by the ancient file format that bank institutions still use today. You’ll never complain about XML files again if you have to deal with a bank file format in your life.

I don’t know how it works here in the US but years ago banks in Brazil came up with a file format dubbed CNAB to exchange financial transactions. It’s basically a layout where data fields are delimited by their byte positions. Seems pretty straight forward, right? So try implementing one and you will feel the pain.

The first problem is bureaucracy. You need a business account, lots of papers, signatures, phones calls and of course talking to Elaine. She is your bank account manager, really polite and willing to help but obviously completely clueless regarding any technical question. Most of the time she is not allowed to put you in contact with someone who works all day writing Cobol and has all the answers to your questions (I actually empathize with the Cobol guy and pity him whenever he needs to answer the phone).

After everything is set and you are allowed to interact with the bank system via their file format they email you the technical instructions. It’s a word document detailing the layout. Prepare yourself to learn how it works through trial and error and a lucky chance to talk to someone on the phone (yes, a real human being) who actually knows what is the default char for the field delimited between bytes 116 and 118. Is it a blank space or just a zero? Can the file be encoded in UTF-8?

You just need a second bank to send you their layout documentation to prove your inner fear. Each bank implements its own CNAB layout version. This is the time you start praying for a framework to deal with all layout inconsistencies across bank institutions.

All is not lost though. After going through all this you have a new skill set. You are ready to work at any bank institution because you did your homework. You have grasped an understanding of all kinds of bank transactions. You have to do this even if you only want to automate monthly invoices for your customers. It’s a hell of a ride my friend.

Now, I’m not trying to undervalue the CNAB file format. It was probably a good solution 20 years ago. It still works. The problem I see is how banks are outdated compared to companies like Paypal and alike. What are they thinking? Can’t you just build a web interface to deal with your internal file formats? Just give me a Restful Web Service in XML or JSON so I can send monthly invoices or pay the employees.

how much does a line of code cost?

August 17th, 2009 No comments

Rio de JaneiroThis past week I stumbled upon a nice tool: sloccount. Sloccount was written by David Wheeler and is a set of tools to count lines of code. Wheeler also has some really interesting papers regarding the linux kernel size and its development cost.

After installing sloccount* I immediately started to harvest data on all projects I currently have on my hard drive. I was really impressed by the first results. The costs are too high, I thought. A small project with 2,000 lines of PHP code like the Autoresponder has a development cost estimated at more than US$55k.

After reading sloccount’s user manual and pondering about the Awake Autoresponder I started to change my mind. 2k lines of PHP code encompass a lot more work than the number suggests. A few reasons for this:

  1. The code was updated every time a customer submitted a bug. As you know, fixing a bug does not necessarily imply more lines of code
  2. Out of the box sloccount doesn’t compute HTML, CSS or Javascript
  3. Technical support
  4. Documentation

It took me a few thousand commits, I don’t know how many emails and several hours of night debugging the script on customer’s servers to reach 2k working lines of code. It may sound like cheap advertisement or self promotion but I must say that US$49.90 for the script is a bargain!

* if you are running Ubuntu it’s easy as

sudo apt-get install sloccount