Wednesday, December 14, 2011

Subnet

Host (ISP): 151.151.0.0/25
First subnet: 151.151.0.128 ! why not 151.151.0.0? Because it assigned to Host(ISP) it is not a subnet.
2nd: 151.151.1.0
...

Host range: 1st: 151.151.0.129 - 151.151.0.254  (255 is Broadcast)
151.151.0.1-151.151.0.126 are belong to 151.151.0.0.


Tuesday, December 13, 2011

Schedule tasks on Linux using crontab

The power of computer is capability of doing thing automatically.  So let auto everything you can. On Linux, using crontab is a must essential knowledge! ~HVN~

If you've got a website that's heavy on your web server, you might want to run some processes like generating thumbnails or enriching data in the background. This way it can not interfere with the user interface. Linux has a great program for this called cron. It allows tasks to be automatically run in the background at regular intervals. You could also use it to automatically create backups, synchronize files, schedule updates, and much more. Welcome to the wonderful world of crontab.

Crontab

The crontab (cron derives from chronos, Greek for time; tab stands for table) command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. To see what crontabs are currently running on your system, you can open a terminal and run:
sudo crontab -l
To edit the list of cronjobs you can run:
sudo crontab -e
This wil open a the default editor (could be vi or pico, if you want you can change the default editor) to let us manipulate the crontab. If you save and exit the editor, all your cronjobs are saved into crontab. Cronjobs are written in the following format:
* * * * * /bin/execute/this/script.sh

Sunday, December 11, 2011

Fixbug ko mở được biểu tượng "computer"

Nếu máy bạn gặp phải lỗi :
Nautilus cannot handle "computer" locations.
khi bấm vào biểu tượng computer. Đi kèm là các triệu chứng : không auto mount USB và CDROM. Cách fix như sau:
bạn tạo một thư mục /usr/local mới rồi khởi động lại máy. Câu lệnh dưới backup thư mục cũ vào tạo thư mục mới:

sudo mv /usr/local /usr/local.old
sudo mkdir /usr/local


Friday, December 2, 2011

Because It’s Fun!

Twelve years ago, computers were a mystery to me, but a friend of mine showed me how I could just go down to the computer parts store, pick out a motherboard, CPU, RAM, hard drive, power supply, &c., and put it together myself. It was so empowering! Those mysterious black boxes that our lives depend on were one step less mysterious.
I learned how to download Linux and install it myself for free — then, FreeBSD and OpenBSD. Then, I was building my own servers. Now, the whole web server/Internet thing was less of a mystery. This was, again, fascinating and empowering.
Ten years ago, I was the founder/owner/CEO of a music distribution company that grew from just me to 85 employees.
As the company grew, I enjoyed building all of the office PCs and web servers myself. I enjoyed setting up the same FreeBSD distribution for everyone, and writing shell scripts to automate the installation of everything. It was a fun challenge, and I’d often stay until midnight setting these things up, totally “in the zone” and loving it.

Friday, November 18, 2011

Stay hungry, stay foolish!

lựa chọn là điều vô cùng khó khăn...
muốn mình không tầm thường, muốn mình đam mê mà khó tìm ra sự thật...
chọn cái gì trong web-desk-mobile, lập trình hay quản lý, IT hay not IT...

con người ta do dự, đắn đo lựa chọn chỉ vì họ không dũng cảm đi đến cùng lựa chọn của mình. Sao phải nghĩ nếu là web/desk/mobile lập trình hay quản lý, IT hay NOTIT mà ở đó mình đều là chuyên gia? lo lắng điều gì? Mình vẫn lo lắng nó không hợp với mình => thật là vớ vẩn. Việc gì cũng có cái hay của nó, cứ đứng ngoài nhìn vào cái hay thì ai mà chả thich...


Nếu như kiến thức học ở các thầy không nhiều thì những câu chuyện cuộc đời thầy kể lại khơi nguồn cảm hứng mạnh mẽ cho sinh viên. GS ngày còn trẻ, ông muốn học ĐTVT, nhưng rồi bị bắt đi học Toán. Và giờ thì ông là GS Toán. Không cần biết bạn làm gì, chỉ cần làm điều đó 1 cách say mê và đến cùng thì ngôi sẽ ra ngô, khoai sẽ ra khoai , củ nào ra củ nấy.

Đơn giản chỉ là pick 1 cái và "just go with it", đến tận cuối con đường.
Mãi đắn đo chẳng tới đâu xa được.


IT or notIT
Web-Desktop-Mobile
Programming - Sysadmin - Multimedia
Windows or Linux

cắt giảm reading-list, force to main task!
Stay hungry, stay foolish!

Pragmatic Thinking: Novice vs Expert

Recently I started reading Andy Hunt's fine book "Pragmatic Thinking And Learning." Hunt is notorious for writing books which offer practical, insightful advice in which developers can apply to their work on a daily basis.  His most famous book is "The Pragmatic Programmer", widely considered one of the top agile programmer books of all time. Even after reading the book 7 years ago, I still refer to it a few times a month. My colleagues and I bring up the "broken window" theory, or often throw out the phrase "Don't Assume, Prove it," sometimes to the chagrin of the unfamiliar. :)

The Book

Pragmatic Thinking and Learning is a different type of book, however. It explores the human mind and how it relates to learning and cognitive thought. To my surprise, it is very well researched and touches on psychology and neuroscience. Hunt brings the concepts home by relating them to the software industry and the toils and travails of an agile developer.

Sunday, November 13, 2011

Vim as hex editor

vim -b datafile
:set binary
:set display=uhex
g CTRL-G
234go
:%!xxd
:%!xxd -r

List of tools for developing on Linux

 General:
make Utility to maintain groups of programs with compiling/linker directives
imake Utility to generate Makefiles from a template.
GNU autoconf Tool used to generate configure script. Requires GNU m4.
gHex Binary Editor and Viewer
beav Binary Editor and Viewer
od dump files in octal and other formats. od -c will try to dump everthing as ascii.
xxd make a hexdump or do the reverse
strings Print the strings of printable characters found in a file.
install copy files and set attributes (ginstall)
m4 Macro language for builing configuration files
objdump display assembler information from object files
nm display symbol table from an object file
readelf Displays information about ELF format object files.
ar Create, modify, and extract from archives
ranlib Generate index to archive
ldconfig determine run-time link bindings
ldd Print shared library dependencies for an executable
(i.e.: ldd `which xpdf`)
GNU libtool Used to generate shared libraries.
ipcs Report interprocess communication facility status for queues, shared memory, semaphores
iprm Remove queues, shared memory, or semaphores

more
http://www.yolinux.com/TUTORIALS/LinuxTutorialSoftwareDevelopment.html

Saturday, November 12, 2011

PyGTK and WxPython

