How does Elon Musk study?

by Yang Yang on December 13, 2014

Someone asked this question on Quora. I wrote an answer.

How does Elon Musk study?

People tend to overstate their feelings about somebody. They are usually not as good as we say they are nor as bad as we say they are.

Elon is smart but he’s not so much so unless he has a world-class team backing him up. And that takes money, which comes from his risk-taking business endeavors rather than his ability to study effectively, albeit it definitely adds up.

But still. It’s not about how fast / effective you study but about knowing exactly what to study against a very specific problem or well defined goal.

Elon has a definitive goal that he wants to achieve. This is what distinguishes him from others. Most study for the sake of knowledge, while he studies to solve problems.

This is the reason why it seems he’s more effectively in studying because he solves more problems than we do with the same amount of study.

80% of knowledge and techniques are cool but useless. Elon only spends time for the other 20% that are actually helpful in achieving his goals.

He does the right study in the right amount just enough at the right time just when the problem arises. Anything more is a waste.

Another reason I think why Elon studies well is he smartly modularizes his ultimate goal in smaller milestones that are easier to achieve one by one. Through consistent positive feedback, he has been able to stay motivated all the way, which is another boost to his study efficiency.

{ 0 comments }

It became a total mess when I selected the entire root directory of my project and accidentally clicked Source > Format in Zend Eclipse PDT. All the files were instantly re-formatted and saved in a manner I wasn’t comfortable with and there didn’t seem any easy way to undo these changes that had been applied across nearly a hundred files in different folders.

They definitely should have prompted up a dialog box asking the developer’s confirmation. They probably will in future but for now, I need to do something to prevent this from happening again.

Disable Source > Format

First we will disable / hide this menu item or we will probably accidentally click on it again. Without any prompt nor confirmation, PDT simply goes on formatting the selected items silently. When you are in a single file that would be fine cause’ you just use Ctrl + Z to undo the change, however if you are selecting an entire directory or the entire project, this command would go ahead and format ALL the files under it and automatically SAVE THEM all onto the hard drive. The next thing you find yourself doing is opening and reverting each and every one of the files one by one.

Enough talk. To disable this menu item:

Window > Customize Perspective > Menu Visibility > “Source” > “Format” (disable this) > OK

Disable Ctrl + Shift + F

We should also disable this short cut keys combination which can also be inadvertently treaded on. Go to:

Window > Preferences > General > Keys > Select all “Format” entries and click “Unbind Command”

Done. Now the only way to format a page or a selected portion or a resource / item in PHP Explorer is to right click on the target and select Source > Format.

{ 0 comments }

When you copy and paste code into Zend Eclipse PDT they will probably be automatically indented and not in the original manner. It may be annoying sometimes. To disable this behavior:

Window > Preferences > PHP > Editor > Typing > When pasting “Adjust indentation”

Just disable the option.

{ 0 comments }

In addition to necessary indexes and proper SELECT queries (only select needed columns), for wide tables, 2 basic tips apply well:

  1. Define your column as small as possible.
  2. Avoid using dynamic columns such as VARCHAR or TEXT as much as possible when you have large number of columns per table. Try using fixed length columns such as CHAR. This is to trade off disk storage for performance.

For instance, for columns ‘name’, ‘gender’, ‘age’, ‘bio’ in ‘person’ table with as many as 100 or even more columns, to maximize performance, they are best to be defined as:

  1. name – CHAR(70)
  2. gender – TINYINT(1)
  3. age – TINYINT(2)
  4. bio – TEXT

The idea is to define columns as small as possible and in fixed length where reasonably possible. Dynamic columns should be to the end of the table structure so fixed length columns ALL come before them. MySQL would then have a better time predicting the position of a column to perform select or update, otherwise it would have to read through the entire row byte by byte to find it.

It goes without saying this would introduce tremendous disk storage wasted with large amount of rows, but as you want performance I guess that would be the cost.

Another tip is as you go along you would find columns that are much more frequently used (selected or updated) than the others, you should separate them into another table to form a one to one relationship to the other table that contains infrequent used columns and perform queries with less columns involved.

{ Comments on this entry are closed }

<Files *.php>
    Order Deny,Allow
    Deny from all
    #Allow from 127.0.0.1
</Files>

<Files index.php>
    Order Allow,Deny
    Allow from all
</Files>

The 2 <Files> directives must be in the exact same order as above.

{ Comments on this entry are closed }

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]

Yeah, that’s it. So:

  1. /path/dir/ is redirected to /path/dir
  2. /path/dir/?a=1&b=2 is redirected to /path/dir?a=1&b=2

{ Comments on this entry are closed }

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.

{ Comments on this entry are closed }

The default array() indentation of Eclipse for PHP Developers when you create an array seems to be 2 tabs which I think are too much. To reduce it to just 1 tab:

Window => Preferences => PHP => Editor => Typing => formatter preference page => Edit… => Indentation => Default indentation of array initializers

Or

Window => Preferences => PHP => Code Style => Formatter => Edit… => Indentation => Default indentation of array initializers

To change the default indentation for wrapped lines:

Window => Preferences => PHP => Code Style => Formatter => Edit… => Line Wrapping => Default indentation for wrapped lines

{ Comments on this entry are closed }

When I encounter the incorrect key file for table error, it’s almost certainly because the disk is full and MySQL can’t write to the tmpdir. The solution is simple, just move tmpdir to another partition with enough disk space.

Open my.ini and change tmpdir to another directory with enough disk space. Restart MySQL and that should do it.

However on Windows, such as for WAMP, you need to make sure you use slashes (/) rather than backslashes (\) in the path for tmpdir in my.ini, or it would be this error and mysqld would simply refuse to start:

InnoDB: Error: unable to create temporary file; errno: 2

{ Comments on this entry are closed }

How to train myself to sleep less?

by Yang Yang on February 19, 2014

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

{ Comments on this entry are closed }