Base64 Encoding

I needed to initialize a file as part of a unit test. The file conatined binary data. My first thought was UUEncoding, which quickly got upgraded to Base64 encoding. To get it into a format that would then work in Java or C code I used the following line of BASH.

base64 < rui.pfx | sed -e ‘s!\\!\\\\!g’ -e ‘s!\”!\\\”!g’ -e ‘s!$!\\n\”!’ -e ‘s!^!+\”!’

It was for testing a decrypter from using a key generated by SSL.

It is important to double the slashes already existing in the file before you add your own.

Note, I added this as a way to remeber how to put binary Data into code, not as a recommendation for how to mock up for unit test.  The correct solution was to use:

InputStream inputStream = this.getClass().getResourceAsStream(
file.getName());

Subjective

Last week, a friend and I had a discussion regarding the question of whether Quality was subjective. While I subscribe to the position that quality was neither subjective nor objective a-la Robert Pirsig, I found myself unable to defend that position. The argument was disturbing for several reasons. First, when I attempted to show that this was an absurd position, I was accused of changing the subject, or redefining terms, etc.  I have to question whether I was. Perhaps the word “Quality” is, as my opponent in the discussion stated, the very definition of Subjective. If Quality is not Subjective, then nothing is. If a subject is defined by their values, if a person is nothing but values, as Pirsig states, then isn’t the perceived quality purely subjective?  Do to the very enjoyable adversarial nature of this discussion, I shall refer to the other participant as my opponent.

From another point of view, if two people agree that something has quality, it just means that their subjective view of quality aligns.

An example he gave was that “A long law is a bad law.” This is an objective guideline, but accepting it is subjective. One problem with this argument is that I feel fairly certain that he does not, nor does anyone agree to this hard and fast, but most people would agree that the longer a law, and , by implication, the harder it is to understand, the worse a law it is likely to be. This concept could be hammered out to the point of actually providing a guideline for judgment of law quality.

Continue reading

Response to yet another “Atlas is Shrugging” Article

Oh no, not you too.  If I see one more of these “Ayn Rand’s messages are about to come true” articles I am going to…not sure exactly what.  Listen, Rand has a fundamental Flaw in her philosophy.  I ‘ve written about it earlier.  OK, so lets forget the her basic premise is flawed, cuz she still might be right despite that.

Continue reading

Booting into single user mode with grub

I recently had a problem where one of the daemons run at startup would hang.  In order to disable this, I needed to boot into single user mode, and chkconfig the service off.

The key to booting into single user mode is the word ‘single’ on the kernel command line.

Heres the steps:

  1. Reboot the system
  2. At the grub screen, hit esc to stop the default boot sequence
  3. use the arrow keys select the kernel image you wish to boot
  4. type ‘e’ to edit the kernel image startup parameters
  5. on the screen use the arrow keys again to select the line with the startup parameters.  This should be the  the middle line, the one that starts with the word ‘kernel’.
  6. Type ‘e’ to edit this line
  7. append the word ‘single to the end of the line and type enter
  8. type the ‘b’ key to boot the kernel

16 Random Things About Me

1. The mechanism in the brain is that is supposed to disengage the mouth doesn’t always work with me. When I remember an embarrassing episode from earlier in my life, I often yell at my self about it, out loud, usually something like “Stop think so much!” or “Quit it.” I have Programming induced Turrette’s Syndrome.

2. I read incredibly fast. I started reading in kindergarten and have always devoured books. I was reading the full length Alexandre Dumas books in third grade.

3. I wore braces while wrestling in high school. My lips were routinely turned into chopped liver by them.

4. Music has been an incredibly strong force in my life. I was singing before I spoke. I started piano lessons in first grade (Thanks Mrs. Stephanski!). My great Uncle Ben started teaching me Saxophone in second grade. I sing out loud whenever I am in the car alone. I contemplated going to Berklee school of music. As a Junior and Senior at West Point I conducted the Jewish Chapel Choir.

5. I read Zen and the Art of Motorcycle Maintenance while in High School. No other book I’ve read has had more of an effect of how I interpret the world.

6. As a Plebe at West Point, I got into big trouble twice. The first time was because I had a sword for the medieval studies club in my locker in the trunk room. The second time was for drinking. My roommate had snuck a bottle of Jack Daniels into the Barracks. I had to shots, and threw them up.

7. When I was a three years old I made up a Superhero named “Strong Running Man”

8. I was really into Archery when I was in boy scouts. I had a recurve bow. My cousin and I were shooting arrows up into the air in New Hampshire. One got stuck in the trees, and fell to earth right in front of my father, missing him by a few feet. He broke the bow over his knees.

9. My first crush was when I was in nursery school. Her name was Elizabeth Lubin. I still don’t know how to spell her last name.

10. I compose music. I’ve written a few jazz and folk songs. I have written about 70% of the book for “The Princes Bride, the Musical.” It is an Operatta.

