Skip to main content

Posts

Showing posts from 2008

monitor your filesystem events with inotify-tools

I looking for the way to mirror files on my server to others when something're updated and found that inotify is a good idea in this case. Thanks for inotify-tools project, c library and set of command line programs for linux provide interface to inotify, that let me avoid from c code. On ibex, i get it by.. pnix@pnix-a7n:~$ sudo aptitude install inotify-tools [sudo] password for pnix: Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done The following NEW packages will be installed: inotify-tools libinotifytools0{a} 0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 39.0kB of archives. After unpacking 201kB will be used. Do you want to continue? [Y/n/?] y ... Writing extended state information... Done pnix@pnix-a7n:~$ Below is example shell script i use to moniter and update file to remote host . #!/bin/bash while inotifywait -r

Many sound problems on Intrepid ibex

I upgrade two ibex last night and found few sound problems below First, on video file(mpg,avi ..), when right click and choose >open with >mplayer. will bring up error " [AO_ALSA] Unable to find simple control 'PCM',0 ". I'm not sure what it is, maybe the config just is not right but I fix this by right click on movie window-> preference then on audio tab, select 'Enable Software Mixer'. [or you can do this by change 'softvol = "no"' to 'softvol = "yes"' in $HOME/.mplayer/gui.conf] Another sound issue is flash player on web[like youtube] not play sound. /var/log/message said pnix@pnix-a7n:_NHDT392$ tail -f /var/log/messages ... Nov 2 00:33:14 pnix-a7n -- MARK -- Nov 2 00:40:51 pnix-a7n pulseaudio[23941]: sink-input.c: Failed to create sink input: too many inputs per sink. Nov 2 00:40:51 pnix-a7n last message repeated 31 times Nov 2 00:40:51 pnix-a7n pulseaudio[23941]: protocol-native.c: Warning! Too many con

Fixing shutdown problem in hardy

For a long time my ubuntu box can't shutdown properly(not sure when this start to happen may be since upgrade to gusty). Shutdown progress bar will stop running, harddrive already stop spinning and hang. I guess it because my kernel option "acpi=off nolapic irqpoll" in /boot/grub/menu.lst without these option shutdown script work perfect. So, why i need that?? I just found the way to fix this from ubuntuforums. This is not new, many guy has this problem and it fixed. To solve this problem [for me] 1.add "apm=power_off" to kernel option. 2.add "apm power_off=1" to /etc/modules Reboot and try shutdown again this time it work perfect.

Bootchart on Ubuntu hardy

Today I'm searching for a way to make my box boot up faster and found this tool. Bootchart can use for analyze and visualization boot process. To install bootchart. pnix@pnix-a7n:~$ sudo aptitude install bootchart Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Building tag database... Done The following NEW packages will be automatically installed: librsvg2-bin The following NEW packages will be installed: bootchart librsvg2-bin 0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 121kB of archives. After unpacking 324kB will be used. Do you want to continue? [Y/n/?] y Writing extended state information... Done Get:1 http://mirror1.ku.ac.th hardy/main librsvg2-bin 2.22.2-2 [21.3kB] Get:2 http://mirror1.ku.ac.th hardy/main bootchart 0.9-0ubuntu7 [99.8kB] Fetched 121kB in 1s (90.6kB/s) ... Building tag database... Done

Setup MySQL with Ofbiz

Download ofbiz weekily build and extract it somewhere you want. From your ofbiz directory, edit file entityengine.xml in framework/entity/config add new datasources below localmysql datasource part <datasource name="custommysql" helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" field-type-name="mysql" check-on-start="true" add-missing-on-start="true" check-pks-on-start="false" use-foreign-keys="true" join-style="ansi-no-parenthesis" alias-view-columns="false" drop-fk-use-foreign-key-keyword="true" table-type="InnoDB" character-set="latin1" collate="latin1_general_cs"> <read-data reader-name="seed"/> <read-data reader-name="seed-initial"/> <

Cannot use SUN rmic, as it is not available.