1. PyGTK - GTK+ for python
GTK+ 2.0 work well but it will end of support soon.
GTK+ 3.0 use GObject) is a painful tookit when you try to install it.
May be it will be easier with higher Ubuntu version (I'm using 10.10)
Leave GTK+. Start to hate GNOME

2. WxPython
trying...

Cannot find install-sh, install.sh, or shtool ...

Painful  GTK+3.0 =.=

fix title error when configure py2cairo 
$ libtoolize --force
$ aclocal
$ autoheader
$ automake --force-missing --add-missing
$ autoconf
$ ./configure

Friday, November 11, 2011

Why so lazy?

I found that many useful things take very short time to learn.
But why I hadn't done that before?
So lazy!

2 days ago, XML looks like some alien-thing to me, after 30 minutes, it's easier than HTML

30 minutes ago, 'make' is some mystical thing to me, now it's so simple and useful tool.

Just give 1-2 hours to learn a tool, it worth your time!



Thursday, November 10, 2011

XML

Why learn XML? It's easy and takes only 40-60 minutes to learn ^^ that's enough for a "WHY".

XML is designed to transport and store data.
I learn this to understand glade file created by Glade3, when writing a GUI for Python app

Some notices:


&lt; < less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark

White-space is Preserved in XML

carriage return (CR) and line feed (LF)
XML stores a new line as LF

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

no words are reserved.

Attributes are handy in HTML. In XML my advice is to avoid them. Use elements instead.
metadata (data about data) should be stored as attributes, and the data itself should be stored as elements.

Document Type Definition (DTD)

Formatting XML with CSS is not the most common method.

W3C recommends using XSLT instead
XSLT is the recommended style sheet language of XML.

XSLT (eXtensible Stylesheet Language Transformations) is far more sophisticated than CSS.

XSLT can be used to transform XML into HTML, before it is displayed by a browser:

http://www.w3schools.com/xml/xml_summary.asp

Saturday, November 5, 2011

Tôi đọc "Suối nguồn"

Sách vở rất dễ nhồi vào đầu con người ta những gì nó viết, đặc biệt là những "triết lý" hay tư tưởng được nói ra thành lời...
Từ ngày quyết định "read less, think more", đọc sách theo 1 kiểu khác. Đọc nhiều chưa chắc hay bằng đọc ít mà nắm được những gì người ta nói, suy được ra những cái hay mà người ta chả nói... Đọc nhiều lấy vội lấy được ngẫm ra cũng như cưỡi ngựa xem hoa, sao biết hoa đẹp, hoa thơm... hoa có lông có lá :))

Với một cuốn sách thiên về tư tưởng và tôn vinh sự sáng tạo như Suối nguồn - "The fountainhead" ~1200 trang, chẳng thể nhớ được nhiều nếu chỉ đọc 1 lần tác phẩm kinh điển này.
"Suối nguồn" lên án mạnh mẽ "xu hướng đám đông" - chỉ vì không có chính kiến, hùa theo số đông mà người ta đánh mất chân lý. Càng ngày, càng thấy rằng chân lý dường như không thuộc về số đông - ngay tại các tập thể mà tôi đang sống. Số đông là những kẻ đam mê hời hợt, nói chuyện tầm phào và giỏi đưa ra nhận xét thằng này hơn thằng kia...



238 - [Bà Keating] Peter, nếu như con đang thực sự hướng đến mục tiêu cao. Con không được phép để cho bản thân mình thỏa mãn bất kỳ ý thích nhất thời nào như bao nhiêu người khác có thể làm, bởi vì đối với họ, đằng nào thì cũng chẳng ích gì.
.....
cont

Tuesday, November 1, 2011

I Try - Ben Taylor


Games, changes and fears
When will they go from here
When will they stop
I believe that fate has brought us here
And we should be together babe
But we're not
I play it off, but I'm dreaming of you
And I'll keep my cool, but I'm fiendin'

[Chorus]
I try to say goodbye and I choke
Try to walk away and I stumble
Though I try to hide it, it's clear
My world crumbles when you are not here
Goodbye and I choke
I try to walk away and I stumble
Though I try to hide it, it's clear
My world crumbles when you are not here

I may appear to be free
But I'm just a prisoner of your love
And I may seem all right and smile when you leave
But my smiles are just a front
Just a front, hey
I play it off, but I'm dreaming of you
And I'll try to keep my cool, but I'm fiendin'

[Chorus]

Here is my confession
May I be your possession
Boy, I need your touch
Your love, kisses and such
With all my might I try
But this I can't deny
Deny

I play it off, but I'm dreaming of you
(but I'm dreaming of you babe)
And I'll keep my cool, but I'm fiendin'

[Chorus]

Thursday, October 27, 2011

x86, 386, 486, 686... @@

Cái đống x86 này làm hoa cả mắt. Nhưng mò một lúc thì không có gì là nguy hiểm cả :))
x86 = extension of 86.
x86_64 là các dòng CPU 64 bit.


Còn lại là các loai CPU 32 bit:
i386 - kiến trúc cơ bản của intel dựa trên 80386
i486 - các vi xử lí dựa trên 80486
i586 - thiết kế cho Pentiums
i686 - Từ Pentium Pro trở lên.

các dòng CPU có khả năng tương thích ngược, tức là có thể chạy 1 hệ điều hành viết cho i386 trên máy i686 ngon lành, điều ngược lại không đúng :D
PS: x86 nếu viết đầy đủ ra phải là x86-32, bởi nó là 1 phiên bản mở rộng của vi xử lí 16bit 8086.

Friday, October 21, 2011

Are You Reading Too Much?




I ran across and interesting quote by Albert Einstein the other day.

Reading, after a certain age, diverts the mind too much from its creative pursuits. Any man who reads too much and uses his own brain too little falls into lazy habits of thinking.

~ Albert Einstein

This isn’t exactly the best known quote by Einstein and I doubt many teachers quote this to their students. Reading is generally a good thing, but if it starts becoming a substitute for thinking on your own it can hold you back from reaching your potential.

This quote touches on a problem that holds many people back from actually accomplishing things. It is easy to spend so much time researching that you never actually execute. That doesn’t mean you shouldn’t read, do research and try to learn from others, but at some point you have to decide that you’ve gather enough data and the time has come to do something. That may be starting your own business, writing a book or even repainting your living room. You have a very finite lifespan. Some people send their life preparing for what they want to do without ever actually doing what they want to do.

Sometimes the most helpful situations are the ones that force you to go ahead and do something by removing the option to try to collect more information.
Business minded? Subscribe to Mark Shead’s business consulting blog.

Sunday, October 2, 2011

Auto mount a partition with fstab

Mount giống như ta nhé CD vào máy trên Windows, Linux sử dụng mount để "nhét" các ổ vào làm việc chứ ko phân chia ổ C,D... như Windows.

Mình đang dùng Ubuntu 10.10, bản này đã sử dụng UUID để chỉ định device được mount trong file fstab.

0. sda sdb..

sda là thiết bị đĩa cứng trên máy của bạn.
nếu cắm usb vào, nó sẽ nhận thiết bị là sdb. Cắm cái nữa sẽ là sdc...
Trên mỗi thiết bị có nhiểu phân vùng (partition) và được đánh số sda1,sda2...
Để xem các phân vùng đã mount ta dùng:
famihug@hvn:/media/Dale$ sudo df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              70G   19G   49G  28% /
none                  1.7G  276K  1.7G   1% /dev
none                  1.7G  168K  1.7G   1% /dev/shm
none                  1.7G  308K  1.7G   1% /var/run
none                  1.7G     0  1.7G   0% /var/lock
/dev/sda5             149G   61G   88G  42% /media/data

