Thursday 31 July 2008

Howto: trash files from other partitions into 'bin' on Ubuntu

Issue:
---------------------------
When you want to delete some files from another partition which is mounted, ubuntu will prompt you warns dialog, saying "Cannot move file to the Deleted Items folder, do you want to delete permanently?".

I always worried if I delete some files by impulse, because such kind of thing was done by me on Windows.

Solution:
---------------------------
For example, I am used to create a separate partition for '/usr/local' to install some third party big programs.

cross@crossphoto:~$ cd /usr/local/
cross@crossphoto:/usr/local$ sudo mkdir .Trash-1000
cross@crossphoto:/usr/local$ sudo chown cross:root .Trash-1000/

Now /usr/local just like my 'home' folders, if I delete something, I can find them in the 'deleted items'.

Trick/hint:
--------------------------
When other partitions are mounted by the boot, actually they are mounted by the user 'root'. So you, the current user, have no permission to move anything to other folder-bin on that partition.
So create one for yourself, and using sudo to give you the permission to 'write' in that folder. Done.

Wednesday 30 July 2008

this is really nice. sigh...


牛B、装B、傻B之间的区别

牛B永远是少数,
  装B者普遍存在,
  傻B满山遍野到处都是。
  
  牛B的人只有一个女人,
  装B的人女人很多,
  傻B的人的女人的男人很多。
  
  牛B的人不在乎开车还是走路,
  装B的人出门必开宝马,
  傻B的人开吉利美人豹。
  
  
  牛B的人喝的是国宴特供,
  装B的人喝的是芝华士,
  傻B的人喝的是干红兑雪碧。
  
  
  牛B的人穿着板鞋去谈生意,
  装B的人穿者西服去音乐厅,
  傻B的人穿者盛装去麦当劳。
  
  牛B的人点烟别人给点,
  装B的人点烟用火柴,
  傻B的人点烟用zippo还在仔裤上玩花活。
  
  
  牛B的人和国人只说中国白话,
  装B的人爱夹杂着文言文,
  傻B的人说话爱中英文夹杂。Too simple, sometimes na?ve.
  
  牛B的人写文章有自己的风格,
  装B的人写文章爱模仿旧式口语,
  傻B的人写文章像CCTV。
  
  牛B的人有自己的生活方式,
  装B的人模仿别人的生活方式,
  傻B的人模仿不好别人的生活方式。
  
  
  牛B的人就是在游泳池里撒尿都不动声色,
  装B的人想学牛B的人在泳池里撒尿却因为上火尿出黄色液体。
  傻B的人直接在跳台上向泳池里撒尿。
  
  牛B的人需要相处一段时间才会觉得他牛B,
  装B的人刚开始相处觉得很牛B,时间长了才知道是装B,
  傻B的人一开始就让人觉得很傻B。
  
  
  牛B的人一般都自称傻B,
  装B的人也自称傻B,但生怕别人不知道自己牛B而装作牛B。
  傻B的人逢人就称自己牛B。
  
  牛B的人最怕别人说自己牛B,
  装B的人最怕别人说自己不牛B,
  傻B的人最怕别人说自己傻B。
  
  
  牛B的人知道自己牛B,
  装B的人以为自己牛B,
  傻B的人不知道自己傻B。
  
  有实力装B是牛B,
  没有实力的装B是傻B。
  
  
  在某种情况下,
  傻B可以进化成装B,
  装B也可以退化成傻B,
  很多时候装B和傻B的界限是模糊的,
  但牛B永远是牛B。


  牛B的人说自己没什么事做,
  装B的人把能把简单的小事弄得很大,
  傻B的人把删除垃圾邮件都说成自己忙的要死,到处找地方收发邮件。

British Motor Show 2008



http://picasaweb.google.co.uk/ukcrossa/2008MotorShow/photo















Tuesday 29 July 2008

平民生活数据整理做的不够好