I download ofbiz weekly build[ofbiz_20080602.zip] from sourceforge and try to build it on eclipse. How to config on eclipse? How to use ofbiz with external database ? you can find out from google or may be I'll post here later.:P This post is about error when I run ant build target 'run-install' to load configured data. Below error'll show on eclipse console. ... stubs: [rmic] RMI Compiling 1 class to D:\eclipse_workspace\ofbiz2\framework\service\build\classes BUILD FAILED D:\eclipse_workspace\ofbiz2\build.xml:125: The following error occurred while executing this line: D:\eclipse_workspace\ofbiz2\framework\build.xml:142: The following error occurred while executing this line: D:\eclipse_workspace\ofbiz2\framework\service\build.xml:101: Cannot use SUN rmic, as it is not available. A common solution is to set the environment variable JAVA_HOME or CLASSPATH. Total time: 8 seconds I solve this by browse to Window->Preferences->Ant->Runtime then highlight o

Compile subversion on Fedora core 6

I just move to new company. My first job here is setup a svn on FC6 box. This post is about how i built it. First download, compile and install apache[must be 2.0 version to have same apr version as subversion-deps-1.4.6.tar.bz2] [root@localhost ~]# wget http://mirrors.issp.co.th/apache/httpd/httpd-2.0.63.tar.bz2 ... [root@localhost ~]# tar xjf httpd-2.0.63.tar.bz2 [root@localhost ~]# cd httpd-2.0.63 [root@localhost httpd-2.0.63]# ./buildconf [root@localhost httpd-2.0.63]# ./configure --enable-dav --enable-so --enable-maintainer-mode --prefix=/usr/local/apache20 ... [root@localhost httpd-2.0.63]# make && make install ... [root@localhost httpd-2.0.63]# cd .. [root@localhost ~]# then download subversion source code and the subversion dependencies source code, extract both then go to compile and install apr, apr-util, neon and subversion itself. [root@localhost ~]# wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.bz2 ... [root@localhost ~]# wget http://subversion.t

Try Asterisk on Ubuntu Hardy

I try install asterisk server on ubuntu hardy from repos. The 'asterisk-sounds-extra' is for testing sound[locate in /usr/share/asterisk/sounds/]. pnix@v400ast:~$ sudo aptitude install asterisk asterisk-sounds-extra Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Building tag database... Done The following NEW packages will be automatically installed: asterisk-config asterisk-sounds-main build-essential debhelper dpkg-dev g++ g++-4.2 gettext html2text intltool-debian libc-client2007 libc6-dev libcompress-raw-zlib-perl libcompress-zlib-perl libct3 libdigest-hmac-perl libdigest-sha1-perl libfile-remove-perl libgsm1 libiksemel3 libio-compress-base-perl libio-compress-zlib-perl libio-stringy-perl libmail-box-perl libmail-sendmail-perl libmailtools-perl libmime-types-perl libobject-realize-later-perl libpq5 libpri1.0 libradiusclient-ng2 libstd

Fixing sendmail take a long time to start

I notice that my database box[FC6+Oracle10.2] take along time to startup. Sendmail and sm-client very very slow to start[ about 5 minutes ]. There's something wrong in /etc/hosts file. 'newalises' command take long time to update and finish with error below. [root@ora10g ~]# newaliases WARNING: local host name (ora10g) is not qualified; see cf/README: WHO AM I? /etc/aliases: 76 aliases, longest 10 bytes, 765 bytes total [root@ora10g ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.1.55 ora10g [root@ora10g ~]# To fix this, custom hostname[ora10g] need to append to localhost line in /etc/hosts. [root@ora10g ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ora10g 192.168.1.55 ora10g [root@ora10g ~]# newaliases /etc/alia

Using Datapump on oracle 10g to export/import