Saturday, October 1, 2011

[Bash] cd around the world

Khi bắt đầu dùng terminal (hay chính xác ở đây là bash shell) bạn sẽ phải làm quen với việc di chuyển đến mọi nơi bằng lệnh cd. Nghe có vẻ đơn giản bởi chỉ việc gõ
cd thu_muc_dich
là sẽ đến được ngay, nhưng việc nhỏ bé này sẽ nhiều lúc gây khó chịu đến nỗi khiến ta bật nautilus lên và browse bằng chuột :D.

Tip1: trở về thư mục mà bạn vừa rời khỏi
dùng lệnh cd -

hvnsweeting@hvnbox:/media/data/HVNSweeting$ cd ~
hvnsweeting@hvnbox:~$ cd -
/media/data/HVNSweeting
hvnsweeting@hvnbox:/media/data/HVNSweeting$

Tip2: trở về một thư mục nào đó sau khi đi khắp nơi.
Ví dụ bạn đang ở ~/a/b/c/d/e/f , chạy đi khắp nơi và giờ muốn trở về nơi này. Việc gõ cd ~/a/b/c/d/e/f là cực kì nhàm chán. Hãy sử dụng biến(variable) của bash:
gán biến cur=$(pwd) #kết quả trả về của lệnh pwd = thư mục hiện tại.
hvnsweeting@hvnbox:/media/data/HVNSweeting$ cur=$(pwd)
hvnsweeting@hvnbox:/media/data/HVNSweeting$ cd /home/hvnsweeting/Dropbox/DIC/
hvnsweeting@hvnbox:~/Dropbox/DIC$ cd /home/hvnsweeting/.config/awesome/
hvnsweeting@hvnbox:~/.config/awesome$ cd $cur
hvnsweeting@hvnbox:/media/data/HVNSweeting$

Tip3: đặt tên cho những thu mục thường xuyên ghé thăm.
đặt các biến gắn với các địa chỉ bạn thường sử dụng trong file ~/.bashrc để dễ dàng di chuyển đến đó:

jlab=~/Dropbox/DIC/Java
clab=~/Dropbox/DIC/C

khi cần, bạn chỉ việc cd $jlab hay cd $clab là teleport đến luôn :D

Happy Linux!

Written by HVNSweeting (a.k.a FamiHug) at http://www.familug.com
vui lòng ghi rõ nguồn khi post lại ở chỗ khác, thanks!

Friday, September 30, 2011

Kernel và vấn đề tương thích với từng máy

Sau cuộc upgrade liều lên 10.10 từ 10.04 LTS của mình (ôi thật dại dột :(( ). Cái máy cứ loạn lên, điên loạn đủ kiểu sau khi nghịch file /etc/apt/sources.list và upgrade từ đĩa Debian 6 =)) .
Vấn đề lớn nhất xảy ra là kernel của bản 10.10 (2.6.35.x đổ về sau) đều không nhận em LCD DELL của mình như các tiền bối nó đã làm. Nó liên tục spam ra console (và chắc chắn là cả log) những dòng báo lỗi
[drm:radeon_dvi_detect] *ERROR* HDMI Type A-1: probed a monitor but no|invalid EDID

search khắp nơi nhưng cũng ko chỗ nào fix được lỗi này triệt để. Vậy là quyết định thọc vào bên trong em nó: kernel :ss

Thử với các ver sau như 2.6.38.x cũng vẫn có lỗi y hệt. Thế nên giải pháp ngon lành nhất là dùng lại kernel của bản 10.04: 2.6.34

remove tất cả đống kernel đã cài đi sau khi cài 2.6.34 down từ đây :
http://kernel.ubuntu.com/~kernel-ppa/mainline/
Dòng spam đã biến mất, console (TTYx) đã chạy bình thường nuột nà :x
Làm việc với console năng suất hơn là ngồi onl với Firefox :-ss ko thể tập trung nổi
PS: Thêm một vấn đề bị vướng phải là không hiện grub menu lúc khởi động.
Lí do là với Grub2 nếu nó không tự hiện menu thì giữ ESC hoặc Shift một lúc là nó hiện :D


Tuesday, September 27, 2011

Sentences

  1. Loving one doesn't require hating the other.


Skinny Love
Bon Iver


Come on skinny love just last the year
Pour a little salt we were never here
My, my, my, my, my, my, my, my
Staring at the sink of blood and crushed veneer

I tell my love to wreck it all
Cut out all the ropes and let me fall
My, my, my, my, my, my, my, my
Right in the moment this order's tall

I told you to be patient
I told you to be fine
I told you to be balanced
I told you to be kind
In the morning I'll be with you
But it will be a different "kind"
I'll be holding all the tickets
And you'll be owning all the fines

Come on skinny love what happened here
Suckle on the hope in lite brassiere
My, my, my, my, my, my, my, my
Sullen load is full; so slow on the split

I told you to be patient
I told you to be fine
I told you to be balanced
I told you to be kind
Now all your love is wasted?
Then who the hell was I?
Now I'm breaking at the britches
And at the end of all your lines

Who will love you?
Who will fight?
Who will fall far behind?

Sunday, September 25, 2011

Console based system

… or everything in CLI
For a long time now I have been trying to get the “perfect” working environment on my desktop (in this case, Ubuntu). My requirements for this are simple:
  • Everything (well, almost everything) should be grep-able (documents, presentations, tasks, mails, chats)
  • A tiling window manager – as screens on desktops tend to be large and wide, I find no reason for having windows stacked
  • Multiple desktop support in the window manager (each one customized for a specialized task)
  • The ability to start all my applications after login and to place each of them on predefined desktop
  • Have unitary settings between home desktop, work desktop, laptops, etc
After some tinkering and time spent on getting there, I finally got to check most of the requirements. The tools of trade are the following:
  1. Dropbox for sync-ing configurations, logs, to-do lists and the sorts
  2. The awesome window manager
  3. Emacs as text editor
  4. Org-mode in Emacs for tasks, to-do lists and presentations (yes, I write all my slides in org-mode)
  5. Auctex mode in Emacs LaTeX for documents
  6. Urxvt as terminal
  7. Finch for communication (Pidgin tends to be ugly to manage in a tiling window manager, and really – I just want to write text in my messages – why all the useless UI?)
  8. Elinks for command line browsing (yes, you can open GMail in elinks without any problem)

Saturday, September 24, 2011

Be better...

Back from HUST's IT - Olympic contest.
Lots things to think
Lots things to do

To win this contest, must solve 3 complicated problems in 180 minutes.
2 ways to go:
1. Solve as much as possible, got EXP
2. Create a model process to follow.

I choose 2.
Solved 82 ProjectEuler problems, but I didn't get many as it should be. Cos just solve and go. I learned almost nothing :(

To do list:
- Resolve all 82 problems by Java (vim/API only - no IDE)
- Essential all techniques: backtracking, brute force, memoization, recursive, dynamic programming.
- Create form to solve problem.

