tag:blogger.com,1999:blog-84677863682322921312024-02-08T12:53:59.248+08:00Chee Seng Tech BlogWhen you think you are superior, you are being an idiot...Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-8467786368232292131.post-22511786040316358552012-02-02T20:32:00.003+08:002012-02-02T20:38:05.187+08:00Scala : Accessing Trait Inner ClassFor example you have:-<br /><br /><code><br />package test<br /><br />trait A {<br /> class B {<br /><br /> }<br />}<br /></code><br /><br />You can use test.A#B to access class B in other class, for example:-<br /><br /><code><br />import test.A<br />type B = A#B<br />val b = new B<br /></code>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-80666592933635265002011-05-27T14:28:00.003+08:002011-05-27T14:41:13.535+08:00i7's Turbo-Boost in ActionThe following steps in Ubuntu Natty show turbo-boost in action on my new laptop, which is quadcore 2.0GHz, boost-able to 2.8/2.9GHz:-<br /><code><br />sudo apt-get install acpidump<br />sudo modprobe msr<br />sudo turbostat<br /></code><br />Turbostat shows the following stat while my laptop is not doing heavy thing:-<br /><code><br />CPU GHz TSC<br />avg 0.80 2.00<br />0 0.80 2.00<br />1 0.80 2.00<br />2 0.80 2.00<br />3 0.80 2.00<br />4 0.81 2.00<br />5 0.80 2.00<br />6 0.80 2.00<br />7 0.80 2.00<br /></code><br />Let's make the processor's cores busy, open another terminal and enter:-<br /><code><br />while :; do :; done<br /></code><br />Now the stat shows:-<br /><code><br />CPU GHz TSC<br />avg 2.86 2.00<br /> 0 2.77 2.00<br /> 1 2.87 2.00<br /> 2 2.70 2.00<br /> 3 2.74 2.00<br /> 4 2.77 2.00<br /> 5 2.81 2.00<br /> 6 2.76 2.00<br /> 7 2.77 2.00<br /></code><br />Cores are working hard, enjoy!Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-212565346395340182011-05-08T15:01:00.002+08:002011-05-08T15:15:08.879+08:00Learning Scala - Code Update without Redeployment via JRebelScala Developer entitles to free license from JRebel, just request it from ZeroTurnaround (<a href="http://sales.zeroturnaround.com/">http://sales.zeroturnaround.com/</a>), the license will be emailed to you in minutes. You'll need to download and install JRebel as well.<br /><br />Having done so, you are only 2 steps away from code update without redeployment.<br /><br /><b>Step 1</b><br />Changed your sbt launch script, I have changed mine to:-<br /><br /><code><br />#!/bin/sh<br />java -Xmx1512M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m <b>-noverify -javaagent:/opt/ZeroTurnaround/JRebel/jrebel.jar</b> -jar /opt/sbt/sbt-launch-0.7.5.jar "$@"<br /></code><br /><br />Note that I installed my sbt jar in /opt/sbt/ and JRebel in /opt/ZeroTurnaround/JRebel/.<br /><br /><b>Step 2</b><br />Change your Web Project build class:-<br /><br /><code><br />import sbt._<br />class WebAppBuild(info: ProjectInfo) extends DefaultWebProject(info) {<br /><br /> val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.14" % "test" <br /> val servletApi = "javax.servlet" % "servlet-api" % "2.5"<br /><br /> <b>override def jettyWebappPath = webappPath</b><br /> <b>override def scanDirectories = Nil</b><br />}<br /></code><br /><br />That's all for the setup, now you can launch sbt in your project directory and test:-<br /><br /><code><br />jetty-run<br />~ prepare-webapp<br /></code><br /><br />Go ahead and change your Servlet source file, upon saving, you can refresh your web browser to see your changes immediately, without the need to redeploy the whole web app.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-90500174835988010442011-05-08T12:13:00.004+08:002011-05-08T12:20:01.258+08:00Learning Scala - Continuous Redeployment with jetty-runTo make jetty-run to auto-detect and redeploy the web app, run the following commands in sbt:-<br /><br /><code><br />jetty-run<br />~ prepare-webapp<br /></code><br /><br />Now you can change your servlet source code and save, the web app should get compiled and redeployed automatcally.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-92222311765393365902011-05-07T13:04:00.005+08:002011-05-08T12:18:32.032+08:00Learning Scala : Hello World Web App with SBTCreating Project:-<br /><br /><code><br />mkdir HelloWorld<br />cd HelloWorld<br />sbt<br /></code><br /><br />You will be prompted to create new project, type 'y' and enter project name, organization, version etc.:-<br /><br /><code><br />Name: HelloWorld <br />Organization: QQ Enterprise<br />Version [1.0]: <br />Scala version [2.8.1]: <br />sbt version [0.7.5]: <br /></code><br /><br />Required Scala libraries will be downloaded automatically, make sure you are connected to internet.<br /><br />Create WebAppBuild.scala build in project/build/ (create build directory if it's not there):-<br /><br /><code><br />import sbt._<br />class WebAppBuild(info: ProjectInfo) extends DefaultWebProject(info) {<br /> val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.14" % "test" <br /> val servletApi = "javax.servlet" % "servlet-api" % "2.5"<br />}<br /></code><br /><br />In the SBT console, enter:-<br /><br /><code><br />reload<br />update<br /></code><br /><br />Create HelloWorldServlet.scala in src/main/scala directory:-<br /><br /><code><br />import javax.servlet.http._<br />class HelloWorldServlet extends HttpServlet {<br /> override def doGet(req: HttpServletRequest, resp: HttpServletResponse) = {<br /> resp.getWriter().print("Hello World!")<br /> }<br />}<br /></code><br /><br />Create webapp directory in src/main, and consequently create WEB-INF directory and web.xml:-<br /><br /><code><br /><?xml version="1.0" encoding="UTF-8"?><br /><!DOCTYPE web-app<br />PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"<br />"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"><br /><web-app><br /> <br /> <servlet><br /> <servlet-name>HelloWorld</servlet-name><br /> <servlet-class>HelloWorldServlet</servlet-class><br /> </servlet><br /> <br /> <servlet-mapping><br /> <servlet-name>HelloWorld</servlet-name><br /> <url-pattern>/HelloWorld</url-pattern><br /> </servlet-mapping><br /></web-app><br /></code><br /><br />In SBT, run:-<br /><br /><code><br />reload<br />jetty-run<br /></code><br /><br />Open your web browser and go to http://localhost:8080, you should see the Hello World! message being print out from your simple servlet written in Scala.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-56621465865285709242011-03-28T22:48:00.001+08:002011-03-28T22:49:47.134+08:00Rip Movie from DVD iso to mpgUsing mencoder:-<br /><br />mencoder input.iso -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video -oac mp3lame -aid 0 -o output.mpgChua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-69063808732251997592010-11-03T17:16:00.003+08:002010-11-03T17:21:11.385+08:00Get Domain Class's Error Message in Grails ControllerThe following code snippet can be used to get domain class's error messages in Grails (1.2.2) Controller:-<br /><br /><code><br />def errMsgList = domainClassObj.errors.allErrors.collect{g.message([error : it])}<br /></code>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-71442896054026811742010-11-03T17:11:00.004+08:002010-11-03T17:14:38.245+08:00Reset Netbeans JDK HomeI always need to reset Netbeans JDK Home whenever I install new JDK version, this serves as my own note to remember:-<br /><br />To reset, change 'netbeans_jdkhome' entry in {NETBEANS_INSTALL_FOLDER}/etc/netbeans.conf.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com1tag:blogger.com,1999:blog-8467786368232292131.post-20066127107015614592010-09-05T17:43:00.003+08:002010-09-05T17:59:33.654+08:00Integrating BlazeDS to GrailsSebastien has written a very good Grails plugin for using BlazeDS in Grails project:-<br /><br /><a href="http://java.dzone.com/articles/grails-blazeds-4-integration?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fgroovy+%28Groovy+Zone%29">Grails BlazeDS 4 Integration Plugin</a><br /><br /><a href="http://sebastien-arbogast.com/2010/05/13/grailsblazedsflexiphone-full-stack-part13/">Grails/BlazeDS/Flex/iPhone Full Stack Part1/3</a><br /><br /><a href="http://sebastien-arbogast.com/2010/05/14/grailsblazedsflexiphone-full-stack-part-23/">Grails/BlazeDS/Flex/iPhone Full Stack Part 2/3</a><br /><br />If you are like me, who try to integrate BlazeDS by hand (by downloading BlazeDS separately and putting in jars and configuration files into existing Grails project), you must use 'run-war' instead of 'run-app' to run your project or you might get 'Type xxxxx not found' error when invoking a BlazeDS service. I solved this after reading notes in Sebastien's blog:-<br /><br /><b>Run your Grails application using “grails run-war” instead of “grails run-app”. Once again this is a known limitation: Flash Builder BlazeDS data connection plugin relies on a classical web app layout and doesn’t understand Grails dynamic layout (that is until someone manages to create a Grails data connection wizard for Flash Builder 4)</b>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-3388677000452439382010-08-16T14:24:00.005+08:002010-08-26T23:06:03.833+08:00Converting .ogv to .flvI used GTK-recordMyDesktop to record step by step guide. The new recordMyDesktop produce .ogv as the output of the recording session. I tried to convert it to .flv using ffmpeg to the outcome is unusable. Finally, I use combination of mencoder and ffmpeg:-<br /><br />mencoder -oac mp3lame -ovc lavc input.ogv -o middle.avi<br />ffmpeg -i middle.avi output.flv<br /><br />This does what I want.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-12064352980811625662010-08-10T11:57:00.004+08:002010-08-10T12:05:54.463+08:00Enabling Logitech C250 Webcam in Skype 2.1 Beta (Ubuntu 10.04)My Logitech C250 Webcam works with guvcviewer, but does not working directly with my Skype 2.1 Beta. When tested on the Video Device it just gave me a blank screen.<br /><br />To make it work, I perform the following steps:-<br /><br /><code><br />cd /usr/bin<br />sudo mv skype skype.real<br />sudo touch skype<br />sudo gedit skype<br /></code><br /><br />And in the new skype file, type in the followings and saved:-<br /><br /><code><br />#!/bin/bash<br />LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so XLIB_SKIP_ARGB_VISUALS=1 skype.real<br /></code><br /><br />close gedit and change the new skype file access:-<br /><br /><code><br />sudo chmod 755 skype<br /></code><br /><br />Restart your Skype and test again with Video Device.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-36115796172678712772010-08-06T17:35:00.004+08:002010-08-06T18:03:52.843+08:00Including Styles & Resources in Multi-Modules Flex ApplicationI have been developing KZLite <a href="http://www.kzlite.com">http://www.kzlite.com</a> which handle modularization with LoaderInfo class. The purpose of the modularization is simple, a module (a swf file which contains multiple class definition) will be loaded only when necessary. We need that as we have a lot of modules in HRMS software.<br /><br />One of the confusing bumper when loading external swf with LoaderInfo is that control's styles and resource bundles information is not loaded in the main application. For example, my main application use RSL for the flex framework, the RSL will load class definition for ComboBox, DateField, but not their styles and resource bundles information (such as the format string), unless you used the particular component in the main application itself. This is because when compiling the main application, the Flex compiler will find and include only styles and resource bundles information for controls that are used in the main application. However, in case where a control is used in a module but not in the main application (e.g. my main application is just a place holder to load module, and my module may use a DateField control), it will cause a lot of funny runtime errors, something like 'One of the properties is invalid' or 'cannot operate on null' etc.<br /><br />To solve this, I usually have a IncludeClasses.as in my main application that include all control classes that my other modules will use. The following is my example IncludeClasses.as : -<br /><br /><code><br />package<br />{<br /> import mx.charts.BarChart;<br /> import mx.charts.PieChart;<br /> import mx.controls.Button;<br /> import mx.controls.CheckBox;<br /> import mx.controls.ColorPicker;<br /> import mx.controls.ComboBox;<br /> import mx.controls.DataGrid;<br /> import mx.controls.DateField;<br /> import mx.controls.HSlider;<br /> import mx.controls.HorizontalList;<br /> import mx.controls.Image;<br /> import mx.controls.LinkButton;<br /> import mx.controls.List;<br /> import mx.controls.MenuBar;<br /> import mx.controls.NumericStepper;<br /> import mx.controls.ProgressBar;<br /> import mx.controls.RadioButton;<br /> import mx.controls.TextArea;<br /> import mx.controls.TextInput;<br /> import mx.controls.TileList;<br /> import mx.controls.Tree;<br /> import mx.controls.VSlider;<br /><br /> internal class IncludeClasses<br /> {<br /> internal var button:Button;<br /> internal var checkBox:CheckBox;<br /> internal var colorPicker:ColorPicker;<br /> internal var comboBox:ComboBox;<br /> internal var dataGrid:DataGrid;<br /> internal var dateField:DateField;<br /> internal var linkButton:LinkButton;<br /> internal var horizontalList:HorizontalList;<br /> internal var hSlider:HSlider;<br /> internal var image:Image;<br /> internal var progressBar:ProgressBar;<br /> internal var list:List;<br /> internal var menuBar:MenuBar;<br /> internal var numericStepper:NumericStepper;<br /> internal var radioButton:RadioButton;<br /> internal var textArea:TextArea;<br /> internal var textInput:TextInput;<br /> internal var tileList:TileList;<br /> internal var tree:Tree;<br /> internal var vSlider:VSlider;<br /> <br /> internal var pieChart:PieChart;<br /> internal var barChart:BarChart;<br /> <br /> public function IncludeClasses()<br /> {<br /> <br /> }<br /> }<br />}<br /></code><br /><br />And in the init() of the Application, add in this line:-<br /><code><br />new IncludeClasses();<br /></code><br /><br />This will make the Flex compiler to think that those classes are in use and include their styles and resource bundle information.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-35261441273913982612010-08-02T16:26:00.002+08:002010-08-02T16:33:59.845+08:00Configuring ${DOCUMENTS} variable in Flash (Flex) BuilderWhen adding library reference in FB, if the particular .swc file is within the workspace, the FB will use ${DOCUMENTS} variable to refer to the targeted .swc file.<br /><br />I had a problem when I created a maintenance branch in my SVN, being lazy to check out from the branch and re-setup my projects, I copied over my current working copy of trunk and do a quick switch. Every things work well except the ${DOCUMENT} variable is still referring to the old workspace directory.<br /><br />Fortunately, I soon read from <a href="http://nwebb.co.uk/blog/?p=40">here</a> that the ${DOCUMENTS} variable is actually set in the Workspace Preferences:-<br /><br />Window -> Preferences -> General -> Workspace -> Linked Resources<br /><br />You can also configure your custom variable there.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-14069836822061861472010-08-02T14:33:00.005+08:002010-08-02T14:57:55.693+08:00KZLite Payroll : The Quick Start GuidesKZLite Payroll comes with a set of Quick Start Guide (QSG) to assist the user to setup and maintain KZLite according to their own company requirements. The following lists the (QSG) available:-<br /><br /><span style="font-weight:bold;">Initial System Setup</span><br />-Company Setup<br />-Payroll Setup<br /><br /><span style="font-weight:bold;">Staff Record</span><br />-New Staff Joining<br />-Staff Resignation<br />-Staff Confirmation<br />-Staff Promotion / Transfer / Salary Adjustment<br /><br /><span style="font-weight:bold;">Payroll Process</span><br />-Create Payout Record<br />-Pay Salary Twice a Month (Mid Month & Month End Payroll Process)<br />-Payroll Statutory Export & Report (Monthly)<br />-Salary Crediting - Autopay & Report<br />-Advance Salary Processing<br />-Bonus Processing<br /><br />When opened, a QSG shows a booklet style window that will guide you through the process step by step:-<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwgaKnperNVhmvX0Phf8kP6iLVBvOi8xtndxxcyk24V9Ca_JarucywoyxLuGZDlDC2iTr4g2dGy96Yb3sV_uW5_x6UbK8WU5b3PCMm8l_3b8H_O8tVTp1d_DnTQk0GbBfMfQ5EAU4lRuA/s1600/qsg.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 241px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwgaKnperNVhmvX0Phf8kP6iLVBvOi8xtndxxcyk24V9Ca_JarucywoyxLuGZDlDC2iTr4g2dGy96Yb3sV_uW5_x6UbK8WU5b3PCMm8l_3b8H_O8tVTp1d_DnTQk0GbBfMfQ5EAU4lRuA/s320/qsg.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5500701316794434994" /></a><br /><br />For each step, they normally will have a 'Open Screen' link that will open the related screen. This convenient navigation way can greatly improve user's productivity when dealing with complex HR processes.<br /><br />To try it, you can logon to our <a href="http://www.kzlite.com/demo">Online Demo</a>.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-89658039018832028782010-07-27T17:42:00.003+08:002010-07-27T23:28:48.905+08:00KZLite Payroll is now AvailableIt has been a while since I updated this blog, I have been working full-force to reach a release point for the HRMS project written in Flex-Java.<br /><br />The final project name is now fixed : KZLite for the suite name, and KZLite Payroll is currently available.<br /><br />The website URL is <a href="http://www.kzlite.com">http://www.kzlite.com</a>.<br /><br />There's a Online Demo version available (<a href="http://www.kzlite.com/demo">http://www.kzlite.com/demo</a>), or you can download the installer to try it out on your local machine.<br /><br />KZLite Payroll handles Malaysian Payroll Statutory requirements, and has ported many features from our Enterprise version of HRMS system (<a href="http://www.kzensolutions.com">http://www.kzensolutions.com</a>).<br /><br />I will write about some useful tips in coming blogs.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-3785041617108014172009-04-11T11:16:00.009+08:002009-04-11T12:05:42.595+08:00Learning Scala 1 : A Hello WorldScala is a powerful and interesting language to learn. Personally, I like it as the next generation of my daily written Java programming language.<br /><br />To getting started with Scala is easy. Get a Scala distribution from <a href="http://www.scala-lang.org/">http://www.scala-lang.org</a> and unzip it to, for say C:\scala-2.7.3.final and set C:\scala-2.7.3\bin into your PATH environment variable. It requires Java runtime environment version 1.5 or later installed on your machine, I am having Sun JDK 6 Update 13 installed on my Windows XP machine.<br /><br />After the above setup, you can start Scala Interpreter by entering 'scala' in command prompt:-<br /><br /><code><br />C:\>scala<br /></code><br /><br />Alternatively, you can start the Scala Interpreter also by double clicking 'scala.bat' under the 'bin' folder. You should after the Scala Interpreter waiting for your command now:-<br /><br /><code><br />scala><br /></code><br /><br />Now, let's type 3 + 5 into it:-<br /><br /><code><br />scala> 3 + 5<br />res0: Int = 8<br /></code><br /><br />The 'res0' is a generated name to refer to the calculated value. You can try to print it out by using println():-<br /><br /><code><br />scala> println(res0)<br />8<br /></code><br /><br />You can declare 'val' (value) or 'var' (variable) in Scala, 'val' works similar like 'final' in Java, which reassignment is not allowed. You can try reassign the 'res0' to something else and you should get an error:-<br /><br /><code><br />scala> res0 = 9<br /><console>:5: error: reassignment to val<br /> res0 = 9<br /></code><br /><br />Now, let's declare a value call 'myValue':-<br /><br /><code><br />scala> val myValue = "Hello World"<br />myValue: java.lang.String = Hello World<br /></code><br /><br />You can see that I do not declare any type for myValue, the Scala compiler is smart enough to infer the value type to String, optionally, you can write it in the following way:-<br /><br /><code><br />val myValue:String = "Hello World"<br /></code><br /><br />Now, let's print it out:-<br /><br /><code><br />scala> println(myValue)<br />Hello World<br /></code><br /><br />That's complete my 'Hello World' in Scala!. ;-)</console>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-6323376124339560552009-03-27T11:04:00.006+08:002009-03-27T11:44:36.970+08:00ACE for Flex 3 with AIR Exam ClearedAfter a week of intensive reading after working hours, finally I got it through today with 92%. The preparation process was tough for me as the scope seems to be very wide. I studied mainly using the official materials from Adobe, which include:<br /><br />Adobe Flex 3 Developer Guide<br />Developing Adobe AIR Applications With Adobe Flex 3<br />BLAZEDS Developer Guide<br /><br />I didn't study for ActionScript programming as I am coding it in my daily job. ;-)<br /><br />Looking forward to have a great weekend, Cheers!Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com1tag:blogger.com,1999:blog-8467786368232292131.post-20431084628783190062009-01-09T10:28:00.003+08:002009-01-09T10:40:21.265+08:00'Work In Progress' Animated GIF GeneratorI am looking for an nice icon to indicate 'Work in Progress' GIF today and found a nice site which let you customize and generate 'Work in Progress' animated GIF:-<br /><br /><a href="http://www.ajaxload.info/">http://www.ajaxload.info</a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh3Twf7DAgyS5I-u__0QSqla5IFjTcLeGm6VCpiX5ELRLDTH1ygxDE_OfhLCNC8znLr5StNFHD195I3BL6kyavwMnY1tlWqGM4LMZOFIELAMsQM0a7tvy8vd0VIAo7KorDVNXbWAm71Fw/s1600-h/ajaxload-info.PNG"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 289px; height: 155px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh3Twf7DAgyS5I-u__0QSqla5IFjTcLeGm6VCpiX5ELRLDTH1ygxDE_OfhLCNC8znLr5StNFHD195I3BL6kyavwMnY1tlWqGM4LMZOFIELAMsQM0a7tvy8vd0VIAo7KorDVNXbWAm71Fw/s200/ajaxload-info.PNG" alt="" id="BLOGGER_PHOTO_ID_5289117026373054594" border="0" /></a>Customize indicator type, colors and transparency.<br /><br /><br /><br /><br /><br /><br /><br /><br />Generated GIF with 'Bar' indicator:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkDkTEGyqo_s3s2Yl3PC08sLSsAcNm10bMVs-QKSDR2ueNzx-lEPPP9KH5OOMkXc51HEXQxSbA9lTFAtLuk2Dg_UbHyhOK74OXuwDWBfxm1F_nNLTx_iTw3_yb2w9fK0xbb5hhtp12608/s1600-h/ajax-loader.gif"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 17px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkDkTEGyqo_s3s2Yl3PC08sLSsAcNm10bMVs-QKSDR2ueNzx-lEPPP9KH5OOMkXc51HEXQxSbA9lTFAtLuk2Dg_UbHyhOK74OXuwDWBfxm1F_nNLTx_iTw3_yb2w9fK0xbb5hhtp12608/s200/ajax-loader.gif" alt="" id="BLOGGER_PHOTO_ID_5289118018430680194" border="0" /></a>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-70225881203794220602008-12-22T13:01:00.004+08:002008-12-23T12:28:56.419+08:00Solving Table Name Case Sensitive Problem of Mysql on LinuxTable name case sensitivity issue is a common problem to hit when you are trying to port an application to use Mysql on Linux. You can set the Mysql to always store table name in lower case by setting the startup parameter <code>lower_case_table_names=1.</code><br /><br />You can type the following to check if the parameter is set or not:-<br /><code><br />mysqladmin -u root -p variables</code><br /><br />If it is not set, you can set it by editing /etc/mysql/my.cnf:<br /><br /><code>sudo gedit /etc/mysql/my.cnf</code><br /><br />In my.cnf, it should have portions like this:-<br /><br /><code>[mysqld]<br />#<br /># * Basic Settings<br />#<br /><br />#<br /># * IMPORTANT<br /># If you make changes to these settings and your system uses apparmor, you may<br /># also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.<br />#<br /><br /><span style="font-weight: bold;">lower_case_table_names=1</span><br /><br />user = mysql<br />pid-file = /var/run/mysqld/mysqld.pid<br />socket = /var/run/mysqld/mysqld.sock<br />port = 3306<br />basedir = /usr<br />datadir = /var/lib/mysql<br />tmpdir = /tmp<br />language = /usr/share/mysql/english<br />skip-external-locking</code><br /><br />Then, restart the server:-<br /><br /><code>mysqladmin -u root -p shutdown</code><br /><code>sudo mysqld</code>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com2tag:blogger.com,1999:blog-8467786368232292131.post-66599658430844396742008-12-18T16:41:00.000+08:002008-12-18T17:14:14.303+08:00Email, How Reliable is it?Email is one of the most important application in Internet today beside Web. However, it has become a channel where hackers target to steal confidential information such as login info from user. One of the most popular trick is to masquerade and send a fake email, saying the user account is going to expire and ask the user to login with a fake hyperlink, which link to a fake page with similar design to the real login page.<br /><br />From technical point of view, how easy to send a fake email? The answer to this question is : 'It's very simple'.<br /><br />You do not need to write a C program, BackTrack 3 or any hacker tool. You can easily do it with high level language such as Java. It depends on how your email provider securing their SMTP server, but in my case, most of the companies that I have worked with is having their SMTP that you can easily send a fake mail.<br /><br />At very basic level, these few lines of Java code using Spring Framework can masquerade as 'Your Boss' and send out an email to your colleague saying that he is fired:-<br /><br /><span style="font-size:85%;"><span style="font-family:courier new;">JavaMailSenderImpl mailSender = new JavaMailSenderImpl();</span><br /><span style="font-family:courier new;">mailSender.setHost("mail.yourcompany.com");</span><br /><span style="font-family:courier new;">MimeMessage mimeMessage = mailSender.createMimeMessage();</span><br /><span style="font-family:courier new;">MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);</span><br /><span style="font-family:courier new;">helper.setFrom("Boss <your_boss@yourcompany.com><your_boss@yourcompany.com><yourboss@yourcompany.com>");</your_boss@yourcompany.com></your_boss@yourcompany.com></span><br /><span style="font-family:courier new;">helper.setTo("your_colleague@yourcompany.com");</span><br /><span style="font-family:courier new;">helper.setSubject("You're Fired!");</span><br /><span style="font-family:courier new;">helper.setText("I am very unhappy with your face, you're fired!!!");</span></span><br /><br />You still will be able to find out which machine this email is sent from if you examine the email's properties. We joked with one of our colleague years ago with this. She was stunned and we quickly clarified with her before any bad thing happens next, it is sin. However, this shows that most people 'TRUST' email, and they believe it.<br /><br />Do you believe your email?Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-84014581307194040702008-12-18T09:08:00.000+08:002008-12-18T10:40:44.030+08:00A Little Information About Setting up StreamyxDepending on the model of your router, here's some tips that can help you to setup your Streamyx connection:-<br /><ul><li>Use 'your_user_id@streamyx' as username</li><li>Set 'PPPoE' as connection type</li><li>Set VPI =0 and VCI=35</li><li>Default DNS servers : 202.188.1.5 and 202.188.0.133</li><li>New added DNS servers : 202.188.1.4 and 202.188.0.132<br /></li></ul>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-49622763351326408392008-12-15T10:11:00.000+08:002008-12-15T10:23:56.391+08:00Enabling TraceMonkey in Firefox 3.1TraceMonkey is the new Javascript Engine in Firefox 3.1 which is claimed to be 20-40 times faster than the order one. I have not tried out Firefox 3.1 myself yet and will wait for the official release.<br /><br />Here's the steps to make sure TraceMonkey is enabled for both web content and XUL/chrome in Firefox 3.1:-<br /><br />-Open a new tab and type "about:config"<br />-Enter "jit" in filter field<br />-Make sure both "javascript.options.jit.content" (for Web Content) and "javascript.options.jit.chrome" (for XUL/chrome) have the "true" value.Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-31752772736740438452008-12-11T16:09:00.000+08:002008-12-11T16:17:50.094+08:00Strange Oracle Error : ORA-12505I have been using Oracle 10g R2 for development for quite a while. However, when I was starting my application server from Eclipse today (not the first start, it should be near the 10th time after my machine boot in the morning), an exception is thrown saying:-<br /><br />ORA-12505, TNS:listener does not currently know of SID given in connect descriptor<br />The Connection descriptor used by the client was:<br />localhost:1521:orcl<br /><br />This seems to be an TNS error, but I am very sure my last startup works and I never touched anything in Oracle since my last application server startup. I tried with tnsping orcl, it works and I have got no idea what's the cause. I tried restarting the TNS listener, oracle server itself as well as my Eclipse, nothing works<br /><br />Finally, I decided to reboot my machine. And you know what, it works after reboot. Strange?Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com1tag:blogger.com,1999:blog-8467786368232292131.post-53273847850894520162008-12-10T15:16:00.000+08:002008-12-10T15:36:56.368+08:00Updating Flex Builder to 3.2<div class="ft-html"><p>Last week after reading about Flex Builder updates in <a href="http://www.artima.com/forums/flat.jsp?forum=270&thread=243069">Artima.com</a>, I decided to update my Flex Builder 3. So I fired up my Flex Builder 3 and go to:-</p> <p>Help->Search for Flex Builder Updates... </p> <p>However, nothing happens. After googling for a while, I found out that the Adobe Updater is not installed, you need to execute Setup.exe in the following directory:-</p> <p>{YOUR_FLEX_BUILDER_INSTALL_DIRECTORY}/AMT\AdobeAUM5.1All.win<br />.installer/Setup.exe</p> <p>Once it's setup, select again (try restart Flex Builder if it doesn't work):-</p> <p>Help->Search for Flex Builder Updates...</p> <p>The update process should be started.</p> <p>Just wonder why it is not installed during installation of Flex Builder 3?</p></div>Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0tag:blogger.com,1999:blog-8467786368232292131.post-81899394884042694512008-12-10T14:23:00.002+08:002008-12-22T11:04:16.816+08:00Apache Derby to Handle Case Insensitive SearchI have been using Apache Derby which can be bundled easily with the 'Lite' version of the product that I am developing in Flex/Java. The fact that by default Derby gives different result set for "where name='chua'" and "where name='CHUA'" has been an egg on my face. Using UPPER/LOWER with function index doesn't sounds good solution to me, neither to my boss. Derby folks are actually aware of the importance to support this, and several proposals have been made in the mailing list, but none have been implemented yet.<br /><br />However, I am lucky enough to find a solution that I like with Collator here:-<br /><br /><a href="http://blogs.sun.com/kah/entry/user_defined_collation_in_apache">http://blogs.sun.com/kah/entry/user_defined_collation_in_apache</a><br /><br />The approach is to create a custom collator provider which returns collator with strength of SECONDARY, which gives case-insensitive comparison for EQUAL and LIKE.<br /><br />Copied from the blog above:-<br /><br />"<br /><ul><li>Create a class that extends <code>java.text.spi.CollatorProvider</code> and returns a collator that orders strings the way you want it to</li><li>Create a text file named META-INF/services/java.text.spi.CollatorProvider which contains one line with the name of your collator provider class</li><li>Put the compiled class file and the text file in a jar file which you drop into your JRE's lib/ext directory or in one of the directories specified by the <code>java.ext.dirs</code> property</li></ul>"<br /><br />And the sample custom collator provider:-<br /><br />"<br /><pre>public class MyCollatorProvider extends CollatorProvider {<br />public Locale[] getAvailableLocales() {<br /> return new Locale[] {<br /> new Locale("en", "US", "caseinsensitive")<br /> };<br />}<br />public Collator getInstance(Locale locale) {<br /> Collator c = Collator.getInstance(Locale.US);<br /> // Ignore tertiary differences (case differences)<br /> c.setStrength(Collator.SECONDARY);<br /> return c;<br />}<br />}<br />"<br /></pre>Make sure the custom collator provider jar is in java.ext.dirs for JRE that starts Derby. Create the database using connection string similar to following:-<br /><pre>'jdbc:derby:NoCaseDB;territory=en_US_caseinsensitive;<br />collation=TERRITORY_BASED;create=true'</pre><br />Using territory based collation disables query optimization when doing LIKE query, I don't know the reason behind it. In the application that I am building, the user is allowed to use every single column to search and filter data. But, not every single column is indexed. ;-)Chua Chee Senghttp://www.blogger.com/profile/04479746846770944394noreply@blogger.com0