This will be update version of this post if you are using oracle 10g or 11g. Last month I post about export/import data in oracle using exp,imp utility. Actually oracle has something newer and better performance if you're using 10g or 11g. Assume that we want to export one table from one oracle db and import it into another oracle db. So create the folder /home/oracle/dbbackup on two oracle db server to store <.dmp> file[that will be created when exporting and importing]. Next, we need to tell oracle to know this folder, create directory on both db by run command below in sqlplus SQL> create directory dmpdir as '/home/oracle/dbbackup'; Directory created. SQL> Now on source database export table with command below. [oracle@k8n ~]$ expdp username/password DIRECTORY= dmpdir DUMPFILE= filename.dmp TABLES= tablename Export: Release 10.1.0.3.0 - Production on Friday, 09 May, 2008 10:54 ... [oracle@k8n ~]$ after finish you will have filename.dmp in /home/oracle/db

Single user mode in fedora core

Again that electricity in area of Sukhumvit road, Bangkok down yesterday night. This time one database refuse to boot it freeze at "Starting system logger:". Look like there's no way to get a shell from any normal run level startup. Not like ubuntu that has recovery mode in grub menu. This box is fedora core, I know there's a way to get in to single user mode by pass kernel parameter at grub boot menu [but can not remember how to at that time:(]. After some googling I found the way. To get single user mode in FC, at grub menu press a [to append kernel parameter]. Now add s to tell fedora kernel that you want single user mode. After finish, enter to continue booting. Now you will get root shell and can figure out what wrong with your system then fix it. In my case now I just want Oracle to come up so i need atleast two service 'network' and 'oracle'. Try to bring it up by run these two command and pray. sh-3.00# service network start sh-3.00# service

Toggle btw compiz&metacity with fusion-icon in Ubuntu Hardy

Since gusty, compiz-fusion will start by default. I love eye candy but for resource shortage reason on my old box, sometime i need to switch to metacity. with alt-f2 and run 'metacity replace' is just work but not convenion. Thank for Tom that point me . Fusion-icon is use to switch between compiz and metacity window manager. For hardy, fusion-icon is in repos. installation is easy like pnix@pnix-a7n:~$ sudo aptitude install fusion-icon Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Building tag database... Done The following NEW packages will be installed: fusion-icon 0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 29.8kB of archives. After unpacking 270kB will be used. ... Building tag database... Done pnix@pnix-a7n:~$ Running : alt-F2 and type 'fusion-icon -n' or if you want this everytime

sudo: timestamp too far in the future

I just finish build the new hardy box at my office. then I go to open the file '/etc/network/interfaces' to add internal ip address and forget something. When I try to open it again, I got this. pnix@hardy-dev:~$ sudo nano /etc/network/interfaces sudo: timestamp too far in the future: Apr 29 01:41:32 2008 pnix@hardy-dev:~$ date Mon Apr 28 18:48:21 ICT 2008 pnix@hardy-dev:~$ I'm not sure why this happen may be some parts of the system using UTC, other parts using timezone-adjusted time. To fix this try code below to clear timestamp. pnix@hardy-dev:~$ sudo -k pnix@hardy-dev:~$ sudo nano /etc/network/interfaces [sudo] password for pnix:

Are you Hardy??

Ubuntu 8.04 LTS code name Hardy Heron just released yesterday. Until now the server still busy, network upgrade[for me] need about 9xx MB download and will take about 1 days and something to do that[on 1mb ADSL from Thailand can you believe? :P]. So I try go for alternative CD . This is pretty much help, download time[for CD] reduce to 2 hours for 700MB. After burning, pop it into CD Drive, it will ask about "Do I want latest pakage from internet?". "Yes" will need more 300MB to download. Anyway it'not a day, estimate time are about 2-3 hours for upgrading. Hope that tomorow I will see hardy desktop on my box.

R4FXO channel did not hang up

Last time , configure r4fxo on trixbox using genzaptelconf command will generate zapata-channels like this. ;;; line="4 FXO/1/3 FXSKS (In use)" signalling=fxs_ks callerid=asreceived group=0 context= from-pstn channel => 4 context=default This look ok except context is set to 'from-pstn', I can make outbound and inbound call with out any problem except the call will never hang up!!!. To fix this problem[from this post ], change 'context=from-pstn'[bold above] to 'context=from-zaptel'.

Running Oracle DBCA(Database Confguration Assistance) remotely

There are two ways to create a new database on existing oracle db server. One is using 'CREATE DATABASE' sql statement[this is too long,hard for me]. Another is using DBCA(Database Confguration Assistance), GUI Base Program. This way is more easy and I choose this way:). One note here is DBCA need X to run and I want to remote login to db server and run dbca from ssh, so ssh need '-X' for X11 forward[assume that DISPLAY variable on server is set, if not try 'export DISPLAY=localhost:0.0' on the server]. [poj@fedev ~]$ ssh -X -l oracle 192.168.1.59 oracle@192.168.1.59's password: Last login: Wed Apr 16 15:11:14 2008 from 192.168.1.122 /usr/X11R6/bin/xauth: creating new authority file /home/oracle/.Xauthority [oracle@k8n ~]$ cd /u01/app/oracle/product/10.1.0/db_1/bin [oracle@k8n bin]$ dbca