No matter how much I learn, but how much I get @@

Thursday, September 22, 2011

[Linux] First pain with awesome window manager (can't set wallpaper)

Sau vài ngày đưa awesome vào sử dụng. Bắt đầu quen với Mod4 + j, k. Hôm nay quyết định nghịch ngợm config awesome. Và những kinh nghiệm thương đau bắt đầu, thật là ít may mắn

Bản awesome mình đang dùng : awesome v3.4.5 (Close To You)

Làm đẹp, một nhu cầu tất yếu của con người nên việc đầu tiên là chọc vào thay theme, wallpaper. Nhưng lúc vừa mới cài mình đã để ý wallpaper ko được set sẵn như lần cài trong máy ảo. Chỉ là một màu xám ngoét mà đã cố chịu đựng trong mấy ngày :)). Fix it now!

trước hết là thay theme khá dễ dàng với việc edit 1 dòng trong file ~/.config/awesome/rc.lua. Thay link trong dấu “” bằng một link đến file theme.lua khác:

beautiful.init("/home/hvnsweeting/.config/awesome/themes/zenburn/theme.lua")
nếu số ai không đen như mình thì nó sẽ đổi cả wallpaper mặc định với mỗi theme sau khi đổi theme. Còn nếu màn hình bạn đã xám ngoét từ đầu thì phải sửa em nó thôi :
mở file theme.lua đã dùng ở trên ra sẽ thấy dòng
theme.wallpaper_cmd = { "awsetbg /home/hvnsweeting/.config/awesome/themes/zenburn/zenburn-background.png" }
bản thân awesome không tự thay đổi wallpaper được, nó phải sử dụng một phần mềm nhỏ có trên máy bạn là awsetbg. Bình thường cái awsetbg sẽ hoạt động ngon lành (gõ awsetbg link/to/wallpaper.jpg sẽ thay wallpaper luôn), thế nhưng ta đang trong trường hợp không bình thường :( gõ vào terminal:

hvnsweeting@hvnbox:~/.config/awesome/themes/zenburn$ awsetbg -i

I can't find an app to set the wallpaper with. Using xsetroot to set a solid background. If you want to have a background image you should install Esetroot or feh.
như vậy awsetbg lại dùng 1 app khác để set wallpaper. Như ở trên thông báo, nó sẽ dùng feh (một wallpaper setter). Gõ check xem đã cài chưa
hvnsweeting@hvnbox:~$ feh -v
feh version 1.7
nếu chưa thì bạn dùng dòng lệnh dưới để cài feh:
sudo apt-get install feh
bây giờ ta thay dòng lệnh trong file theme.lua để có thể đổi wallpaper:
theme.wallpaper_cmd = { "awsetbg -u feh /home/hvnsweeting/.config/awesome/themes/zenburn/zenburn-background.png" }
màn hình đã không còn xám ngoét mà giờ đả đỏ choét :x. Sự sống lại đến với em desktop awesome! 

Tuesday, September 20, 2011

[Python] Ma trận chuyển vị và cách lấy cột của 1 ma trận

Giải PE82, nghịch Python lại tìm ra trò mới.â
Cần lấy 1 cột trong 2D list để cho vào 1 list khác.

Cách làm là dùng hàm zip() để trả về ma trận chuyển vị rồi lấy dòng (tương ứng với cột ) cần lấy. (hoặc đơn giản hơn là tạo 1 list mới chứa các phần tử của cột cần lấy)

>>> ls = [[1,2,3],[4,5,6],[7,8,9]]
>>> for i in ls: print i
...
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
>>> print ls[2][:]
[7, 8, 9]
>>> for row in zip(*ls): print row
...
(1, 4, 7)
(2, 5, 8)
(3, 6, 9)
>>> print zip(*ls)[2]
(3, 6, 9)
>>> print zip(*ls)[1]
(2, 5, 8)
>>> [row[1] for row in ls]
[2, 5, 8]
Python cung cấp nhiều thư viện giành riêng cho mục đích tính tóan và khoa học vd như scipy, pynum... Nhưng khi không cần nhiều như thế thì cứ zip mà xoay :x
Love Python ! :x Solved PE82
(Mình ham chơi quá :“> )

Friday, September 16, 2011

[IMG]Obvious Similarities


source: bonkersworld


=))

[Python] Nhập file chứa ma trận vào chương trình

nếu như C có fscanf(), java có nextInt() thì Python chỉ có mỗi read()#đọc byte và readline()
làm mình tìm tung lên và chửi nó một lúc :">
Nhưng python thật quá tuyệt trong khoản này :p. Mò một lúc là có thể đọc dữ liệu (các hệ số) từ file:

Trước tiên dùng readline() để đọc một dòng, nó sẽ trả về 1 str. Sau đó split str này thành 1 list các str con rồi map lại thành 1 list int

hvnsweeting@hvnbox:/media/Paradise/DIC/pyhvn$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> fin = open("matrix.txt","r")
>>> matrix = []
>>> for i in range(5):
... arow = map(int, fin.readline().split(','))
... matrix.append(arow)
...
>>> matrix
[[4445, 2697, 5115, 718, 2209], [1096, 20, 1318, 7586, 5167], [9607, 7385, 521, 6084, 1364], [7206, 3114, 7760, 1094, 615], [3620, 8024, 577, 9997, 7377]]
>>> for i in matrix: print i
...
[4445, 2697, 5115, 718, 2209]
[1096, 20, 1318, 7586, 5167]
[9607, 7385, 521, 6084, 1364]
[7206, 3114, 7760, 1094, 615]
[3620, 8024, 577, 9997, 7377]
>>>
Ngày càng yêu python :x

Thursday, September 15, 2011

[Java] Thay đổi kích thước heap

Khi chạy một số chương trình dùng nhiều bộ nhớ (vd như chương trình đệ quy gọi nhiều lần) chương trình sẽ báo lỗi nếu bộ nhớ sử dụng vượt quá dung lượng bộ nhớ mặc định:

java.lang.OutOfMemoryError: Java heap space

Có thể thay đổi kích thước heap để chương trình có thể chạy ngon lành :D

Eclipse
eclipse [normal arguments] -vmargs -Xmx256M [more VM args]
http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F


Command (terminal - linux)
java -Xss20m PE81Dijkstra
java -Xss[kích thước heap] program

Đây là một cách chữa cháy khi chương trình báo lỗi ko đủ bộ nhớ, nhưng điều thực sự nên làm là thay đổi chương trình, sử dụng thuật tóan tốt hơn để chạy tốn ít bộ nhớ hơn.

Tuesday, September 13, 2011

Phrases We Owe to Shakespeare






Becky, a 20-year-old English Lit geek living in London, scribbled out this list in a Moleskine notebook at 3 am

a couple nights ago. She posted it on her Tumblr page,

and within 24 hours, more than 11,000 people had saved it in their favorites file.

She was astonished. “I still don’t know how something I scribbled in a hurry at 3am got so many notes in the space of a day? Shakespeare is clearly too awesome,” Becky said in an update on the post today. “I spelt “bated” wrong, awk … Someone said this looks like a serial killer’s notebook, which made me laugh a lot. They’re not wrong, I’ve been a sleep deprived zombie lately.”