1。3年没在国内度过夏天了,london曲曲二十几的温度让我非常难受,回想当年都从官方预报的42度都过来了,但是现在忘记了当时的感觉

2。于是乎,进半年第一次在非体育活动中不穿牛仔裤,换了一条国内带来的薄薄的休闲裤,膝盖和大腿上到处都是口袋那种,面料是棉麻。惊奇发现这条裤子居然要收腹才能系上扣子,哎,胖了,现在所有的牛仔和非正式的裤子都不用要带了,庆祝一下我这标准的身材。哈哈。不过去年的时候腰带是必不可少之物,但是现在记不起来当时穿这些裤子的感觉。


Metro上见到的panda baby,在做俯卧撑。
Baby panda
小日本(就这么叫了,爱怎么着怎么着)又搞出来个geisha机器人,貌似挺好玩的。


Wednesday 23 July 2008

ATI brings white screen on Ubuntu Hardy

1. EnvyNG for ATI driver

When switch on desktop effect, it will bring white screen, which hide all the GUI.

$ modprobe fglrx
will get rid of the white screen, but desktop effect can not work.

2. ATI driver from restricted driver.
No white screen, but crash in some minutes after switching on the desktop effect


Sigh!!

http://ge.ubuntuforums.com/showthread.php?s=62e322f49a76f15390544fcaeee98436&t=714034&page=5

Friday 18 July 2008

刚刚才知道sourceforge也被中国封了,气愤死我了

封明慧,我支持;封youtube,我无奈;封我的flickr我忍了,封我的blogspot,我也可以忍。但是中国居然把sourceforge也给封了,这就太过分了。

这摆明是想把中国再一次送进闭关锁国的状态,不知道再次的卖国求荣会在多久以后的将来出现!

反而与之相反的,中国内地大规模的抄袭活动却如火如荼,tudou,youku模仿youtube,可以接受,毕竟外表不像;fanfou模仿twitter,可以忍受,虽然连字数限制都抄袭的一模一样;但是xiaonei把facebook抄袭的一毛不剩,developmen wiki和api的命名方式,就更别说主色调和laytou了,这种无耻的抄袭还获什么奖,搞什么创意大赛,还说中国最大开放平台。

中国的悠久历史使得我们的文明根深蒂固,和日韩相比,外来词汇及名词,我们都分别一个个再起一个中文名字。使得很多像我这种英语很烂的人刚到国外麦当劳怎么说都不会,只是到处去找kfc,因为这个好读;什么bruce Lee,jacky chen, jet lee,都是何许人也,一个个老外兴奋的和我提起来,我的反应让我和他都一头雾水;更别说那些流行天王天后,影视明星了,抱歉,我只知道中文名。

国外的知名网站,如果没有中文版很难打开在中国的市场,在欧美,即便日韩,几乎所有的大型门户网站都可以看到digg,deliciou,facebook这些bookmark或者share的网站;而在中国完全另外一回事,而大为风光的是那些抄袭的龌龊之人。中国这么个搞法,毁掉的是自己的一代又一代,山寨的肆虐确实说明我们民众的强悍,但是只知道抄袭,我们猴年马月能真正培养出自己的诺贝尔奖获得人呢。而且这个年头较量的关键不是‘你能否’,而是‘能否做到最好’。不求精,只求新,只求‘你能我也能’,一辈子只会跟着别人屁股跑。

中国活生生的第二次闭关锁国开始了。

出国之前常听人说,英语不好的人才中英文混着说,那个时候看港片,确实如此,觉得很不屑;后来常常看到类似这样的话”牛b的人只说汉语;装b的人只说英语;傻b的人中英文混着说“。
但是生活中,如果把regent street叫做摄政街,trafalgar square叫特拉法加广场,waterloo叫滑铁卢,china town硬说是唐人街。
相比之下我更愿意中英文混着说,我是尊重其原本的名字,尊重其原有的创意;我不愿意去无耻的抄袭。