11. I spent my first two and a half years as a professional programmer doing Microsoft programming. My focus on Linux and Open Source programming comes from having been burnt by MS too many times.

12. When I was Lieutenant in the Army, I lived in a beach house on the North Shore of Hawaii. On certain days, when I was allowed to do the morning exercises (PT) on my own, I would often go snorkeling right behind my own house.

13. My favorite hobby is Rock Climbing. I have done more damage to my body by climbing with out doing injury prevention exercises than any other way. My favorite type of climbing is climbing cracks by jamming my hands and feet into the wall and camming them.

14. I was incredibly nearsighted as a kid. It killed my depth perception. It is one reason I never liked sports like Baseball or Basketball. I had LASIK about ten years ago, and my eyes have continued to get worse to the point that I need glasses full time again.

15. I have a ridiculous memory for quotes. I can watch a movie or TV show once and pick up a quote that I remember for years.

16. I grew up wandering in the woods. The thing I love most about being back on the East Coast (aside from being near to family) is the woods here. There is something about the deciduous forests and terrain gentle enough to let you walk just about anywhere while out in the woods that I find really recharging. I’ve recently taken up snowshoeing because I love being able to wander through the snow covered woods and walk anywhere.

Cool it with the Ayn Rand comparisons

No, we are not entering the time of Atlas Shrugged.  No, Obama’s plan to deal with the economic melt down is not the same thing as the various acts passed during Atlas Shrugged.  No, we are no about to enter a world dominated by socialism.

If you feel the need to drop out of society and move to a valley in Colorado, please feel free to do so.  I will be understandably jealous.

Continue reading

contracting

After  the dot com bubble burst, I worked as an independent contractor in software for a few years. This is extremely common in the field. Some companies will hire independents outright, where as many others make you go through contracting firms to mitigate risk. (There was a lawsuit regarding compensation and stock options at Microsoft that caused this, worth googling and reading about). I set up an LLC that I used for a couple of the projects. I want to record a few of the lessons that I learned.

I leanred that when figuring negotiating price, I needed to  remember to factor in Health Insurance, which is much higher for a single payer than for a member of a large organization. I had to pay both sides of payroll tax (roughly 15%) but you then could deduct half of that as a business expense. The math gets a little tricky, but I would say that I was paying about 5% more in taxes than I would have as a salaried employee. There are tax benefits: you can expense much more than you can as a full time employee.  Many of these additional costs to me would have been norne by the comapny that issued me a W2 if I had been a Full Time Employee.

Regardless of the setup between me and the company, I  treated it just like I was  a company, and separated out the money I earned as an LLC from the money I paid to myself as an employee.  Except for the times I had to work through a body shop that issued  a W2, I had to deal with paying  both state and federal taxes. I didn’t pay income tax directly out of your monthly pay, so I held on to the tax money for an average of 1 month an a half longer, which I could invest. There is a final accounting done at the end of the year.  There are books on this. I had a good accountant.

One thing I learned to watch is the length of the contracts. Once a contract ends, if I didn’t have another lined up, I went  without work, but was still paying the mortgage. It was up to me to fill in my own schedule.  I spent a good deal of the time working on my own software, and a lot of time cleaning the apartment.

Entangled Dependencies

Our LDAP Client has a wrapper for creating a persistent search.  In order to execute a persistent search, a polling mechanism has to call the client code with notifications of changes from the LDAP server.  This means a threading library.  The call looks something like this:

LDAPCLient->GetApp()->GetThreadPool()->ScheduleTimer(MakeFunctor(callback))

Here the call to GetApp is completely superfluos to the logic:  we should not care where the ThreadPool comes from.  Instead, LDAP client should either take a thread pool pointer in its constructor, or a thread pool should be passed as a parameter to CreatePersistentSearch.  I prefer to resolve all dependencies like this at object construction time.

GetApp throws an exception if it is called prior to a call to AppImpl::Init.  Init reads an XML based config file.  So our dependencies now include both the config file and the xml parser on top of the App object.  The LogObject and LogName are also initialized in the App.

What we are seeing here is how dependencies get entangled implicitly.  In order to reuse the LDAP client, or to create a Unit Test for it, I have to initialize an App object, which is far beyond the scope of LDAP.

Continuing on looking at the ThreadPool, I see that the AppImpl actually creates the ThreadPoolWin32 object by passing the config file view to it, and the config file view is used to fetch values for the state of the thread pool value by value.  Example:

_config->Get(“TaskMax”, &_maxWorkerThreads);
_minIOThreads = 1;
_config->Get(“IoMin”, &_minIOThreads);
_maxIOThreads = 2 * _maxWorkerThreads + 1;
_config->Get(“IoMax”, &_maxIOThreads);

The binding of the values to the object should be external of the constructor, as it is just one Initialization scheme.  What if we want to reuse this object and read the values in from a database, or from a different config file format?

The LDAP Client should have a field that is the ThreadPool base class.  For the Unit test, we could mock this out. Of course, maybe the persistent search itself should be its own class.