She certainly is a girl on a mission.

On her birthday on August 30th, she set a challenge for herself: Read a book every week until she turns 21. “Lately, I’ve gotten into the terrible habit of buying books but never reading them.

Gradually I’ve been reading less and less,” she said.

She put together a list of 52 books (heavy on Palahniuk, Murakami and Hemingway) and posted it here.

“I thought it would be a good way to encourage others to read more too.”

Want to take the challenge? The details are here.

She’s also giving away the books she reads.

Awesome.

[Python] One-liner prints square triangle

Tự dưng nghĩ ra trong lúc tắm, hehe. Liệu có ngôn ngữ nào có thể viết ngắn hơn thế này ? (nghi ngờ Perl :D )

>>> for i in range(1,11): print i*'*'

*
**
***
****
*****
******
*******
********
*********
**********
>>>

Nhờ tính năng “nhân” string của Python
Love :x

Friday, September 9, 2011

Everyday English 20110909

assessment : sự đánh giá
fork : chia nhánh
perceive : lĩnh hội, nắm đc
perspectives : phối cảnh, viễn cảnh
arrogant (a): kiêu ngạo
ignorant (a): ngu dốt, dốt nát
convinced : tin chắc
Embrace : ôm, nắm lấy
I would advice you to think twice about if software development is for you (nghĩ 2 chiều - nghĩ đi nghĩ lại)
see my job board for evidence(bằng chứng)
nanosecond is one billionth of a second (1/tỷ)


 

Twinkle Twinkle Little Star - Timelapse Compilation by ThePianoGuys

The Truly Educated Never Graduate

http://stoffe.deephacks.org/2011/08/09/the-truly-educated-never-graduate/

Science can be very complex in theory and people failing to think in these abstract terms probably get cold feet prematurely in their choice of education. Other people have a hard time to apply theory in practice even though they are all very smart people! Indeed, having a university degree is far from an insurance of being intelligent.
Alan Kay, the father of object-oriented programming, shares some very interesting ideas around teaching and understanding. James Bach also touches on the subject in Secrets of a Buccaneer-Scholar. Noam Chomsky and Sir Ken Robinson further acknowledge the failure of modern education in a very deep and interesting analysis.
I think this is very unfortunate, because it means that we (the people) are somewhat mislead in a system that does not encourage individuals to pursue our their inner passion.

Thursday, September 1, 2011

Conclude for this week

Writing recursive function
Transfer files between 2 linux computer using vsftpd & ftp

Learn basic concept about Functional Programming
http://www.joelonsoftware.com/items/2006/08/01.html

Nice question
http://stackoverflow.com/questions/7267760/how-can-a-time-function-exist-in-functional-programming

Wiki
http://en.wikipedia.org/wiki/Functional_programming

Ten Things Everyone Should Know About Time

Ten Things Everyone Should Know About Time:

“Time” is the most used noun in the English language, yet it remains a mystery. We’ve just completed an amazingly intense and rewarding multidisciplinary conference on the nature of time, and my brain is swimming with ideas and new questions. Rather than trying a summary (the talks will be online soon), here’s my stab at a top ten list partly inspired by our discussions: the things everyone should know about time. [Update: all of these are things I think are true, after quite a bit of deliberation. Not everyone agrees, although of course they should.]


1. Time exists. Might as well get this common question out of the way. Of course time exists — otherwise how would we set our alarm clocks? Time organizes the universe into an ordered series of moments, and thank goodness; what a mess it would be if reality were complete different from moment to moment. The real question is whether or not time is fundamental, or perhaps emergent. We used to think that “temperature” was a basic category of nature, but now we know it emerges from the motion of atoms. When it comes to whether time is fundamental, the answer is: nobody knows. My bet is “yes,” but we’ll need to understand quantum gravity much better before we can say for sure.


2. The past and future are equally real. This isn’t completely accepted, but it should be. Intuitively we think that the “now” is real, while the past is fixed and in the books, and the future hasn’t yet occurred. But physics teaches us something remarkable: every event in the past and future is implicit in the current moment. This is hard to see in our everyday lives, since we’re nowhere close to knowing everything about the universe at any moment, nor will we ever be — but the equations don’t lie. As Einstein put it, “It appears therefore more natural to think of physical reality as a four dimensional existence, instead of, as hitherto, the evolution of a three dimensional existence.”


3. Everyone experiences time differently. This is true at the level of both physics and biology. Within physics, we used to have Sir Isaac Newton’s view of time, which was universal and shared by everyone. But then Einstein came along and explained that how much time elapses for a person depends on how they travel through space (especially near the speed of light) as well as the gravitational field (especially if its near a black hole). From a biological or psychological perspective, the time measured by atomic clocks isn’t as important as the time measured by our internal rhythms and the accumulation of memories. That happens differently depending on who we are and what we are experiencing; there’s a real sense in which time moves more quickly when we’re older.


4. You live in the past. About 80 milliseconds in the past, to be precise. Use one hand to touch your nose, and the other to touch one of your feet, at exactly the same time. You will experience them as simultaneous acts. But that’s mysterious — clearly it takes more time for the signal to travel up your nerves from your feet to your brain than from your nose. The reconciliation is simple: our conscious experience takes time to assemble, and your brain waits for all the relevant input before it experiences the “now.” Experiments have shown that the lag between things happening and us experiencing them is about 80 milliseconds. (Via conference participant David Eagleman.)


5. Your memory isn’t as good as you think. When you remember an event in the past, your brain uses a very similar technique to imagining the future. The process is less like “replaying a video” than “putting on a play from a script.” If the script is wrong for whatever reason, you can have a false memory that is just as vivid as a true one. Eyewitness testimony, it turns out, is one of the least reliable forms of evidence allowed into courtrooms. (Via conference participants Kathleen McDermott and Henry Roediger.)


6. Consciousness depends on manipulating time. Many cognitive abilities are important for consciousness, and we don’t yet have a complete picture. But it’s clear that the ability to manipulate time and possibility is a crucial feature. In contrast to aquatic life, land-based animals, whose vision-based sensory field extends for hundreds of meters, have time to contemplate a variety of actions and pick the best one. The origin of grammar allowed us to talk about such hypothetical futures with each other. Consciousness wouldn’t be possible without the ability to imagine other times. (Via conference participant Malcolm MacIver.)


7. Disorder increases as time passes. At the heart of every difference between the past and future — memory, aging, causality, free will — is the fact that the universe is evolving from order to disorder. Entropy is increasing, as we physicists say. There are more ways to be disorderly (high entropy) than orderly (low entropy), so the increase of entropy seems natural. But to explain the lower entropy of past times we need to go all the way back to the Big Bang. We still haven’t answered the hard questions: why was entropy low near the Big Bang, and how does increasing entropy account for memory and causality and all the rest? (We heard great talks by David Albert and David Wallace, among others.)


