How to fix conflict of ui-router and karma

Share Button

When you use karma to do unit testing for angular application using ui-router module, you will likely get following error:

The part after “GET” depends on your setup of the application. The reason this happens is that there is a conflict of ui-router module and karma. The quickest fix is to defer  intercept of  urlRouterProvider by adding following to your unit test code:


Three layers dressing method to stay warm

Share Button

Thanks so much for icebreaker making such great infographic, especially some regions are suffering from historical cold weather in US.


Resolving “cannot connect to database” error of wordpress after upgrading from Ubuntu 12.04 LTE to 14.04 LTE

Share Button

I upgraded my server from Ubuntu 12.04 LTE to 14.04 LTE. But after that, I cannot access my wordpress site any more. This gave a headache for a whole night. After trying tons of methods, finally I figured it out how to resolve it. But still not sure what happened though. So my issue is I keep getting “cannot connect to database” error.

First of all, I tried to check if mysql is installed correctly, and see if I can log in mysql using root. The answer is yes. But strangely I cannot log in using the user name and password wordpress is using. I also checked mysql wp_* tables, and they are all there. So it must be something with user name and password. I basically tried all method on But no matter I access or or, I always get “cannot connect to database”.

I know it’s something wrong with my wp-config.php, but I couldn’t figure out why. So I tried following solution which worked eventually for me.

  1. I backed up old wp-config.php, and it will let you generate new wp-config.php.
  2. When I accessed, the initial setup screen showed up! I tried to setup database name, user name, password, database host and table prefix according to DB_NAME, DB_USER, DB_PASSWORD, DB_HOST and table_prefix variables in wp-config.php. But no luck, I still could not connect to database.
  3. Then I created new mysql user and password
  4. Then I repeated step 1 and 2. Magically it worked! Everything comes back!

It took me 3 hours 22 minutes.


Fix “There was a problem with the editor ‘vi’” on Mac

Share Button

I encountered this issue when I run

and vi opens up. If I input some comment, save and quit. I’ll get this error msg:

and commit will fail.

I think this is because some thing wrong with default vi installed on Mac. I verified by running

This means quit vi returns error code 1. I have no idea why this happen. But I tried with Vim and it doesn’t happen. So the solution is really simple, set default edit to something other than this problematic vi.

To find which vim you are using:

How to Get Better Sleep

Share Button

Optimizing your sleep depends heavily on three things: preparation (building good sleep habits), environment (tweaking your surroundings for optimal sleep), and timing (getting the sleep you need when you need it).

  • Preparation
    • Exercise regularly.
    • set a kinder, gentler alarm.
    • Ditch the alcohol, cut out the caffeine, and watch the cigarettes.
    • Cut back on screen time.
    • Meditate before bed.
    • Improve your evening ritual.
  • Environment
    • Make sure your bed is actually comfortable.
    • Adjust the temperature.
    • Filter out the light.
    • Cut out the distractions
  • Timing
    • An often overlooked way for people to optimize their sleep is to wake at the same time every day, or at least within the same hour. So rather than oversleep on off days, waking at the same time and then taking a nap allows the extra sleep without disrupting the normal wake/sleep schedule.
  • Get Help From the Experts