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.)