8. Complexity comes and goes. Other than creationists, most people have no trouble appreciating the difference between “orderly” (low entropy) and “complex.” Entropy increases, but complexity is ephemeral; it increases and decreases in complex ways, unsurprisingly enough. Part of the “job” of complex structures is to increase entropy, e.g. in the origin of life. But we’re far from having a complete understanding of this crucial phenomenon. (Talks by Mike Russell, Richard Lenski, Raissa D’Souza.)


9. Aging can be reversed. We all grow old, part of the general trend toward growing disorder. But it’s only the universe as a whole that must increase in entropy, not every individual piece of it. (Otherwise it would be impossible to build a refrigerator.) Reversing the arrow of time for living organisms is a technological challenge, not a physical impossibility. And we’re making progress on a few fronts: stem cells, yeast, and even (with caveats) mice and human muscle tissue. As one biologist told me: “You and I won’t live forever. But as for our grandkids, I’m not placing any bets.”


10. A lifespan is a billion heartbeats. Complex organisms die. Sad though it is in individual cases, it’s a necessary part of the bigger picture; life pushes out the old to make way for the new. Remarkably, there exist simple scaling laws relating animal metabolism to body mass. Larger animals live longer; but they also metabolize slower, as manifested in slower heart rates. These effects cancel out, so that animals from shrews to blue whales have lifespans with just about equal number of heartbeats — about one and a half billion, if you simply must be precise. In that very real sense, all animal species experience “the same amount of time.” At least, until we master #9 and become immortal. (Amazing talk by Geoffrey West.)


Sunday, August 14, 2011

Java for Android programming


A complete understanding of the basics would be desirable.
Specifically the following topics:
  • Declarations and Access Control
  • ObjectOrientation
  • Assignments
  • Operators
  • Flow Control, Exceptions, and Assertions
  • Strings, I/O, Formatting, and Parsing
  • Generics and Collections
  • InnerClasses
  • Threads
But if you know already the basics ( classes, objects, inheritance, interfaces ) I think you're ok to start.
You don't need to learn specific libraries ( like swing, or others ) because you won't use them in Android.

http://stackoverflow.com/questions/2981495/how-much-java-should-i-have-learnt-before-trying-android-programming

Weekly plan 15/08/11 - 21/08/11

Makefile & Java makefile
http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html
http://www.cs.swarthmore.edu/~newhall/unixhelp/javamakefiles.html

Java IO

Maven
http://maven.apache.org/what-is-maven.html

Cmake
OpenCV
Virii

Conclude for this week

Learned stuffs:
Dynamic Programming
Euler transforming
Partition Function
generating function
Write loop instead of recursive
Pentagonal numbers: n*(3*n - 1)/2 where n = 0, +-1, ...

Good sites:
http://mathworld.wolfram.com/


Project Euler is a game, stop playing game to do large work

[Self remind]
Doing PE is fun, useful. I love to do some ProjectEuler problems, learn some new technique. But PE just a game. Now, must stop playing game and do real work.
Play PE in spare time :x

Test some new FF extensions

Test ScribeFire - Add on help write blog
Has many nice features but not lightweight =.=
Tile view - Tile the browser
Bad shortcut, difficult

Wednesday, August 10, 2011

Programming Achievements: How to Level Up as a Developer

How does a good developer become a great developer?
Forget greatness for a moment: How does a decent developer become a good developer?
There is no definitive path from Step 1 to Step n. Heck, it's not even clear what Step n is. And as logically-minded developer types, the lack of a well-defined route can make for a daunting journey from novice to master.
I've spent a fair bit of time over the last few years bumping up against this conundrum. What's next? How do I go from being a good developer to a being really good developer?

Triết lý mì tôm

Những cái lí được triết ra sau những ngày "Sáng học Mac, chiều học thể dục, tối ăn mì tôm" (thật ra mới ăn mì tôm có 3 bữa =)) )



1. Thuyết tương đối:
Một bát mì chẳng là gì so với cơm ngon , thịt gà , cá gỡ nhưng còn hơn là nhịn đói. Giá trị của gói mì tôm là tương đối, không có gì là tuyệt đối.

2. Nắm bắt thời cơ:
Thời điểm tốt nhất để ăn một bát mì là sau khi nó vừa chín. Ăn sớm thì sống, ăn muộn thì nát. Hãy nắm bắt thời điểm thích hợp nhất để làm việc cần làm :-" (BTW: vẫn có những đứa thích ăn mì tôm sống và mì tôm nát =.= )

3. Lòng tốt:
Thời điểm tốt nhất để rửa bát là sau khi ăn mì tôm. Để lâu mỡ sẽ đóng lại rửa rất khó chịu, đặc biệt là vào mùa đông. Hãy rửa bát ngay sau khi ăn, hoặc tráng qua nước nếu bạn không phải là người rửa. Ai đó sẽ nói "Cám ơn!"

4. Kết hợp:
Chẳng có ai thích ăn mì không cả, trừ khi bắt buộc phải thế. Ăn mì với trứng, thịt bò, hành lá thật là tuyệt vời. Khi đi một mình, mì tôm có thể chí đáng giá 3k nhưng thêm thị bò vào là lên 15 nghìn ngay, thậm chí còn đắt hơn. Đừng sống một mình!

5. Nguyên tắc chia nhỏ:
Ai nấu mì tôm cũng bẻ ra cả, để cả miếng lúc chín rất khó ăn. Việc lớn khó thì xé nhỏ ra mà làm.

Ai tài trợ mình thêm thùng mì nữa cái :">

Tuesday, August 2, 2011

Top 5 regrets people make on their deathbed

Deathbed-Regrets
By Bronnie Ware (who worked for years nursing the dying)
For many years I worked in palliative care. My patients were those who had gone home to die. Some incredibly special times were shared. I was with them for the last three to twelve weeks of their lives.
People grow a lot when they are faced with their own mortality. I learnt never to underestimate someone’s capacity for growth. Some changes were phenomenal. Each experienced a variety of emotions, as expected, denial, fear, anger, remorse, more denial and eventually acceptance. Every single patient found their peace before they departed though, every one of them.

When questioned about any regrets they had or anything they would do differently, common themes surfaced again and again. Here are the most common five:

1. I wish I’d had the courage to live a life true to myself, not the life others expected of me.

Saturday, July 30, 2011

Text Editors in The Lord of the Rings

Prompted by a passing thought about TextMate, I thought I’d make a comprehensive, accurate, unbiased, and irrefutable survey of text editors by way of comparison to locations in The Lord of the Rings.

TextMate: Minas Tirith


A once-great but now decaying city. Only the King has the power to renew it, but he is a long absent, indeed half-legendary figure—though there are persistent rumors that he is alive still in some distant land. In his stead, the city slowly falls in upon itself, kept in some sort of working order by its melancholy people. They can repair but not truly rebuild it, and they pray daily for the Return of the King.

Sunday, July 24, 2011

Hash passwords

http://security.stackexchange.com/questions/5586/why-do-people-think-that-this-is-bad-way-to-hash-passwords

Q:  

Well, please tell me, what's wrong with this code

$password = "hello";;
$password = md5($password);
for($i=1;$i<20;$i++){
    $password = md5($password);
}

Test-Driven Development Is Not Slower

