Autotest keeps running

I had an issue with autotest where the tests would just keep running, even when all the tests passed. After doing some searching I found the following code helpful from this post:

Put this in your ~/.autotest, leave out the growl line if you’re not using that.

require 'autotest/growl'

Autotest.add_hook :initialize do |at|
  %w{.git vendor rerun.txt}.each {|exception| at.add_exception(exception)}
end

When I initially tried this code it didn’t work. To figure out why autotest thought it had to keep running I ran the following:

find ./ -cmin -1 

This will show you any files that changed in the last minute. I had to add db, log, system and public to the list above. Depending on your configuration you might run into other files or folders that need to be excluded.

Before You Bet, Understand Expected Value!

With the upcoming super-bowl and all the betting surrounding it, you should understand expected value before you make any bets.

Informally, the expected value can be interpreted as the long-run average of the results of many independent repetitions of an experiment. (from wikipedia)

By using expected value as a guide over your life, you should come out ahead.

How to calculate expected value:

Say you have two options, one is to bet in a superbowl grid and the other is to bet on a 0-9 pool. To calculate the expected value of each do the following:

Expected Value = – (chance of losing * amount lost) + (chance of winning * amount won)

Ex. -(.99 * $100) + (.01 * $10,000) = $1 (Superbowl Grid)

(The above is simplified as with the grid you have a .01 chance of winning each quarter and for the half)

Ex. -(.9 * $100) + (.1 * $1,000) = $10 (0-9 pool)

Which would be the better choice?

In most decisions in life you would prefer the expected value be more than the amount at risk, this rarely happens with betting and is the reason the house always wins.

Issue using insert_after/before “ActionDispatch::Static”

We are currently building a new product on Rails 3 with a couple custom middleware rack apps. Everything is working great on development and we’re progressing nicely. Today I decided to start setting up the production environment and the following error popped up:

No such middleware to insert after: "ActionDispatch::Static"

I had this in my config/application.rb:

config.middleware.insert_after('ActionDispatch::Static', '::API::Throttle')

I received this error while trying to run rake or startup unicorn. After looking around trying to figure out what I was doing wrong I discovered this in the production config.

config.serve_static_assets = false

Essentially what this does is remove “ActionDispatch::Static” from the rails middleware stack. I had no idea that I could not rely on that being there.

Solution, use insert_before ‘Rack::Lock’ instead:

config.middleware.insert_before('Rack::Lock', '::API::Throttle')

Hope this saves someone some time!

Stop Blaming the Employer!

Over the past few days I’ve had several people tell me that business is taking advantage of employees. When recessions hit, the employer exploits the situation in his favor, to the employees’ detriment. While this may be the case in some situations I don’t think it is in the majority of cases.

The employer may be an easy target in this situation, but the anger and frustration is misguided. The ability of an employer to pay an employee stems from demand for the employers product. If the demand shrinks, then his demand for employees with the skill to produce the product shrinks. With shrinking demand comes shrinking revenue. Without revenue to pay the bills, including payroll, expenses have to be reduced. There really is no other choice here if the business wants to remain viable.

There are several reasons why demand might shrink. There are two overwhelming reasons in the current situation that I see. First is that consumers (including businesses) have reduced or are reducing their spending, this directly translates into reduced demand. The second is globalization is providing real competition for technology related skill sets. If you can’t differentiate yourself and provide real value it is hard for any employer to justify regular salary increases. Remember the employer must compete with other companies that can and will take advantage of these cost differences.

Another cause of reduced revenue is the inherent idea of consumers to want to buy the cheapest items possible that satisfies their need. With companies competing for the limited spending, this directly translates into less revenue for the company that you are buying from. The reduced revenue means reduced employment, but also means the most efficient business will be successful and will add jobs once demand increases. In a world of global competition keep this in mind when you think that your employer is not being fair. He is working in a world where to survive he has to make the best economic decisions to keep the business operating and competitive.

What can you do to change this and improve your situation? Learn new skills that makes your company more competitive. If you can show that your new skills bring value to the company then most employers will be willing to share that with you (remember it may take some time to actually realize revenue from your new skills). If they aren’t then maybe it is time to find a new employer. You can bring value by selling jobs, learning new skills that are in demand by current clients or by increasing efficiency and thereby reducing costs. If you are not willing to do anything then you really only have yourself to blame.

If you are feeling like a victim of the current recession my advice is to get up and do something about it. Learn something new, at no time in history has there been such valuable information available for free. Help make your company more competitive and you will come to realize that taking action is a much better path than dwelling on your perceived misfortune.

Milton Friedman on Inflation

From “Free to Choose”, chapter 9

Below are Milton Friedman’s five simple truths regarding inflation.

  1. Inflation is a monetary phenomenon arising from a more rapid increase in the quantity of money than in output (though, of course, the reasons for the increase in money may be various)
  2. In today’s world government determines – or can determine – the quantity of money
  3. There is only one cure for inflation: a slower rate of increase in the quantity of money
  4. It takes time – measured in years, not months – for inflation to develop; it takes time for inflation to be cured.
  5. Unpleasant side effects of the cure are unavoidable.