试问中国搞封闭的那些官员们,你们是不是傻的啊。真tmd想骂街。

Thursday 17 July 2008

意大利面酱的做法

意大利面酱的制作材料:

主料:1,
两磅GROUND CHUCK BEEF,没有的话就随便找牛肉磨肉好了.2, 两磅ROMAN
TOMATO,就是罗马番茄.椭圆的那种.没有的话找最新鲜的红番茄也好.3,一小盒BABY BELLY FRESH
MARSHROOM.新鲜香姑也行.估计也是一磅左右吧.4,150ML CABERNET SAUVIGNON RED WINE
总之是红葡萄酒5,150 ML EXTRA VIRGIN OLIV OIL.150毫升初榨柑榄油.6,两瓣蒜头,两片BASIL
LEEF(九层塔叶子),一小把意大利香菜(PARSLEY),没有的话去卖调味瓶的地方买干的粉末.7,一点点盐,一小勺细辣椒粉.8,0.5LB
ITALIAN PARMIGIRNO REGGIRNO
CHEESE.总之要半磅这样的芝士(在我这儿是.98/LB)乳白色非常硬的那种.9,一个中等个儿的白洋葱,实在没有的化什么颜色的都行.10,纸盒
包装的碎番茄粒(用于加色加味)POMI TOMATO DICE

意大利面酱的做法:

1.把洋葱切小丁,西红柿切大块,去子,磨菇切大片.PARSLI AND BASIL LEAF 切细.蒜切末.

2.
找个不沾锅,点火,放肉和洋葱进去(对现在不放油!),等热到洋葱和肉都出水和油以后把这些液体滗干.然后加橄榄油进去,放蒜末,出香味后放红酒.然后放
西红柿.盖上锅盖慢慢煮.直到番茄脱皮融化.然后放点纸盒包装的碎粒番茄.然后加PARSLEY,BASIL,CHEESE,辣椒粉,盐.尝尝味道,临出
锅之前放蘑菇

My favorite packages for Ubuntu/Fedora