export,import data in oracle with exp/imp command

One of database box hang today. It doesn't let me ssh to see what happen, so I just shut it down and try to reboot again. But during boot process, I got "Kernel panic: VFS: Unable to mount root fs on...". err.. look like the disk is gone. Anyway, after few time of cold boot it give me a chance to backup my data:). I don't need all data in database[too many outdate data], so I decide to move some importance table to another database. Oracle has exp and imp utility to do this job. To export table test123 to file test123.dmp type follwing command. [oracle@Oracle-1 oracle]$ exp username/password TABLES=test123 FILE=test123.dmp Export: Release 8.1.7.0.1 - Production on Mon Apr 7 13:22:01 2008 (c) Copyright 2000 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production With the Partitioning option JServer Release 8.1.7.0.1 - Production Export done in US7ASCII character set and US7ASCII NCHAR character set About to ex

Talk to asterisk with Asterisk-java

I just found the java way to talk to my trixbox. With Asterisk-java you can handle call from asterisk server via the FastAGI protocal , use the Manager api to connect to Asterisk server, send action and handle event. Last the Live api instead of using actions and events like the Manager api it use active domain objects (live objects) that represent Asterisk concepts like a channel or an extension. more example on tutorial page .

Adding ip address on trixbox[without X]

On Ubuntu, to manage ip address of the box in console, we need to edit /etc/network/interfaces. By default ubuntu is set to using dhcp as you will see. auto eth0 iface eth0 inet dhcp changing "dhcp" to "static" and add network information auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 will change the box to use static ip address. Adding more ip address on this interface can be done by add script below to the same "interfaces" file.[ note that we have :1 after eth0 ] auto eth0:1 iface eth0:1 inet static address 192.168.1.109 netmask 255.255.255.0 broadcast 192.168.1.255 Trixbox use centos. Like other redhat family, it has system-config-network utility or if you want to play with the configuration file, adding ip address is done by create new file in /etc/sysconfig/network-scripts like in mycase. I have

R4FXO card Installation note

Last year I have played with trixbox for two week and leave it sit under my desk for a long time. Last week I just got a new card to play with. It's Rhino R4FXO[4 FXO ports]. My goal now is make trixbox know the card and config it properly. I start with reinstall trixbox with the almost latest version[trixbox ce 2.4.2]. Upgrade all packages[Include zaptel driver 1.4.9.2-4] note: this zaptel driver is not work with current rhino driver in repos[for now 21/03/08]. It need to manual download the driver and install from console[ more detail ] After base system is ready. Install R4FXO card. 1. Shutdown the box. 2. Put R4FXO card to the pci slot. Boot trixbox again and run command 'genzaptelconf' to generate configuration files automatically. The config file is '/etc/zaptel.conf' and '/etc/asterisk/zapata-chanels.conf'. mine is look like this. [trixbox1.localdomain ~]# cat /etc/asterisk/zapata-channels.conf ; Autogenerated by /usr/sbin/genzaptelconf -- do not han

