Saturday, April 30, 2011

Google Reader Keyboard Shortcuts

 
Google Reader Keyboard Shortcuts:
j/k: next/previous item
space/ + space: next/previous item or page
n/p: scan down/up (list only)
o/enter: expand/collapse (list only)
s: star item
+ s: share item
v: view original
t: tag item
m: mark item as read
r: refresh
u: toggle full screen mode
+ a: mark all as read
1: switch to expanded view
2: switch to list view
+ n/p: next/previous subscription
+ x: expand folder
+ o: open subscription or folder
g then h: go home
g then a: go to all items
g then s: go to starred items
g then t: open tag selector
g then u: open subscription selector


for more:
http://www.google.com/support/reader/bin/answer.py?hl=en&answer=69973&ctx=cb&cbid=-1vbaz66dtlhu5&cbrank=4

Friday, April 29, 2011

If programming languages were religions...

http://www.itu.dk/courses/BPRD/E2010/religion.txt
Monday, December 15, 2008
If programming languages were religions...
By amz at 14:52

C would be Judaism - it's old and restrictive, but most of the world
is familiar with its laws and respects them. The catch is, you can't
convert into it - you're either into it from the start, or you will
think that it's insanity. Also, when things go wrong, many people are
willing to blame the problems of the world on it.

Java would be Fundamentalist Christianity - it's theoretically based
on C, but it voids so many of the old laws that it doesn't feel like
the original at all. Instead, it adds its own set of rigid rules,
which its followers believe to be far superior to the original. Not
only are they certain that it's the best language in the world, but
they're willing to burn those who disagree at the stake.

Friday, April 15, 2011

Bruce Lee’s Top 20 Tips for Living a Successful Life

http://www.wakeupcloud.com/bruce-lee-successful-life/

Bruce Lee Statue in Hong Kong
When I grew up, Bruce Lee was one of my biggest role models, and he still is.
He accomplished more during ten years than most people do in a lifetime. So I decided to gather Bruce Lee’s most impactful quotes in one place.
The quotes below are what I believe it takes to live a successful life and have success in life. These quotes will inspire, motivate, and encourage to go after your dreams.
With all that said here are Bruce Lee’s top 20 tips for living a successful life.

1. Apply What You Learn

“Knowing is not enough, we must apply. Willing is not enough, we must do.”
How many people do you know that read a lot of books and spend a lot of time buying courses, but never apply the knowledge they learn?
You may even notice these tendencies in your life. It’s hard to take action and apply what you learn, because we’re all afraid of failure, and taking action can be paralyzing from time to time.
However, success in life doesn’t happens until you use the knowledge that you have inside of you. Most of us have exactly what we need to get to our goals, but we make excuses not to even get started.

2. Learn, Simplify, and Use

“Absorb what is useful, Discard what is not, Add what is uniquely your own.”
It’s all well and good to learn from others, but it’s not until you take action that you discover what works and doesn’t.
When you discover what doesn’t work, you simply discard it and keep going. When you keep moving forward, you will create your own path.
Living a successful life is all about experimenting and trying new things. The more things you try, the closer you will get to true success.

[IMG]Isn’t it ironic…

Isnt it ironic

Thursday, April 14, 2011

Farey sequence

http://en.wikipedia.org/wiki/Farey_sequence

http://www.cut-the-knot.org/blue/Farey.shtml

Autocompletetion in the Python console

Hans tells us how to have autocompletion in the Python console:

"
It is handy to be able to tab-complete properties of python objects at the python prompt. Nowadays, I am always using IPython, a significantly enhanced interactive python console which is really worth the installation. (It helps you with completion, indentation, syntax highlighting, macros, input/output caching, session management, improved history, debugger, and tracebacks. And more. ;-) )
However, I find it interesting to note that it is possible to have completion in the standard python console (if compiled with readline, which it really should be)! The following code can be used to activate it:
# .pythonrc.py
import readline, rlcompleter
readline.parse_and_bind("tab: complete")
Put this code in a file ~/.pythonrc.py or similar, and use the variable PYTHONSTARTUP to point python to it! (I.e., I put "export PYTHONSTARTUP=$HOME/.pythonrc.py" into my shell environment setup.)
Now, go check out IPython. ;-)
"

