Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jun 022010
 

Disable APC auto recompile modified PHP files

Answer:

If you want extra performance boost for PHP/APC, you can tell APC not to auto recompile modified PHP files even they have changed. This can save APC for not to check the modification time of your script on every request.

To do so, edit your php.ini, and add

apc.apc.stat = 0

Restart your web server (e.g. Apache) to take effect.

Jun 012010
 

How to print out Perl opcodes?

Answer:

If you want to have a deep understanding on how Perl execute your statements, you can try the following:

# perl -MO=Concise -e ' print "foo\n" '

6  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
5     <@> print vK ->6
3        <0> pushmark s ->4
4        <$> const[PV "foo\n"] s ->5
-e syntax OK
May 302010
 

How to perform syntax check on a bash script?

Answer:

You can perform syntax check on a bash script, without actually running it using the following command:

# bash -n script.sh

But if your script contain execution of other program, bash will not try to run it, even if it does not exist, error of this type will not be returned.

May 292010
 

What is "The Zen of Python"?

Answer:

Try the following command in shell:

# python -c "import this"

And it will print out...

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!