Hello, my name is Matt Honeycutt, and I am addicted to Test Driven Development.  I’ve been “using” for about 5 years now.  It started out with a little innocent unit testing and Test Later Development, but I quickly found that the increased productivity caused by TDD to be too alluring, and I succumbed.  Now I’m using all the time.  I use at work.  I use at home.  I just can’t stop.  People don’t really understand the risks.  There’s this myth that TDD is slower, that it makes you less productive, but that’s so not true.  Read on, and I’ll help you understand why.
NOTE: This post is an extended version of a comment I left in reply to an anonymous commenter on Mike Hadlow’s “I Don’t Have Time For Unit Tests” post.  I encourage you to go read his post, because Mike has some good insights that I won’t repeat here.

Thursday, July 21, 2011

Java note

Java only supports Pass-By-Value. You can pass a reference by value, but you cannot pass by reference in Java




Which one is faster in Java ?

1for(int i = 100000; i > 0; i--) {}
2for(int i = 1; i < 100001; i++) {}
Answer: Which ever is run second with be fastest. The server JVM can detect and eliminate loops which don't do anything. A method with either loop is compiled when the loop iterates about 10,000 times. (Based on -XX:CompileThreshold=10000) The first loop will take time to detect it doesn't do anything, however the second will have been compiled.

Wednesday, July 20, 2011

Funny Source Code Comments

I recently stumbled upon an awesome Stack Overflow thread, entitled "What is the best comment in source code you have ever encountered?".

As you might have guessed, it is a collection of funny source code comments, provided by developers all over the world. Take a look at it, it could definitely make your day.

I am reposting here my personal favorites from that long long collection:

// sometimes I believe compiler ignores all my comments

Exception up = new Exception("Something is really wrong.");
throw up; //ha ha

Monday, July 18, 2011

21 Google Plus circles you can actually use.


This infographic on 21 Google Plus circles you can actually use made me chuckle.

(via David Pogue)
"

Test your vocabulary

http://testyourvocab.com/?r=105891

Your total vocabulary size is estimated to be:
5,450
words

Dạo này lười thế :D

Weekly post

Weekly, I will conclus everything I've learned to a post. To keep watching them, recall it on next week to keep my knowledge.

Last week:
Basic PHP
Normalize SQL database - 3 steps
MD5 hash, little things in cryptography.
TTD, PHP simpletest , JUnit

This week:
PHP & HTML form

MD5Hasher v1.0

My first Java simple software . It prints out MD5 Hash of the input.
http://www.mediafire.com/?lzi4t158c4z5phc
run on both Windows and Linux. You have to preinstall JRE.
Just a toy software make to use some interesting things that I've learned about cryptography and Java GUI.
Nice try ;)
(If you would like the source, plz comment) :D


Thursday, July 7, 2011

A physics joke

A physics joke: "
Newton, Pascal, and Einstein are playing hide-and-go-seek in heaven.
Einstein closes his eyes and starts counting.
Pascal goes and hides behind a cloud.
Newton stays where he is, and draws a 1mx1m square on the floor around him.
Einstein finishes counting and turns around.
'Ah ha, Newton! I found you!'
'No you haven't, you've found one Newton over 1m2 . . . You found Pascal.'
submitted by nanuq905

Monday, June 20, 2011

Infographic of the Day



Infographic of the Day


Infographic of the Day: The future ain’t what it used to be. I don’t see a flying car anywhere on this chart!

Infographic of the Day

Infographic of the Day: "

Infographic of the Day



Infographic of the Day: The future ain’t what it used to be. I don’t see a flying car anywhere on this chart!


[reddit]



Tagged: computers, Infographic, the future


"

Tuesday, June 14, 2011

Fibonacci number in O(1) time!

It takes O(Exponential) time if you use recusion...
takes O(n) if you use loop with two variable
can it be solved in O(log(n))?

More better, it can be solved in O(1) time ?!!!
#include  stdio.h
#include  math.h  //please add smaller and larger symbol

unsigned long long fib(int n)
{
    double x = sqrt(5)/5;
    double f1 = x * pow((1 + sqrt(5)) / 2, n);
    double f2 = -x * pow((1 - sqrt(5)) / 2, n);

    return (unsigned long long)(f1 + f2);
}

int main()
{
    int n;
    printf("Find nth Fibonacci number, n = ");
    scanf("%d",&n);
    printf("%dth Fibonacci number: %llu\n",n,fib(n));
    return 0;
}

Unsigned long long type can represent largest number which has <=20 digits. For  larger number, use gmp library or use higher level language.

This algorithm use golden ratio.

Thursday, June 9, 2011

ToStudyList

http://en.wikipedia.org/wiki/Fast_Fourier_transform
http://zung.zetamu.net/Files/XSTK2010_2chapters.pdf

Tuesday, June 7, 2011

Every year

Obviously every year is annual. Every two years is biennial.

What does a developer do?

http://programmers.stackexchange.com/questions/81929/is-it-normal-for-people-to-not-work

Q
After graduating college I was hired as a Junior Programmer a little over a year ago. I quickly noticed that I was degrees of magnitude faster than all the other programmers; this seems to be because I simply don't waste time "in general".. The majority of other people however seem to enjoy staring the ceiling, browsing youtube/facebook/random websites, and in general doing in a day the work I usually do in an hour. I'm 100% sure they would be able to do that work in an hour too if they focused.
I've been quickly promoted to Senior Developer and more recently to Team Leader and now I replaced a lot of those people with new hires (still a couple to go).. The situation is now more acceptable, but still I think it could be much better.
I can't help to notice though that everyone seems to behave like this is "normal".. All my bosses aren't concerned about this and they too seem to work little to nothing. I always have a very hard time finding them, they arrive much later than they are supposed to and leave early.. Obviously there is nothing I can do in this case since they're above me, but I'm now wondering if this is the "norm" in all companies or I simply ended up in a very bad one (this is my first work experience). Also I'm wondering if in a few years I'll "become like them".

Sunday, June 5, 2011

How to become a Linux system administrator

One of the FAQs that I get is "How can I become a Linux system administrator". I got into sysadmin by mistake and learnt things the hard way i.e. by making mistakes. I do not know of any college courses that train people to be a sysadmin. There are private coaching centers that promise to train people to become a certified RedHat or Novell system administrator, but frankly I am wary of their capabilities. The main reason for my caution against these private institutes is the quality of the teachers there - anyone who is a good sysadmin will usually get picked up in the job market in a jiffy.

Here are things I think that anyone in the college right now and looking to become a sys admin can do. Note that I am focussing here mostly on the technical skills required.

Wednesday, May 25, 2011

tar -xzf

tar -xzf merc.tgz what the fuck
how the fuck do you people remember this shit
just think with a german accent
XTRACT ZE FILES


http://qdb.us/305221

Tuesday, May 24, 2011

KiB vs kB

