4 Mar 2010

portage-2.1.8 has new --rebuilt-binaries option

In portage-2.1.8 there's a new emerge --rebuilt-binaries
option that is very useful for people who build binary packages and
install them on multiple computers (using PORTAGE_BINHOST or shared
PKGDIR). The option causes packages to be automatically reinstalled in
cases when rebuilt binary packages are available (due to revdep-rebuild
or similar cases).
Rebuilds are detected by comparison of BUILD_TIME package metadata.
This option is enabled automatically when using binary packages
(--usepkgonly or --getbinpkgonly) together with --update and --deep.


http://blogs.gentoo.org/zmedico/2010/03/03/rebuilt_binaries_portage_2_1-8

12 Feb 2010

Love songs

#!/usr/bin/env python
# python script to download love songs from mp3.zing.vn
# hungnv
# license: Public Domain
from urllib2 import urlopen
from urllib import urlretrieve
from os import mkdir
from os.path import join, isdir
import sys
mp3_dir = "/home/hungnv/Music/"
html_source = "http://mp3.zing.vn/mp3/nghe-album/album-hot/love-song.html"
if not isdir(mp3_dir):
    try:
        mkdir(mp3_dir)
    except:
        print "cannot create directory %s" %mp3_dir
        sys.exit(1) 
def getlink():
    try:
        response = urlopen(html_source)
    except:
        print "connection error"
    response = urlopen(html_source)
    content = response.readlines()
    response.close()
    for line in content:
        a = line.find('http://dl.mp3.kapsule.info')
        b = line.find('?')
        if a <> -1 and b <> -1:
            link = line[a:b]
            c = line.find('filename') + 9
            d = line.find('alt') - 2
            filename = line[c:d]
            print "Song named %s will be downloaded at url %s" % (filename,link)
            print "Downloading.....\n"
            abs_path = join(mp3_dir,filename)
            urlretrieve(link,abs_path)
        else:
            continue
if __name__ == '__main__': 
    getlink()
exit()

27 Jan 2010

Indispensable job

I have an account named hungnv on my server - vndev.net which's running Fedora 8. If I want to remote copy, modify, delete... some files on this server , which way is faster:
1. sftp ( known as an extension of secure shell protocol - SSH ) 
hungnv@g3n2 ~ $ sftp vndev.net
Connecting to vndev.net...
sftp>
Browse local file: lls, move to local directory lcd
upload put
download get

2. sshfs (not an ssh extension, we must install fuse-sshfs to use it)
hungnv@g3n2 ~ $ eix sshfs
[I] sys-fs/sshfs-fuse
     Available versions:  1.9 ~2.1 2.2
     Installed versions:  2.2(08:46:14 AM 01/27/2010)
     Homepage:            http://fuse.sourceforge.net/sshfs.html
     Description:         Fuse-filesystem utilizing the sftp service.
hungnv@g3n2 ~ $ sudo emerge -av sys-fs/sshfs-fuse
hungnv@g3n2 ~ $ sshfs vndev.net:/ /vndev
to mount. We browse, cp, edit, delete....like local file and directory.
I didn't use sshfs until yesterday, with me, ssh and sftp are enough. But I should know sshfs and I did not know, so I fail.
We must learn what we never use =.=

22 Jan 2010

Phân hóa thu nhập từ nhiều góc nhìn

Trong một phát biểu của Trần Trọng Thức ở Tuần Việt Nam
Trong khi có những người giàu lên không bằng năng lực cũng chẳng nhờ vào thời cơ, mà nhờ vào các mối quan hệ. Hầu hết các nước kém phát triển, khi quyền lực liên kết với tư bản trong làm ăn thì phân hóa giàu nghèo càng khó giải quyết. Về mặt lý thuyết thì quyền lực chính trị là khả năng quyết định ai sẽ nhận được "cái gì" để làm ra được "cái gì" và cho ai được hưởng.
Thực tế đơn giản là thực tế :-D.

21 Jan 2010

Học python

Sửa lại chút cái shell script hồi xưa Dreammedia , viết lại bằng python.
Bạn nào dùng thì nhớ nếu tên ban nhạc hoặc album có khoảng trắng, thì thêm vào thành "band name" hoặc "album name" :).

#! /usr/bin/env python
# Script to download Music from Dreammedia.ru
# Try to find your favorite Band and Album, then use this script
# hungnv coded 
import os
import urllib2
import sys
def usage():
        print "Usage:",sys.argv[0], "\"bandname\" \"albumname\""    
        
def st_replace(string):
        new = string.replace(' ','%20')
        return new
            
def download(url,pl,band,album):
        band1 = st_replace(band)
        album1 = st_replace(album)
        temp = (url + pl[:8] + '/' + band1 + '/' + album1 + '/' + pl)
        try:
                response = urllib2.urlopen(temp)
        except:
                print 'Connection error'
        response = urllib2.urlopen(temp)
        content = response.readlines()
        for line in content:
                a = line.find('music/')
                b = line.find('.mp3')
                if a <> -1 and b <> -1:
                        path = line[a:b+4]
                        semi = (url + '%s') %path
                        final = st_replace(semi)
                        os.system('wget '+final)
                else:
                        continue
                        
if __name__ == '__main__':
        band = sys.argv[1]
        album = sys.argv[2]
        url = "http://dreammedia.ru/"
        pl = 'playlist.xml'
        if len(sys.argv) <> 3:
                usage()
                exit()
        else:
                download(url,pl,band,album)
exit()


7 Dec 2009

7-12-09

Tâm trạng đang không tốt, thật sự không tốt, chen lẫn chút nóng giận.
Đôi lúc những gì chúng ta đặt mục tiêu lâu dài không phải sẽ lâu dài, ví như tình bạn chỉ vỏn vẹn...hơn 10 năm cũng chả là cái gì :-)). Thói đời khốn nạn, khốn nạn từng giây từng phút, không thể nào ngờ được.
Cám ơn những cái nhỏ nhặt tưởng chừng nhưng vô nghĩa, nhưng nó mang lại một cái gì đó vô cùng lớn lao như tìm ra được chân lí sống sau một hồi cãi vã, lol. Chỉ là một con người. Đôi khi sống và vui đùa với những cái ảo còn hơn đối diện với những cái thực mà khó lường được chuyện gì sẽ xảy ra. Đôi khi tin vào cái ảo và rồi cái ảo đó thay đổi, mất mát không làm con ngươi ta chết đi được.

10 năm để rồi ra thế này đây, tiên trách kỉ, hậu trách nhân. Cuộc sống đang tồi đi từng ngày trông thấy, nhãm nhí, vô vị, thối nát, ảm đạm.

Vẫn kìm nén được tâm trang không chửi thề ở nơi không nên chửi thể, sao mình giả dối quá. Sống giả thế này bao lâu rồi?
Đồ đồi bại.

Disqus