The United States has embarked on rising monetary growth four times during the past twenty years. Each time the higher monetary growth has been followed first by economic expansion, later by inflation. Each time the authorities have slowed monetary growth in order to stem inflation. Lower monetary growth has been followed by an inflationary recession. Later still, inflation has declined and the economy has improved. So far the sequence is identical with Japan’s experience from 1971 to 1975. Unfortunately, the crucial difference is that we have not displayed the patience Japan did by continuing monetary restraint long enough. Instead, we have overreacted to the recession by accelerating monetary growth, setting off on another round of inflation, and condemning ourselves to higher inflation plus higher unemployment.

We have been misled by a false dichotomy: inflation or unemployment. That option is an illusion. The real option is only whether we have higher unemployment as a result of higher inflation or as a temporary side effect of curing inflation.

In my view, we have and will have higher unemployment as a result of higher inflation. I think we are currently in the economic expansion from monetary growth. Based on comments earlier in the same chapter, increased monetary supply takes six to nine months to work its way through the system to increase economic growth and employment. Another 12 to 18 months elapse before the price level appreciates and inflation occurs or is speeded up.Given that a sharp increase in money supply started mid 2008, that would point to first quarter 2009 impact. This may be consistent with the above as we saw a market bottom in March 2009. So that would point to the end of the 1st quarter 2010 to the 2nd quarter 2010 to start seeing increased inflation.

Let’s see what happens.

Four Essential Lessons to Pass Down

If you could boil down everything you know into something concise that you would like to convey to the younger people in your life, what would you say? Below are some of my thoughts.

First, would be “Do unto others, as you would have done to yourself”. The golden rule. With this, you don’t need any other religion or morality.

Second would be to exercise. Exercise has so many benefits. Besides the obvious fitness, there are the self esteem and confidence benefits and I believe a strong relation to drive and intelligence.

Third would be to read. Read to learn and understand. Not romance novels and other useless crap, but the classics, history, psychology, economics. Learn the meaning of words, learn logic and clear thinking.

And lastly, question everything. Don’t take anything at face value, even and especially if its a view passed down from your parents. If you don’t understand something, seek to understand it. And don’t rely on others to teach you, teach yourself what you need to know to understand your questions.

I feel that if you follow these four simple to say, but not so simple to follow rules, you will have a significant advantage over a majority of your peers. In a global and ever more competitive world it might be a required edge.

Business Value

Last night we went to the BMA Awards dinner, the keynote speaker was Keith Pigues. He gave a very good speech about delivering value. Here are a couple of the key points that I wanted to remember.

The top priorities for marketing companies should be to either increase their clients revenue or decrease their costs. This brings real value to their clients.

Don’t make up a need, build a product for that need and then try to sell that product. This is backwards! Figure out the need first, then create the product that fulfills that need. If it creates real value, then you will have no problem selling it.

Larger organizations are moving toward partnering with service providers so they have some “skin in the game”. This would mean setting some kind of base cost and then using a bonus structure that was based on specified measurements of the company’s performance. Seems like a good idea, but how does the service provider evaluate the client and all their other vendors to ensure they are pulling their own weight?

Language Mismatch

One of the reasons that I believe communication between developers and non-developers is difficult is because developers must work in a world of specifics and details whereas a non-developer can casually neglect those details without even knowing they’ve been neglected.

For instance a non-developer says we need to allow users to log into this system. Easy enough, non-developer thinks his part is done. The developer looks at this requirement and thinks, is it a single users system? Will people register for this system? Is htaccess acceptable? Should it be a web based login? Etc. etc.

The above example is overly simplified and does not entirely show the mismatch. The only way to improve communications between the two groups is to ensure both groups understand how the other thinks. Without this understanding there will be tension that doesn’t necessarily need to exist.

The non-developer has most likely been educated in a less scientific and more abstract manner. This leads the non-developer to neglect details that are essential to any system designed to run on a computer that has to understand all paths through the system.

The developer on the other hand has to think about and understand all these paths to be able to build a system that fully functions. Always thinking about and contemplating whether or not the requirements are complete enough and whether they conflict with each other.

I believe the only way to resolve this mismatch is through educating both parties to be more understand of how the other must think. With this education maybe each party can move toward the others way of thinking enough to make the resulting system that much better.

USB Linux Install

Create usb net inst device for x41 tablet. Because of conflicts with SATA and the usb cdrom I couldn’t get an install to work with the usb cdrom. I could get the installer to start, but it wouldn’t detect the hard drive no matter what I did. I tried loading t he drivers manually, but nothing worked. I decided to try my luck with an old Lexar Jump Drive (256M). It worked! See my notes below.

  • Partition usb key (/dev/sda) – cfdisk /dev/sda
  • Create msdos filesystem on partition – mkdosfs /dev/sda1
  • Run syslinux on partition – syslinux /dev/sda1
  • Mount the partition – mount /dev/sda1 /mnt
  • Copy the files from here to /mnt
  • Copy the net inst iso to the partition -
  • Run lilo on the drive to create MBR – lilo -M /dev/sda
  • Unmount the partition – umount /mnt
  • Try your luck!

Create Image over network in Linux

Create image of hdd over network with linux

Copy Image over network

# on receiving machine
nc -l -p 9000 | dd of=tablet.sda
# on sending machine
dd if=/dev/sda | nc 10.1.0.3 9000