http://kogs-www.informatik.uni-hamburg.de/~meine/python_tricks

Friday, April 8, 2011

[IMG] Beautiful Dance Moves

Beautiful Dance Moves

4846_5664_400

Beautiful Dance Moves

"

The first 20 years of Linux [video]

http://www.omgubuntu.co.uk/2011/04/the-first-20-years-of-linux-video
As someone who is still “relatively” new to Linux compared to many - having jumped aboard the Tux train at Ubuntu 7.10 – it’s all-to-easy for me to remain unaware of the history and legacy upon which the operating system I spend my days writing about builds upon.

That’s why I love following video from the Linux Foundation which distils 20 years of Linux history into 3 short minutes. It melds the interesting and informational, starting at how Linux came to be and arriving at today where the virtual dominance of Linux in computing – both seen and unseen – is utterly impressive in light of its humble beginnings from a bedroom in Helsinki, Finland.

Gushing aside, brew a coffee, grab a (preferably chocolate) biscuit and prepare to want to punch the air…

Tính căn bậc 2 và số e

sqrt(2) = [1;(2)] tức là:

√2 = 1 +
1
2 +
1
2 +
1
2 +
1
2 + ...

tương tự sqrt(23) = [4;(1,3,1,8)]

Đặc biệt hơn, số e = [2; 1,2,1, 1,4,1, 1,6,1 , ... , 1,2k,1, ...]
hay 



Research when try to slove PE65

Wednesday, April 6, 2011

Max recursive depth

Max recursive depth

Khi viết hàm kiểu đệ quy, nếu gọi đệ quy quá nhiều lần sẽ bị tràn stack và dẫn đến kết quả trả về sai(thậm chí là crash chương trình). Số lần tối đa gọi đệ quy  phụ thuộc vào độ lớn của stack. Trong Unix/Linux, có thể sử dụng lệnh ulimit -a trong terminal để xem stack mà OS cấp cho người dùng là bao nhiêu.(có thể thay đổi được size stack!)

VD:
hvnsweeting@HVNBBZ:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 20
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192 => 8 MB
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

VD với hàm tính giai thừa viết theo kiểu đệ quy bình thường, khi gọi để tính factorial(1000) đã báo max recursive depth exceeds (trong Python)

Vậy khi viết chương trình, nên tránh viết dưới kiểu đệ quy mà hãy viết theo kiểu tuyến tính để tránh lỗi này xảy ra hoặc chỉ viết đệ quy cho các hàm gọi ít lần.

Tuesday, April 5, 2011

C: array and function

int factorial[10] = {1,1,2,6,24,120};

int printfFac(int i)
{
    printf("%d ",factorial[i%10]);
    return 0;
}

    int
main ( int argc, char *argv[] )
{
    printfFac(5);

    return 0;
}       
~~~~~~~~~~~
Quick note:
đoạn code trên chạy nghĩa là hàm printFac() có thể đọc được nội dung trong array khai báo ngoài nó khi mà array factorial[10] ko phải là argument của printFac().

Monday, April 4, 2011

Memoization

Not to be confused with memorization.

Memoization là một kỹ thuật tối ưu trong lập trình,Nó đổi không gian lưu trữ để giảm thời gian tính toán. Kỹ thuật này lưu trữ lại kết quả trả về của hàm và dùng lại vào lần gọi sau thay vì tính lại, bởi vậy sẽ tốn nhiều không gian nhớ hơn nhưng sẽ nhanh hơn.
Dùng khi viết hàm theo kiểu đệ qui.

VD: Ta có 5! = 120. Nếu muốn tính 6!, ta sẽ phải tính 6! = 6 * 5!.Thay vì tính lại 5!, ta lưu kết quả 5! đã tính trước đó (vào 1 mảng) rồi chỉ việc lấy giá trị của 5! ra nhân với 6.

......
Cache....

Memoization
Found this when solved PE74.


http://en.wikipedia.org/wiki/Memoization

Saturday, April 2, 2011

Things to avoid in C/C++

avoid gets() -> use fgets()

Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security. Use fgets() instead.


http://www.gidnetwork.com/b-56.html
avoid fflush(), scanf()
http://www.gidnetwork.com/b-57.html