Shadow Text Effect on JLabel

I found the trick to create shawdow text on JLabel from java forum . Instead of use JLabel.setText() set string to JLabel, he create Image and get Graphics2D by Image.createGraphics(). Then use TextLayout draw overlapping string on that Graphics2D. example code int w = 500; int h = 120; Font font = new Font("Lucida Bright", Font.ITALIC, 72); String text = "Shadow Text"; BufferedImage image = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); adjustGraphics(g); //start off all white: g.setPaint(Color.WHITE); g.fillRect(0, 0, w, h); //draw "shadow" text: to be blurred next TextLayout textLayout = new TextLayout(text, font, g.getFontRenderContext()); g.setPaint(new Color(128,128,255)); textLayout.draw(g, 15, 105); g.dispose(); //blur the shadow: result is sorted in image

using Class.getResource() load resource file in Eclipse

There are many ways to load resource file in java app. What sun recommended is using Class.getResource(" resource_name ") or Class.getResourceAsStream(" resource_name ") then you will get URL and InputStream respectively. If resource_name is specified without "/", it will be prepend with Class package. So resource file must be in same place[folder structure] as the Class. What I love to do is call getResource() with "/" and put resource file at the root of package. This way i can have separate resource folder. below is in Eclipse, 1. From Package explorer right click src folder->click import 2. In import dialog, Choose General->File System ->next 3. from directory:->Browse to your resource folder. 4. to folder:-> I add "resource" as a folder name under src folder. then click "Finish". In the code, load resource with this.getClass().getResource("/resource/buttons1.png") or this.getClass().getResourceAs

tinymce_imce.patch fixing browse button not showing up

Few week ago, I get tinymce module work on my new site. When I create new content and want to add the picture. Tinymce allow me only add url for an image. Anyway I found another module called IMCE . It work together with tinymce and allow me to upload image from my computer. After installation, I can't see browse button when click add image??? my environments is (Drupal5.7+TinyMCE5.x-1.9+TinyMCE3.0+IMCE5.x-1.0). Many post tell me to add <?php print $closure;?> to page.tpl.php file, that not work for me. mine already have it. Today I found the patch from here . It work well for my case. To apply patch[I do this on my local box then upload tinymce.module and imce_set_tinymce.js to host] pnix@pnix-a7n:drupal$ ls imce tinymce tinymce-5.x-1.9.tar.gz imce-5.x-1.0.tar.gz tinymce_3_0_1.zip tinymce_imce.patch pnix@pnix-a7n:drupal_modules$ patch -p0<tinymce_imce.patch patching file tinymce/tinymce.module patching file imce/imce_set_tinymce.js pnix@pnix

Changing partition label on Ubuntu

I found this howto from community docs while searching for rename my usb drive. Not many times you need to do this but if you want, here is the summary. You need few programs depends on the your partition type. mtools for fat32 ntfsprogs for ntfs e2label for ext2 or ext3 reiserfstune for reiserfs(v3) Install which you need by 'sudo aptitude install [program name]' note : check your partition type by 'mount' or 'df -T'. For me, my usb is fat32 changing label is done by pnix@pnix-a7n:~$ sudo mlabel -i /dev/sdb :: myusbdrive pnix@pnix-a7n:~$ upper command, I just change label to 'myusbdrive'. for other partition types, below are some examples. sudo ntfslabel /dev/sda1 newlabel sudo e2label /dev/sda1 newlabel sudo reiserfstune -l newlabel /dev/sda1 update [many thanks for comment]: for ext2/ext3 you also can use tune2fs like this sudo tune2fs -L newlabel /dev/sda1 note : may be it's need to umount device before try changing label to get it work. T

Embeded Flash in Java Desktop App