Packages for Ubuntu
(dpkg --get-selections > mylist: backup all the packages you've installed, and use awk to output the first column)
sudo dpkg --set-selections < mylist && apt-get dselect-upgrade

====
some plugins for fedora:
yum-utils
nautilus-open-terminal
bash-completion
====
Wine
wine-doors

libdvdcss2
*w32codecs
ffmpeg( following packages are not needed:
sudo
apt-get purge libical0 libflash0c2 mplayer-skins libsvga1
python-mpdclient libamrnb3 libamrwb3 libenca0 libggi2 libgii1
libgii1-target-x sshfs)
ubuntu-restricted-extras (this one can solve mp3 and other third party stuff)

For Totem (gstreamer)
gstreamer-ffmpeg and ffmpeg is essential.
other plugins for gstreamer will be helpful.

smplayer(mplayer)

nautilus-open -terminal

--gnome-do

guake/yakuake
terminator

--kmod-ndiswrapper (from fedora 11, run such command "
su -c 'yum -y install kmod-ndiswrapper' ", after RPM Fusion is installed.

*stardict

vnc4server
vnc4viewer

opera
/epiphany

emesene

gedit-plugins(a lot of plugins for c/c++/java/latex etc.)

lyx(for latex and other formal document writing)
latex-beamer

lynx(command-line web browser)

*vim

*texmaker(+texlive-latex)

Chinese

ndiswrapper (-ma to install driver)

samba(smbpasswd -a user, here this user must exist in the system users database)

=================================
(Extra)

build-essential
gcj
sun-java6-jdk(jfree char lib)
*python (docs,matplotlib,numpy)


eclipse(+cdt,pydev)
compat-libstdc++ (for compatibility of some programs using old gcc binaries)

ipython
idle(python-tools in fedora)
numpy
matplotlib
Octave
QToctave

=============
KDE:
adept (update frequency can be set here easily)
======================
Good application:

mozilla-acroread acroread-plugins

inkscape

audacity
smplayer

miro

vlc

realplay 11
*azureus(vuze, should install from website downloading)

conky
devhelp
okular (pdf reader)

synctree
unison ( make two folders authentic)

easytag

audacity(audio editor)
avidemux(video converter)
kino

gigaget:Thunder( international version (gigaget) with msvcp60.dll)
d4x
gwget
================
patch:

preload
deborphan
powertop
acpitail(to check the temperature, battery)

simple-ccsm (CompizConfig Settings Manager)
ccsm
compiz fusion icon

===============================
For fedora:
smart ( alternative to yumex, which is too slow and costing memory)
rpmfusion-free-package-config-smart

yum-plugin-rpm-warm-cache (to speed up yum)
yum-plugin-remove-with-leaves

favorite Firefox Addons

autofill form
AutoSaveTextToCookie
--autohidestatusba
--Chickenfoot(not in addons)
cookieswap
--cooliris (load entire page and no wrap words)
CustomizeGoogle
delicious
evernote web clipper
*extension backup
firebug
--firefox companion for ebay
flashgot
googleenhancer
google toolbar
greasemonkey
--interclue
*Gmail Notifier(or webmail notifier)
-IE tab
--mouse gestures
*tiny menu(similar to Compact Menu 2 and personal menu )
--piclens
--qtl (+smart link > Hyperwords)
quickdrag
scrapbook // to save web page with good format
ScribeFire
Site Launcher
--Tab Mix Plus
twitterfox
Undo Closed Tabs Button
web developer
webmail notifier

-:for windows --ignorable *need configuration

Wednesday 16 July 2008

recover default gnome setting

if you really need to recover the default settings (in gconf-editor),
then you only need to delete ~.gconf/ and ~.gconfd/ directorys. Then
log back in to the Gnome desktop.

让我觉得崇高,高尚的广告--it's Linux

Saturday 12 July 2008

Java/Jython to read file

All the programs is quite preliminary and in Jython environment.

1. BufferedReader + FileReader
====================
import java.io as ji
fr=ji.FileReader('a.txt')
br=ji.BufferedReader(fr)
text=br.readLine()

2. FileInputStream + BufferedInputStream + DataInputStream
====================
import java.io as ji
fis=ji.FileInputStream('a.txt')
bis=ji.BufferedInputStream(fis)
dis=ji.DataInputStream(bis)
text=dis.readLine()

3. FileInputStream + BufferedInputStream + InputStreamReader + BufferedReader
====================
import java.io as ji
fis=ji.FileInputStream('a.txt')
bis=ji.BufferedInputStream(fis)
isr=ji.InputStreamReader(bis)
br=ji.BufferedReader(isr)
text=br.readLine()

Wednesday 2 July 2008

Regular Expressions for grep, sed, awk

One of the examples in last week's tip used the following awk statement to extract, from a file named unixfile, lines (records) that contained the string "learn" in them:

awk '/learn/ { print $2 " " $1 }' unixfile
The string "learn" in this statement is a regular expression that is delimited on each end by the forward slash (/) character. In addition to awk, regular expressions are often used with other UNIX utilities such as grep, sed, and vi.

Regular expressions, often abbreviated as regex or regexp, describe a pattern or particular sequence of characters and are used to search for and replace strings.

Most characters used in a regex will represent themselves, but there are special characters (known as metacharacters) that take on special meaning in the context of the UNIX utility/tool in which they are used.

Since the topic of regular expressions is quite extensive, this brief overview will only focus on two of its frequently used positional or anchor metacharacters, the caret (^) and the dollar sign ($).

The caret is used to match at the beginning of a line, and the dollar sign is used to match at the end of a line. Carets will logically be found on the left-hand side of a regex, and dollar signs on the right.

To demonstrate the usage of these two positional metacharacters, the same data file used for last week's tip will be used again this week. The only change made was the insertion of 4 blank lines between each line of text. The file unixfile now contains the following data:

unix training

learn unix

unix class

learning unix

unix course

Using grep, all lines in unixfile that begin with "unix" will be extracted with the help of the caret metacharacter:

# grep '^unix' unixfile
unix training
unix class
unix course

Removing the caret from the beginning of the regex and adding a dollar sign to the end will cause grep to display lines ending with "unix":

# grep 'unix$' unixfile
learn unix
learning unix
These two metacharacters can also be combined in a single regex to identify/manipulate blank lines. The -c option for grep will be used with a regex containing both the caret and the dollar sign to count the number of blank lines in unixfile:

# grep -c '^$' unixfile
4

You may recognize that this regex would be useful for removing blank lines from a file when needed.

Experienced UNIX system administrators and shell script programmers understand that becoming skilled in the use of regular expressions is essential for using standard UNIX utilities (e.g. grep, awk, sed, and vi) to their fullest potential.

GREP

grep searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.”

AWK

Awk scans each input file for lines that match any of a set of patterns specified literally in prog or in one or more files specified as -f progfile. With each pattern there can be an associated action that will be performed when a line of a file matches the pattern. Each line is matched against the pattern portion of every pattern-action statement; the associated action is performed for each matched pattern.”

SED

“The sed utility is a stream editor that reads one or more text files, makes editing changes according to a script of editing commands, and writes the results to standard output.”

# 在file 1中找到含有firststring那行,并在第二个空格之后加入secondstring。
# 注意 s/set1/set2/g, g用来代表全局替换,而2则表示再第二次出现的时候替换。
sed -i '/firststring/ s/ / secondstring/2' file1

# 在file 1中最后那行的末尾加入finalstring。
sed -i '$ s/$/finalstring/' file1


REGULAR EXPRESSIONS

Regular expressions allow you to use variables in your commands. Most of us are at least familiar with *, where *.db means “every file ending in .db”. There are however many useful regular expressions, and they are the key to executing the above commands efficiently. Brush up on regular expressions here.

PIPES AND REDIRECTS

In order to send the results from one command to another command you need to “pipe” them together. An example:

cat *.txt | grep "blatti.net"

cat *.txt will display the contents of every file that ends in “.txt” to the standard output. By piping those results, they become the input for the second command. grep "blatti.net" will take the standard input, and display each line that contains “blatti.net” on the standard output. So when these two commands are piped together, we will get every line that contains “blatti.net” in every file that ends in “.txt” in the working directory.

While most of your work can be done with standard input and output, you’ll probably want to write your results to a file. Enter redirection. Using the example above, lets say we wanted to take our results and write it to a file. This is done with the > redirector.

cat *.txt | grep "blatti.net" > results.txt

This command will take every line that contains “blatti.net” in every file that ends in “.txt” in the working director, and write them to the file “results.txt”. Note that this will overwrite any existing “results.txt” file that exists in the working directory. Which begs the question “What if I want to append instead of overwrite?” Well then use >> instead of >. The >> redirector is especially useful if you are creating logs.

Now you too can create obnoxious commands with limited knowledge! The command below is one I created using the resources listed in this article. It is part of a piece of software that pulls text out of a PDF and returns a specified section in a text file. (I’m sure it is inefficient - so someone chime in and tell me how to make it better so I’ll know for next time)

sed 's/^[0-9]$/Period &/’ /tmp/skypdf.txt | sed ’s/[A-Z]*$/&,/’ | sed ‘/Period/G’ | sed ‘$!N;s/\\n/ /’ | sed ‘/Period/{x;p;x;}’ | sed ’s/^ //’ > ~/Desktop/full.txt”

Now say that 10 times fast!



Php console came out

install php-cli you will have the console similar to python for php programming.

  • php -a: console environment
  • php -r <command>: run single php command line like what 'python -c' does. ( must end with ';')
  • php -f <php file>: just for pure php codes, if there are some html codes, it still works, but will pup up a lot of html tag.

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter