Categories
Kavoir & Whatever

How to train myself to sleep less?

Someone asked a question:

I have been trying to reduce how long I sleep so that I have more waking hours available. I have read this question, and this one but it does not really give an answer.

My question is whether I can train my body to sleep less. I currently have about 6.5 to 7 hours sleep per night. If I reduce that to 6 hours every night for the next two months, and then down to 5.5 hours then onward, will my body get adjusted to the new sleep pattern?

When I was 22 and just graduated from college I had the same idea as you do now. As a workaholic who’s passionate about his work (software development) and very determined about his goal, I would keep working until late night and get up very early. The average sleep I got was about 5 hours per day, EVERYDAY, for 5 years, even on weekends. There’s always so much that I could do to make my projects better thus making more money.

For the first few years it was all good and rewarding because I was young and I had the power and energy to keep it going, even on very stressful times. But eventually I started noticing changes with regards to my body:

  1. I started going to doctors more often than my peers.
  2. My vision started to deteriorate, albeit slightly.
  3. I started losing hair.
  4. I started to forget stuff which shouldn’t be an issue before.
  5. Last but the most important, when you sleep less for very long time, eventually you’ll actually sleep less because it takes longer for you to fall asleep and you easily wake up.

So for a short answer, yes you can train your body to sleep less, but do make sure it’s not very long as to years so you can easily recover. It may not be obvious but sleeping less than you body needs DOES undermine your health. However the amount of sleep everybody needs may vary because we are designed differently in genes.

For a long answer, no, sleeping less wouldn’t let you get more things done in the long term. Everything has a price. It’s actually against productivity rather than for it. When I look back how I went through these years in retrospect, I could have not pushed myself that hard but still accomplish the same results. Productivity is about getting the most out of time rather than getting the most time. Lots of people have got plenty of time in their life, even more than they need, still they blow it. In fact, when I was in college, some of the top performing students actually sleep more than the average.

So sleep as much as you want. Time enjoyed is NOT wasted. Sleep is beautiful. Don’t waste it for some stupid things that you need done!

The Road goes ever on and on
Out from the door where it began.
Now far ahead the Road has gone,
Let others follow it who can!
Let them a journey new begin,
But I at last with weary feet
Will turn towards the lighted inn,
My evening-rest and sleep to meet.

–The Return of the King, Book VI, Chapter 6

Categories
Programming Tips & Insights

Shortcut Keys in Zend Eclipse for PHP Developers (PDT)

At any time, press:

Ctrl + Shift + L

For a list of available shortcut keys defined in your Zend Eclipse PDT.

Go:

Window > Preferences > General > Keys

To edit the shortcut keys. Or simply press Ctrl + Shift + L twice.

For Zend Eclipse PDT to instantly show a tool tip hint of what the parameters of a function / method are so you don’t have to look up the original definition, just place the cursor in the parameters parenthesis and press one of them:

Alt + ?

Alt + Shift + /

Ctrl + Shift + Space

Which is defined under the title “Context Information” when you press Ctrl + Shift + L.

If a function or method name is elusive to you, type the beginning part of it and press:

Alt + /

Ctrl + Alt + /

And PDT would try and auto-complete it for you. It is defined under the title “Word Completion” when you press Ctrl + Shift + L.

Categories
PHP Tips & Tutorials Programming Tips & Insights Web Applications & Online Software

4 Tips for Zend Studio 8 (Eclipse)

I coded a lot in Zend Studio 5.5.1, the gold old version that’s insanely popular because it made it so easy to code in PHP. As PHP evolves, ZS 5.5.1 gradually falls behind of the edge and it simply becomes imperative that you switch to the latest version of Zend Studio, the 8.

The IDE is built on Eclipse, which I have never used before. It’s great but one still needs some time to learn the curves before he or she can jump in and swim like a whale. Today I gave it a test drive and have some tips to share with you when you are just starting out with Zend Studio 8.

1. Change Default Character Encoding

Before you create your project or editing any existing PHP files, you may need to change the default encoding of the Zend Studio Workspace, or make sure it is what you usually work in.

By default, the encoding is that of the container (your operating system). I’m using a Chinese Windows 7 so the default encoding is GBK and it is everything but good because I primarily develop English projects.

For North America users, the default encoding should be ISO-8859-1. If you open up a file that’s encoded in UTF8 without changing the encoding accordingly, you may end up screwing up the file. And another victim.

To change the default encoding of Zend Studio: Windows –> Preferences –> General –> Workspace –> Text file encoding, switch to “Other” and select the encoding you normally use.

2. Display Function Parameters Hint on Demand

In 5.5.1, function parameters hint is automatically displayed when you place the cursor in the parentheses. However in 8, the hint is only automatically shown after you immediately finish typing the function name. When the focus moves away or you click anywhere else in the window, the hint disappears and if you don’t know the correct shortcut keys, you wouldn’t be able to get it back.

After a few searches, I found out the key combinations to get the parameters hint re-appear: Alt + Shift + /

Some pages say it’s Ctrl + Shift + Space but it didn’t work out for me. Maybe it’s a version thing?

3. Display Potential Function Candidates / Auto-complete Function Names

Along with the previous tip, this one is pretty important in modern IDE because they are essential in boosting one’s coding productivity. Can’t live without them.

When you are typing the function name, Zend Studio would guess what you mean and display a list of possible candidates for you to choose from.

If you want it to appear again, just place the cursor on the function name and use Alt + / to make Zend Studio makes a guess again.

4. Display All Shortcut Key Combinations

You can use a lot of shortcut keys in Zend Studio 8 to make things happen quickly and intuitively, just press Ctrl + Shift + L to bring up the key map to see the full list. Here’s a list of the commonly used commands:

zend studio 8 key assist - commonly used commands