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

Business Group Questions

A few questions to stimulate conversation for our business group.

  1. Have you recently read any thing that may be of interest to the group?
  2. Have you heard of anyone failing in business lately, what was the reason?
  3. Have you heard of any business thriving lately, what was the cause?
  4. Do you know of anyone that has lately done something worthwhile, what was it? Who has committed an error that we sho uld do our best to avoid?
  5. Is there anything at present that we may do to help mankind, the country, our friends or ourselves?
  6. Is there anyone you want to meet that the group can somehow arrange?
  7. In what ways can the group assist you in your pursuit of success?
  8. Do you have any ideas which would be a good fit for this group to execute?
  9. Do you have any other questions that you feel should be added to this list?

Some VIM Commands

Every once in a while I try to review some vim information to get additional practice with the editor. Today I reviewed file buffers, visual mode and markers. All very useful in editing files with vim.

File buffers are great when editing more than file.
:buffers
:b1 :b2 :b3
:bn :bp
:sbn :sbp

Visual Mode
In normal mode use v, shift-v or ctl-v (block edit)
Use >, <, r, c, d, etc.

Markers
In normal mode use ma, mb, mc, etc
Then use ‘a, ‘b, ‘c etc.

Windows
:sp, :open, ctl-Wn, etc.
ctl-w, ctl-w to switch windows
Buffer commands above come in useful here

Completion, Omni-completion
ctl-p, ctl-n to complete with words from file
ctl-x, ctl-o to use syntax completion
Very useful things in a text editor!