YJ Park's profileYJParkPhotosBlogListsMore ![]() | Help |
|
|
8/1/2007 Web park prototype release (See more than 1 pages in one tab)Current I am using a relative big screen(22' widescreen LCD) which is
at 1680X1050. It's pretty good, but it's hard to utilize it when
surfing web, most web pages will only take a small part of the whole
screen, for example a maximized firefox browsing google will look like
this: As you can see, two different pages are shown together(it's configurable, if you have a really big screen, you can show more than 2 pages). and click on google's search result will load the page on it's right, so to me, means a lot of tab operations become needless. This project is currently in a very early stage, only have some basic functions, if you want to try it out, just visit http://yjpark.3322.org/webpark, click the left-top button to install an extension for firefox (It's needed to add hook to user's click) The second button is for login which is not implemented yet, the third can config how many pages you want to see in the window, the fourth can add a new page. on right side, each opened page will have a thumbnail(currently all same, will customize it in the future), you can click on it to switch(sub page will have no thumbnail, a sub page is the one which supposed to be on a new window, but with the extension, I can catch it and display it on right of the original page). the small buttons on top of each page can be used to maximize and close a page. 12/11/2006 Backup svn local modificationsWhen we are working on a task,
our local modifications are not in repository yet, so it's not safe, I
don't want to make branch just for backup, so I wrote a script to
backup local modifications, here is the script: backuptask #!/bin/bash You need to have a file named as 'TASK' in your working directory, it has only one line with the task's name, I put my backups in '~/tasks/' , you can change it if you want, and I scp the backup file to yjpark@exobox, you need to change the user and host name. Use kompare for svn diff and code reviewsBefore commit, we
need to read the diff, that is done by svn diff, while the result is
not easy to read, using kompare, the diff is much easier to read, here
is the script I use for this svndiff if [ $2 ] ; then If provided two parameters, this command will show svn diff of two revisions, with 10000 lines context(I just want to see the whole file if there is diff, this is useful for doing code reviews), pipeline the output to kompare; otherwise, It will just use kompare to show the output of svn diff, 11/16/2006 Turbo dojo widgetsBackground
In our project, we chose dojo as the AJAX toolkits, we use dojo widget programmatically, it's easy to use and easy to extend, but dojo's widget has big performance problem in our project. In one page, we can have thousands of widgets, creating a widget in dojo is really slow, showing such a page needs like 20 minutes 100% CPU usage, it's far from acceptable, so I have to figure out some method to boost dojo dramatically. dojo's widget is very powerful, you can define attach points and connect events in the templates, then dojo will parse the templates and pick up all the custom tags and process on them, after reading some dojo source code, I found out that the template parsing is the most time consuming part in widget creations, it takes like 80-90% of the whole time, so I decided to try to optimize this part first. Every time creating a widget with dojo.widget.createWidget(), the template of that widget will be parsed, that is actually not needed, every kind of widget will have same template, so the result of the first parse can be cached, then it's not needed to parse the same template anymore. I've seen some one in dojo's maillist talking about cloning a widget, I think it's the same idea I have here, but I don't have enough time to actually patch dojo to have a faster widget creation, so I first do some work to help our project running fast with dojo. As I said before, our project create all the widgets in javascript, my turbo way only work in this scenario, if you want to use the widgets in html, this post can not help you. My trick
common/turbo.js dojo.provide("common.turbo");
The logic here is simple, in our javascript code, we call common.turbo.createWidget() instead of dojo.widget.createWidget() to create a widget. In common.turbo.createWidget(), it will call dojo.widget.createWidget() to create the first widget, so I don't need to write code to parse template and can keep using most of dojo's power(will talk about the limitation later), then after got the widget created, we check whether it has a method named as turboInit(), if it does, then means this widget is one of our turbo widgets, then we can use common.turbo.cloneWidget() to get a clone and cache it, then if the same type of widget is needed in the future, the cached prototype can be used to make another clone, then we make sure dojo's slow widget creation will only happen once per type, that is acceptable. Here is an example of turboed widget dojo.provide("common.widget.Button2");
This is a subclass of dojo.widget.html.Button, in turboInit(), it rebuild the dojoAttachPoint from domNode, and attach events. The usage of Button2 is same with other widget, just use common.turbo.createWidget() to create it. By using this simple technology, our ajax page is pretty fast now, the same page now only takes like 20-30 seconds in widget creation part. Then with some lazy loading tech, our project is fast enough now. The limitation of this approach
The dojoAttachPoint and dojoAttachEvent only works for the first widget, all cloned widgets needs to set them up in turboInit(), now for my own widget, I just don't use them in templates, in the case of changing a current widget like the example of Button2.js, I leave them in template and setup them up again in the turboInit() now. And for better perforamnce, I didn't call all the functions dojo calls when create a new widget, e.g. postMixInProperties() and postCreate(), it's easy to call them in common.widget.cloneWidget(), while in our project it's not needed. The simple clone in common.widget.cloneWidget() is not a deep one, I think this is better, you can choose deep copy some property of reinitialize it in turboInit(). Not all properties needs to be copied, actually some of them may have wrong value after the copy. Future work
As I said, if I add the similiar hack to dojo's framework, then it's possible to just make all template parsing cached for all type of widgets, and don't need the turboInit() trick. This may or may not be easy, if I got time, will try to figure it out. 9/21/2006 Use Mpd to Stream Music as Internet RadioMpd can work with icecast for streaming music, but the current statble version doesn't include this feature yet, so you have to check out the latest code from svn, here are the commands I used to build it. sudo apt-get install icecast2 sudo apt-get install autoconf automake1.9 libtool makesudo apt-get install libshout3-dev liblame-dev libmad0-dev libao-dev libflac-dev libasound2-devsvn co https://svn.musicpd.org/mpd/trunk mpdcd mpd./autogen.sh./configure#make sure the shout is enablemakesudo make install Or if you are lazy can download the binary I built, but make sure to install the needed libs wget http://yjpark.googlepages.com/mpdsudo mv mpd /usr/bin In your mpd configuration (/etc/mpd.conf or ~/.mpdconf), add these lines audio_output { type "alsa" name "local playback"} ################# SHOUT STREAMING ########################## Set this to allow mpd to stream its output to icecast2# (i.e. mpd is a icecast2 source)#audio_output { type "shout" name "yjpark's stream" host "localhost" port "8000" mount "/yjpark" password "******" quality "10.0" # bitrate "64" format "44100:16:2" # Optional Paramters user "source"# description "here's my long description"# genre "jazz"} # end of audio_output########################################################## If you don't want to hear the music from the computer's local speaker, can remove the first audio_output section. You need to change the name and mount point and password, and can change the quality or bitrate and format if you want, for more detail please check icecast2's documents. And you need to edit /etc/icecast2/icecast.xml, the only things I changed are source-password(same as the one in mpd configuration), and admin-user, admin-password(can use this to admin through web interface) then restart icecast2 and mpd, play some songs, then you can use a browser to connect to http://localhost:8000, you should see the source played by mpd, then can listen to it using an radio player(amarok, rhythembox, xmms...) For the guys in ExoWeb, you can listen to the same songs I am listenning with http://yjpark:8000/yjpark.m3u (Hope this will not slow down my machine too bad :) ) Links: * http://my.opera.com/chongmeng/blog/show.dml/362421 * http://mpd.wikia.com/wiki/Configuration * http://etnoy.broach.se/2006/06/your-own-internet-radio-station-with-mpdicecast.html Fix on ncmpc to make chinese display workingNcmpc is a command line mpd client, it's very good, but the chinese support has some problem, in the song list window, chinese names are truncated. At first I thought might be some unicode bug in it, after read some source code, here is what I found: it deal with unicode correctly, the problem is it didn't consider the wide-charactors like chinese charactors, so in the list window, it just show the correct chinese charactors then erase some of them later. change two lines this is ok. the patch is Index: src/list_window.c===================================================================--- src/list_window.c (revision 4813)+++ src/list_window.c (working copy)@@ -203,10 +203,10 @@ if( show_cursor && selected ) wattron(lw->w, A_REVERSE); + if( fill )+ mvwhline(lw->w, i, 0, ' ', lw->cols); //waddnstr(lw->w, label, lw->cols); waddstr(lw->w, label);- if( fill && len<lw->cols )- mvwhline(lw->w, i, len, ' ', lw->cols-len); if( selected ) wattroff(lw->w, A_REVERSE); Using the following commands, you can build ncmpc automatically. sudo apt-get install build-essentialsvn checkout https://svn.musicpd.org/ncmpc/trunk@4813 ncmpccd ncmpcwget http://yjpark.googlepages.com/ncmpc_chinese_patchpatch -p0 < ncmpc_chinese_patch./autogen.sh./configure --enable-artist-screenmakesudo cp src/ncmpc /usr/bin/ Or if you are lazy, can just download the binary I build and try it wget http://yjpark.googlepages.com/ncmpcsudo mv ncmpc /usr/bin/ Can edit ~/.ncmpc/config to setup ncmpc, here is my settings auto-center = yeswide-cursor = yesenable-colors = yes set-xterm-title = yesxterm-title-format = "[[%artist% - ]%title%]|[%file%]" And if you want to run ncmpc in real console(not gnome-terminal or xterm), you can use zhcon(just apt-get), I cannot run zhcon with fb driver, here is how I start it zhcon --utf8 --drv=vga the --utf8 is needed for ncmpc to working correctly, and you can edit .zhconrc to change defaultencoding to GBK for better compatibility. It's still not perfectly running ncmpc in zhcon, especially there are some bad encoding strings in your songs' tags. Using mpd to play musicLately I moved to use mpd for my music playing, mpd is "Music Player Daemon", as its name says, it's a daemon to play music, not like amarok or rhythembox, it do not need X windows at all, so the music will not stop even if you restart X, this is one advantage of it, others includes multiple clients to control it, from command line tools, scriptable tool, web pages, X clients; very easy remote control; low resource requirement. And it's easy to stream as internet radio(will talk about this later in another post) mpd's website: http://www.musicpd.org/ there you can find kinds of clients for it, Personally I like ncmpc and pympd(not listed there) most, ncmpc base on ncurses lib, so console base, it's very easy to use with keyboard. pymod is a python client looks like rhythembox. To install mpd, under Debian or Ubuntu sudo apt-get install mpd ncmpc is in both Debian and Ubuntu too, but pympd is not avaliable to Ubuntu yet, you can install it by sudo apt-get install python2.4-profiler build-essentialwget http://jaist.dl.sourceforge.net/sourceforge/pympd/pympd-0.07.tar.gztar xzvf pympd-0.07.tar.gzcd pympd-0.07makesudo make install Ncmpc does not support chinese well, it support unicode, but for chinese like double byte, it will not show the song list correctly, some part is cutted, after some research in ncmpc source code, I finally resolve this problem. (Again, will talk about this in another post) 9/15/2006 Install Internet Explorer on Linux for TestingWe need to test our site under Internet Explorer, to me this is the only reason I need to install vmplayer on my Debian machine, it works fine, but a little bit slow and complicate, the Wine project is used to provide windows api on linux, so it's possible to use it to run IE without a virtual machine, but the setup is not very easy for it, I did try once, didn't get it. Recently I know that there is an open source project for this, the name is ies4linux. It's objective is download IE's installer and setup wine then install it automatically for you, it works great, The only problem I met is the download process is not very reliable, I need to run it several times to get it installed successfully, so I include the files I downloaded, it only has IE6 in it, if you want to install other version, you need to download them by yourself. For the ExoMates with exosetup installed, you can do: exosetup import nordicbet cd /tmp sudo exosetup install nordicbet-ie If you do not have exosetup, you can just run the following scripts: apt-get install wine cabextract mkdir ~/.ies4linux cd ~/.ies4linux wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/downloads.tar.gz tar xzvf downloads.tar.gz rm downloads.tar.gz cd /tmp wget -nd -N -r http://exobox.lan.exoweb.net/~yjpark/exosetup/nordicbet/ie/ies4linux-2.0.3.tar.gz tar xzvf ies4linux-2.0.3.tar.gz cd ies4linux-2.0.3 ./ies4linux ies4linux: http://www.tatanka.com.br/ies4linux/index-en.html 8/8/2006 Runing Postgresql in Ramfs for Great Performance in TestingAs a database server, postgresql make a lot efforts to make the data as secure as possible, but in some certain cases, we don't need these features, we just want it as fast as possible, e.g. in testing. When doing testing, postgresql will access disk to write the data and logs, cause a very big iowait. By running postgresql in ramfs, we can make it much faster.
Ramfs is just using ram to simulate a file system, it's in ram, so it's very fast, of course you need to have enough ram for that.
Here is the script I use to start a second postgresql server at a given port:
After the server start, need to do some setup:
Using it in nordicbet team:
the postgresql port support is in trunk now, you can just add these two lines to your local config:
After setting this, I can run the ftest 30% to 40% faster, I think it's pretty worth doing. 6/16/2006 Javascript Regular Expression TipsLately, I wrote some javascript+DHTML page, in this page, I use javascript's regular expression a lot, it works fine, very flexible and powerful. but when I did the browser compatibility tests, there are quite some issues, I think they are very important if you want to use similar technology, so I list some of them here 1. Internet Exporer's regular expression implementation seems has some performance issue, some particular searches are VERY slow in ie, I write a page for that, you can use your browser to test it. it's url is http://yjpark.googlepages.com/regex_test.html 2. Browsers may change a object's innerHTML after parse, e.g. <tr class="a"> will become to <TR class=a> in Internet Exproler, and become to <TR class="a"> in opera. And in konqueror, it will remove all the html comments in innerHTML. 3. In Mozilla under Windows, it will replace all \n to \r\n But in same version Mozilla under Debian Linux, this will not happen. 6/9/2006 Use kdesvn for Easier svn Browsingsvn is very easy to use, but if you want to browse the files in it, and tired of typing commands, you can use some gui svn tools for it. I tried esvn and kdesvn, think kdesvn is very useful, and it can use kompare to show the diff. If you are using debian, just 'apt-get install kdesvn' Tip: 'diff revisions' is under 'Subversion' -> 'General', and its result depends on the current selected files/folders, so if you want to see the whole diff, you need to select the root folder or just select nothing Share Music, Page 2New client for daap accessThe current rhythmbox in Debian testing(0.9.4.1) already has the ability to access daap shares now, but by default, it will not install the library for daap access, you can install it byapt-get install rhythmbox avahi-daemon Allow multiple programs play sound at the same timeby default there is only one program can output to the sound card, it's possible to allow multiple, here is my configuration, you need to put then into ~/.asoundrc pcm.nforce-hw { type hw card 0 } pcm.!default { type plug slave.pcm "nforce" } pcm.nforce { type dmix ipc_key 1234 slave { pcm "hw:0,2" period_time 0 period_size 1024 buffer_size 4096 rate 44100 } } ctl.nforce-hw { type hw card 0 } Be careful, for better sound quality, I am using the spdif(digital optical, IEC958, different name, same stuff in this case) output as default, you may need to change hw:0,2 to hw:0,0 to use the anolog output. You can use 'aplay -l' and 'aplay -L' to see the current avaliable alsa devices and current pcm setting P.S. Just found out this setting will make the sound recording not working, so if you want to use something like skype, you can not use my setting. If you know how to make the multiple source and recording work together, please add a comment, thanks. I have tried to follow some tips on that, not lucky with them, and I don't care this function now, so will not spend more time on it. 5/16/2006 Use Kompare for Better Format DiffAs a programmer, diff is an everyday tool for me, but the text only output of diff is quite hard to read, comparing to Trac's colorful source browser. Spend little time to try some graphic diff tools, I like kompare most, it's very easy to use, and the output is very nice. You can just 'apt-get install kompare' if you're under Debian. Tip: for use it with svn, you can do 'svn diff | kompare -' 4/27/2006 Debian Testing Upgrade ProblemToday I did a apt-get upgrade, everything goes well, but when I try to reboot, it just stuck, waiting for mounting root filesystem for ever. It's good that I have a system rescue cd with me, seems the file system is very well, not know what's wrong, but after restore my /boot folder, it just works fine again. 4/24/2006 Be Careful About Dict's KeyI am trying to improve performance of some python code, in it, found out some big object are used as dict's key. It seems in python, it use repr(obj) to calculate it's hash instead of it's pointer. So using object as key is much slower than using it's pointer or some unique id, in my case more than 20 times slower. So after change this, just save more than 40% for a relative large data input. 4/3/2006 Remotely Running X ProgramFor thost that don't know that yet. If you want to remotely run a x program, it's very easy and secure with ssh. run 'ssh -X user@host' in xterm or gnome-terminal, that's all, then you can start program in it, the window will just pop up to your screen. 3/30/2006 Access Samba Network Under GnomeI am using Debian testing now, after the default installation, the smb:// is not working in nautilus, there are two packages need to be installed apt-get install gnome-vfs-extfs libgnomevfs2-extra 3/29/2006 Setup ssh to use public key authentication (without input password)Under Linux, we use ssh and scp a lot, just tired of input password all the time, I know there is some way to do it, but always too lasy to check it out. Thanks Vincent for telling me how to do this. I think most of you should already know how to do it, if you still type in password all the time, this is very simple and useful. First you need to generate a public/private key pair to identify yourself, use 'ssh-keygen -t dsa' Then you need to add the generated public key to the remote host, here is how I do it At Local Machine scp id_dsa.pub yjpark@exobox: ssh-addAt Remote Machine: mkdir .ssh chmod 600 .ssh cd .ssh cat ../id_dsa.pub >> authorized_keys chmod 600 authorized_keys That's all make sure that .ssh and authorized_keys is not accessed by anyone except the owner, otherwise it will not work How to setup window's background color under GnomeIn current version of gnome, there is no tools for setting up background color of window, it's background setting only change desktop's background. I really don't like white background, I want the background gray, so I setup some applications's background manually, but some application do not have background color setting(e.g. some versions of Eclipse), and it's not a good way to do that, so I spent little time on it. First I tried some themes, some of them has gray background, while I don't like there colors setting, so what I need to do is to modify some themes to fit my requirement. In gnome's theme setting -> Theme Details, you can choose different setting of Controls, window Border or Icons, window's background belongs to Controls, I picked up !LighthouseBlue as a base setting. The themes file are under /usr/share/themes, I only modified gtk-2.0/gtkrc bg[NORMAL] = "#D0D0D0" //background color of window base[NORMAL] = "#CCCCC0" //background color or controls That make me quite happy. I didn't find good tool for editing theme, there is a definition of the values Sharing Music Between UsListening to music is very important to me, make me more concentrating and much happier working. But sometimes I may want to listening something new, radio is not bad, while you can not control over it, sharing music between us will be a good idea, this blog is telling how to do that under debian linux. I like iTunes very much, it's very good to listen and manage music files, and it's sharing is very good. Unfortunately there is no iTunes on linux, and running it in a virtual machine is not very comfortable, so I spent a little time to find out what we can get under linux for music sharing. I choose mt-daapd to share my music to others, and git(Get It Together) to play music from others' machine. I have put the install script to ExoSetup, you can install it by running exosetup import yjpark exosetup install yjpark-jdk1.5 exosetup install yjpark-music There are only very few settings you need to change for mt-daapd, in /etc/mt-daapd.conf admin_pw your password to admin the server mp3_dir where you put the music files, should be readable to all users serverName name of your music service You can admin mt-daapd by browser, just goto http://localhost:3689 git is written by java, that's why we need to install jdk1.5, and the current chinese fonts support is only done under jdk1.5, so I suggest you install it. And the chinese fonts using simsun.ttc, if you install your chinese font by using 'exosetup install chinese', then it should be under /usr/share/fonts/truetype/simsun/ If not, you need to specify the right path in /usr/lib/j2sdk1.5-sun/jre/lib/fontconfig.properties git has its own server, but I think mt-daapd is better, and I use amarok to play local files, you can disable it under Settings |
|
|