Trước đây, mình cứ nghĩ KiB và kB giống nhau, = 1024 B. Thế nhưng sự thật thì lại không phải thế :
KiB là Kibi Byte = 1024 Bytes = 2^10
MiB là Mibi Byte = 1024 KiB= (2^10)^10
Hệ đơn vị KiB MiB này là do người Mỹ nghĩ ra. Dựa trên hệ số 2
Còn kB, MB, GB... là đơn vị thuộc hệ SI ( Système international d'unités )
1 kB = 1000 B, 1 MB = 1000 MB.
=> 1 kB < 1 KiB, 1 MB < 1 MiB
 
Vậy chữ "i" kí hiệu cho hệ binary.

PS: bit là viết tắt của "binary digit"
 
2008
  • The US National Institute of Standards and Technology guidelines require use of IEC prefixes KiB, MiB ... (and not kB, MB) for binary byte multiples[83]
    • p29, “The names and symbols for the prefixes corresponding to 2 10 , 2 20 , 2 30 , 2 40 , 2 50 , and 2 60 are, respectively: kibi, Ki; mebi, Mi; gibi, Gi; tebi, Ti; pebi, Pi; and exbi, Ei. Thus, for example, one kibibyte is also written as 1 KiB = 2 10 B = 1024 B, where B denotes the unit byte. Although these prefixes are not part of the SI, they should be used in the field of information technology to avoid the non-standard usage of the SI prefixes.”
2009
  • Apple Inc. uses the SI decimal definitions for capacity (e.g., 1 kilobyte = 1000 bytes) in the Mac OS X v10.6 operating system to conform with standards body recommendations and avoid conflict with hard drive manufacturers' specifications.



    http://en.wikipedia.org/wiki/Timeline_of_binary_prefixes http://superuser.com/questions/287375/what-is-the-origin-of-k-1024

    Saturday, May 21, 2011

    Something changed!

    From now,daily writing moved to http://hvnc2k8.tumblr.com/
    Thanks!

    chắc mình sẽ sớm nghỉ làm thêm, có quá nhiều thứ muốn học!!!
    sung sướng gì việc đi làm mấy thứ vớ vẩn.
    lòng tham con người, cái gì cũng muốn...
    sao không cho tôi, những gì tôi đáng được hưởng, đâu cần hơn?

    Thơ thẩn hơ hơ...

    Đc ngày nữa chả học hành gì cả.
    Đi chơi về ngồi vào máy làm thơ ... hơ hơ :))

    "yêu em có đôi khi anh dại
    chót nhận mình chẳng biết luộc khoai..."

    câu 1 sinh ra từ cảm xúc, lúc đầu là thương em, lúc sau đổi thành yêu cho nó sướng :>
    câu 2 bịa ra tại em đang xem dạy luộc khoai :))

    đi hóng các Hutter chém gió về chả muốn học, lại tóan :-<

    Friday, May 20, 2011

    Develop a firefox extension

    http://blog.mozilla.com/addons/2009/01/28/how-to-develop-a-firefox-extension/


    Admit that you have always wanted to know how to develop a Firefox extension but never had the time to learn. :-) Here I will walk you through and at the end of the article we will have created a fully functional Firefox extension!

    Our objective

    We will create a Firefox extension to find all links in the current web page, highlight those which have a target attribute and alert you how many links it found. The good part is that once you have done this, you have both an understanding of Firefox extension development as well as a blueprint for any extension you would want to develop in the future.

    Những điều không quan trọng

    Từ hôm nay chính thức không dùng Facebook nữa. Để dành lại chút thời gian rảnh rỗi ít ỏi cho những việc cần thiết hơn như... ôm đàn, tập violin, code, đọc tài liệu, viết truyện... blah blah. Nhưng ko deactive, để thỉnh thoảng còn vào xem ảnh của... ngta :">(hư lắm b-( b-( b-( )
    ..............~~~~~~~~~~~~~~~................



    Những điều không quan trọng
    (Bài viết này áp dụng với những thứ liên quan đến đời sống hàng ngày và không liên quan đến việc KIẾM TIỀN!)

    Trong cuộc đời này, bạn luôn phải đối mặt với sự lựa chọn. Đôi khi năng lượng bạn dùng để quyết định điều gì đó còn nhiều hơn là bạn dùng để thực hiện nó!
    Why so serious?
    - Không quan trọng bạn dùng Window(Cracked) hay Linux(Ubuntu) miễn là bạn cảm thấy thoải mái và làm việc hiệu quả nhất với nó.
    - Không quan trọng bạn dùng C, Cpp, C#, Java hay Python mà quan trọng là bạn làm được những gì với nó...
    - Không quan trọng bạn chơi violin hay guitar, chỉ cần bạn cảm thấy thoải mái, phiêu nhất với nó....
    - Không quan trọng bạn học khoa nào, mà quan trọng là bạn đứng chỗ nào trong khoa ấy?
    - Không quan trọng bạn dùng Iphone hay Blackberry thậm chí là 1100i, quan trọng là bạn sử dụng nó để làm gì? (thằng dùng Iphone chỉ để nghe gọi đú sao được với thằng dùng 1100i biết đặt cả báo thức :)) )
    ....
    và còn rất nhiều điều không quan trọng nhiều khi khiến bạn bối rối. Hãy nhận ra đâu mới là giá trị thực sự!

    Monday, May 9, 2011

    Design pattern

    Today, I've got what is "Design pattern" and it's the first time I heard about MVC(Model View Controlle). I search around to get some futher knowledge...

    Why is MVC more popular than PAC?
    http://programmers.stackexchange.com/questions/74799/why-is-mvc-more-popular-than-pac

    MVC Wiki
    http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

    PAC Wiki
    http://en.wikipedia.org/wiki/Presentation-abstraction-control

    Saturday, May 7, 2011

    Why Successful People Leave Work Early

    Try this for a day: don't answer every phone call. Stop checking your email every two minutes. And leave work early. You'll be astounded at how much more you'll get done.
    According to a study published in the Psychological Review conducted by Dr. K. Anders Ericcson, the key to great success is working harder in short bursts of time. Then give yourself a break before getting back to work.

    chartThe trick is staying focused. Ericsson and his team evaluated a group of musicians to find out what the 'excellent' players were doing differently. They found that violinists who practiced more deliberately, say for 4 hours, accomplished more than others who slaved away for 7 hours. The best performers set goals for their practice sessions and required themselves to take breaks.

    Looking at the chart, you can see that the best violin students practiced with greater intensity just before the lunch hour and then took a break before starting up again at 4 p.m. -- whereas the other students practiced more steadily throughout the entire day.

    The researchers found that successful people in other professions had similar habits:

    'While completing a novel, famous authors tend to write only for 4 hours during the morning, leaving the rest of the day for rest and recuperation. Hence successful authors, who can control their work habits and are motivated to optimize their productivity, limit their most important intellectual activity to a fixed daily amount when working on projects requiring long periods of time to complete.'

    Timothy Ferriss gives similar advice in his New York Times bestseller, The 4-Hour Workweek. He stresses the Pareto principle, or the 80/20 law, which is that 80 percent of outputs come from 20 percent of inputs. So stay focused, and you'll do more in less time.

    For more productivity tips check out 9 Ways to Work Less and Do More >


    For the latest career news, visit War Room. Follow us on Twitter and Facebook.
    Join the conversation about this story »
    See Also:

    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