Most of examples about playing Flash animation on desktop application I found on the internet to are done by VB. But today I found java version. Flash SWT Plugin[ many thanks to Don Park ], it work very well on my latest project :). To use Flash SWT Plugin, download com.docuverse.swt.flash-0.4.zip and extract it somewhere on local disk. Now our eclipse flash project need to add atleast two external jars e.g. flash.jar[from where we just extract the zip] and swt.jar and now we are ready to code. THE SOURCE To play swf file, all we need is FlashPlayer object and activate it that all. it'll look like this. import com.docuverse.swt.flash.FlashPlayer; public class SWTPlayer { .... private void run() { // TODO Auto-generated method stub Display display = new Display(); Shell shell = new Shell(display); FlashPlayer player = new FlashPlayer(shell); player.loadMovie(0, " yourflashfile.swf "); player.setSize(550, 400); player.activate(); shell.setSize(550, 400);

Install TinyMCE module on Drupal

I'm just choose Drupal to be CMS for my new site. Nothing more than google tell me that it win 2007 Open Source CMS Award :) so just try it. Creating content with drupal is easy but if you want to add image, WYSIWYG editor, you need to install third party module. This post is about how i get this feature for my site. 1. Download TinyMCE WYSIWYG Editor [this will enable the TinyMCE editor to be used with Drupal] you will get file name tinymce-5.x-1.9.tar.gz. Extract it into Drupal modules folder you will get modules/tinymce. 2. Download TinyMCE engine and you will get tinymce_3_0_1.zip. Again extract into tinymce folder from step one. Now you have modules/tinymce/tinymce. 3. Enable TinyMCE module by go to Administer->Site building->Modules TinyMCE should be at the bottom of the page. Enable it. 4. Grant permission to user role by go to Administer->User management->Access control[I'm check only authenticated user] 5. Create new profile by goto Administer->Site Con

Make your eclipse look better on ubuntu

When using eclipse on ubuntu, extra space between items and fonts size make it look awkward. I try to adjust fonts by go to [Window->Preferences->General->Appearance->Colors and Fonts]. This will not much help, reduce fonts size does not change space between item. Here is Eclipse Europa before tweak. Anyway, at last I found the way to make eclipse look more compact from googling. Thank for Wesley and Vladimir Buell for this trick . Create ".gtkrc-2.0" in your home directory enable you to customize gtk object style[more about gtkrc-2.0]. Here is my ".gtkrc-2.0". pnix@pnix-a7n:~$ cat .gtkrc-2.0 style "gtkcompact" { font_name="Sans 8" GtkButton::default_border={0,0,0,0} GtkButton::default_outside_border={0,0,0,0} GtkButtonBox::child_min_width=0 GtkButtonBox::child_min_heigth=0 GtkButtonBox::child_internal_pad_x=0 GtkButtonBox::child_internal_pad_y=0 GtkMenu::vertical-padding=1 GtkMenuBar::internal_padding=0 GtkMenuItem::horizontal_paddin

cvs server on ubuntu gutsy

Note for my first time setting up cvs server on ubuntu gutsy. CVS, a version control system, allow you to work on sourcecode with your team. To install it on ubuntu, we need two packages from repos, cvs and the wrapper. pnix@pnix-a7n:~$ sudo aptitude install cvs cvsd [sudo] password for pnix: Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Building tag database... Done The following NEW packages will be installed: cvs cvsd 0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 1756kB of archives. After unpacking 3973kB will be used. Writing extended state information... Done Get:1 http://th.archive.ubuntu.com gutsy/main cvs 1:1.12.13-8 [1669kB] Get:2 http://th.archive.ubuntu.com gutsy/universe cvsd 1.0.13 [87.4kB] ... Building tag database... Done pnix@pnix-a7n:~$

include external jar into your own exported jar

One problem that almost java guys have is create jar with external jar include. In eclipse it has export function to export project but there's no way to add external jar with this method. Today I found one solution, the project Fat Jar Eclipse Plug-In can take care this problem. Installation is just unzip it to eclipse folder then restart eclipse in shell or command line with this command "eclipse -clean". Now your eclipse already have fatjar plugin. To use it export the project, from your package explorer, right click on your project and select "Export...". You will get "Export Dialog"[see pic], choose Other->Fat Jar Exporter. From here you will know what to do next.:)