Showing posts with label Technical. Show all posts
Showing posts with label Technical. Show all posts

Monday, September 26, 2011

llminfotrafik

Salam,

Anda seorang pemandu? Pernah rasa tertekan sebab jem? Anda berulang-alik kerja menggunakan jalan-jalan utama? Anda ada twitter? Anda juga telah mengikuti @kltu, @klrb, @amptraffic dan lain-lain lagi untuk mendapatkan info trafik terkini? Tapi, anda masih rasa maklumat yang di perolehi dari sumber-sumber berkenaan tidak mencukupi. Anda mungkin memerlukan maklumat visual untuk membantu anda menganalisa situasi sebenar keadaan trafik di tempat kejadian. Jangan bimbang, kini maklumat bervisual boleh membantu anda. Ikuti melalui akaun twitter anda dan dapatkan visual-visual dan tweet seperti di bawah ini:

1800887752(7AM-10PM)
0115pm PLUS@NKVE: Trafik perlahan dari Subang ke Damansara. Harap bersabar.

1800887752(7AM-10PM)
0725am NPE: Trafik perlahan dari Maju Jaya/OUG ke Templer, Pantai Dalam ke Angkasapuri & sibuk di Bulatan Kewajipan.

0710am KESAS: Trafik agak padat & perlahan disekitar Persimpangan Kewajipan dari arah Seafield.

1800887752(7AM-10PM)
0703am SILK: Trafik mulai perlahan dari Sg Ramal ke Persimpangan Bandar Baru Bangi manakala sibuk Mine ke Sri Kembangan

Sumber

Monday, December 20, 2010

Memory Management #1

Dominator Object:
What is Dominator Object? In what circumstances does this thing
happen?. Remember I'm a programmer and I do code. But how the heck
this thing happen? Easy there folks. Lets go through this from the
very bottom of it.
As usual, we start with our lovely but deadly controller. It control our code.
While at logic level, we have our service class. It does the logic and
control data parsing inside the logics. At data level, we have our
models. We may also have the ORM as part of our model. View? Included.
Jsp for view, enough.
But hey, enough with the chat. Now, let's see, when did Dominator
objects happened and what is the effect of having Dominator object.
Not so long time ago, I declare of ORM inside my MainModel (assuming
that MainModel is the model that I used as model in our case). My
program runs. The logical output was true, and the page went well.
(I'll attach picture later, I do post from mobile you know? :) )
Dao/VO declared in model. Easy to call but remain in memory untill full GC is performed.

what's wrong with above method? While development and testing, my
bosses found out Memory Issue. Sometime, small Instance that hold
approximate 10 to 20 application will easily do full GC in every hour
basis. It shows serious memory problem. When I declare another class
in a class (Dominator Objects?), though I've nulled the value when not
in use, sometime, they do stay in memory and cleared once Full GC
done.
How to overcome this kind of problem? If the problem started because
of stacked class inside other class, one quick simple solution was to
clear that stacked class. Just carry the value youu need and leave
behind everything as history. This way, I believe GC will happen
faster. Well, theoritically I guess LOL. (Again, I will attach the
picture soon).

Dao/VO called in service only when program call specific function.

So now we see, how Dominator Object effect the application memory and
how to overcome this problem. Any question? As usual, you are welcome
to raise question + comments in comment section. Your feedback will
much appreciated. (maybe I'll edit this post with further reading).


Further reading:

http://www.eclipse.org/mat/about/screenshots.php
http://www.slideshare.net/guest62fd60c/eclipse-memory-analyzer-presentation

PS: next post: How to programatically done this?

Friday, May 7, 2010

ORACLE: Oracle AS 10.1.2.0.2

*Alert Another Oracle related technical post.


Salam and good-day all my technical readers (Though i knew, not many of my fans are technical readers). :D

Have you ever heard of Oracle Application Server? No? Why not? You use tomcat? With administrative gui? What if your gui crash? or worst, it's not pre-installed? Dont worry, there's always another way to spell three.

Prereq:
local oc4j 10.1.0.2

Step-by-step:
1. Make sure your local oc4j 10.1.0.2 is up and running.

2. Issue this command
java -jar admin.jar ormi://oc4jHost:oc4jOrmiPort adminId adminPassword options

EG:
F:\oc4j_extended\j2ee\home>java -jar admin.jar ormi://sphbdb:23791 admin password
4 -help
Error: Illegal command -help
Usage:
java -jar admin.jar [-help] - print out this usage

java -jar admin.jar ormi://host.domain.com<:port> username password [command]
Commands are:
-shutdown [force|ordinary] [reason] - shuts the entire server down
-restart [reason] - restarts the entire server
-deploy [subswitches] - (re)deploys an application. Sub-switches are:
   -file [filename] - Enterprise Archive to deploy
   -deploymentName [name] - Name of the application deployment
   -targetPath [path] - The path on the remote OS to place the archive at. If no
t specified the applications directory is used
   -parent [name] - Specifying parent application of this application, the defau
lt is the global ('default') application
   -deploymentDirectory [path] - Root of the deployment configurations, "[NONE]"
 to place them inside the .ear
   -cluster - Signals that the deployment should be propagated to other live clu
ster nodes if part of a cluster
   -iiopClientJar - the path on the local OS to place the jar file containing th
e application client stubs
-undeploy [application name] - remove a previously deployed application
-site [subswitches] - configures a site. Sub-switches are:
   -add - adds a site
      -host [host] - host/IP of this site
      -port [port] - port of this site
      -display-name [display-name] - display name of this site
      -virtual-hosts [virtual-hosts] - virtual hosts of this site
      -secure [secure] - true if this site is secure; otherwise false
      -factory [factory] - name of SSLServerSocketFactory implementation if not
using JSSE
      -keystore [keystore] - the relative/absolute path to a keystore used by th
is site
      -storepass [storepass] - keystore password
      -provider  [provider] - the provider used if not using JSSE
      -needs-client-auth [needs-client-auth] - true if needs client auth; otherw
ise false
   ......... yada yada yada yoda..


*This mean your oc4j is up and running. Congrats!

3. Issue this command to start the deployment process:

java -jar admin.jar ormi://localhost:23791 oc4jadmin password -deploy -file utility.ear -deploymentName utility 

Example Output:

F:\oc4j_extended\j2ee\home>java -jar admin.jar ormi://sphbdb:23791 admin password
 -deploy -file F:\2_devspace\1_MBAS\listprovider\deploy\listprovider.ear -deplo
ymentName listprovider
Notification ==> Application Deployer for listprovider STARTS [ 2010-05-07T16:09
:25.088SGT ]
Notification ==> Undeploy previous deployment
Notification ==> Copy the archive to F:\oc4j_extended\j2ee\home\applications\lis
tprovider.ear
Notification ==> Unpack listprovider.ear begins...
Notification ==> Unpack listprovider.ear ends...
Notification ==> Initialize listprovider.ear begins...
Notification ==> Initialize listprovider.ear ends...
Notification ==> Initialize listprovider begins...
Notification ==> Initialize listprovider ends...
Notification ==> Application Deployer for listprovider COMPLETES [ 2010-05-07T16
:09:38.675SGT ]


F:\oc4j_extended\j2ee\home>

4. Test your application in browser.
 
Now your application is deployed. :P Any question? do leave comment(s). 


Friday, April 30, 2010

MySQL: Backup and Restore MySQL

* Warning: Third technical entry? (Obviously, I graduated from Technical University :D).

Salam and good day,

We meet again in another technical entry as stated above. As you can see database are as important as the program itself. as programmer, you should not mingle to much with your database or face the upcoming consequences. It's like the heart of the program. It keep track of data stored in the applications. How do we keep our database as stated in our BRP? dont worry, K0m4nd3r once again come to the rescue.

Prereq- (From now on, Prerequisites will know as prereq, you determine it yourselves):

MySQL. (For sure...)

Step-by-step:
Unfortunately, this time, there are no step-by step guide. Only commands that we can use to make sure we have correctly backup and restore our database.

To backup:
Just assign this command: 

$ mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]

where:
[uname] is database username
[pass] is database password for that particular username
[dbname] is database name that you want to enter as in use [dbname]
[backupfile.sql] is name of the file created once backup is done.
--opt is option available when you do the backup. for more information visit reference below.

Example:
[test@testsvr1 ~]# mysqldump
Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
# cd /home/testBackup
# mysqldump -u myname -p mypass mydb > mydbBackup.sql

To restore:
another command in your ssh:

$ mysql -u [uname] -p [db_to_restore] < [backupfile.sql]

where:
[uname] is database username as above.
[pass] is also same as above.
[db_to_restore] have to refer to [dbname] above.
[backupfile.sql] is backupfile generated from above command.

Example:
# cd /home/testBackup
# mysqldump -u myname -p mydb < mydbBackup.sql
# enterin passwordnya dong!



IMPORTANT:

Notice differences in ">" and "<" backup

">" use to backup.

"<" use to restore.

JAVA: Send email from JAVA? Can OR Not?

* Warning: Technical Entry


Salam and good day,

We meet again in another Technical topic. This time it's about JAVA Mail. In this tutorial, we'll use javamail api. Cut the crap now and get ready.


Pre-requisites:
Step-by-step guide:
0. Import the required library onto your project folder. (Use of IDE also can ma: Right click, import libraries, yada yada yada, you know the drill)

1. Create your function that send mail from your service more-or-less like this.
      //Declare this on class header  
   private static final String SMTP_AUTH_USER = "someemailaccount";
   private static final String SMTP_AUTH_PWD = "someemailpassword";
   
   public void postMail(String[] recipients, String subject, String message, 
                         String from, String portalUserName, 
                         String feedbackType) throws MessagingException {
        logger.info("Inside postMail");
        boolean debug = false;

        //Set the host smtp address
        Properties props = new 
        props.put("mail.smtp.host", "email.test.gov.
        props.put("mail.smtp.auth", "true");

        Authenticator auth = new SMTPAuthenticator();
        // create some properties and get the default Session
        Session session = Session.getInstance(props, auth);
        session.setDebug(debug);

        // create a message
        Message msg = new MimeMessage(session);

        // set the from and to address
        InternetAddress addressFrom = new InternetAddress(from);
        msg.setFrom(addressFrom);

        InternetAddress[] addressTo = new InternetAddress[recipients.length];
        for (int i = 0; i < recipients.length; i++) {
            addressTo[i] = new InternetAddress(recipients[i]);
        }
        msg.setRecipients(Message.RecipientType.TO, addressTo);


        // Optional : You can also set your custom headers in the Email if you want
        //msg.addHeader("Feedback Type: " + feedbackType, 
                     // "\nAs reported by " + portalUserName + ".");
        String header = 
            "Portal KPT telah menerima maklumbalas seperti berikut:\n\n";
        String namaPengadu = "Nama: " + portalUserName;
        String emailPengadu = "\nEmel: " + from;
        String kategoriAduan = "\nKategori: " + feedbackType;
        String keterangan = "\nKeterangan: \n\n" + message;
        String footer = 
            "\n\n---\nIni adalah emel janaan automatik. Sebarang kemusykilan teknikal tentang maklumbalas ini boleh emel ke test@test.test.my.";
        message = 
                header + namaPengadu + emailPengadu + kategoriAduan + keterangan + 
                footer;
        //message = message;
        // Setting the Subject and Content Type
        msg.setSubject(subject);
        msg.setContent(message, "text/plain");
        Transport.send(msg);
        logger.info("Leaving postMail");
    }

    private class SMTPAuthenticator extends javax.mail.Authenticator {

        public PasswordAuthentication getPasswordAuthentication() {
            String username = SMTP_AUTH_USER;
            String password = SMTP_AUTH_PWD;
            return new PasswordAuthentication(username, password);
        }
    }


2. Create String recipientAddress[] in your model. Not to forget getter and setter.
    String recipientAddress();


3. Call the function from your controller.
                   feedbackModel.setRecipientAddress({ "receiverEmail@testServer.gov.my" }); 
          feedbackService.postMail(feedbackModel.getRecipientAddress(), 
                                         "Portal Feedback: "+feedbackModel.getPortalUserName()+"- "+feedbackModel.getFeedbackType(), 
                                         feedbackModel.getFeedbackMessage(), 
                                         feedbackModel.getPortalUserEmail(), 
                                         feedbackModel.getPortalUserName(),
                                         feedbackModel.getFeedbackType());
4. Compile and test send an email.

5. Check your email. make sure that the email is sent.

6. Tada!! my work is done!

As usual. Any comment are highly appreciated?

Thursday, April 29, 2010

Change Your ORACLE_SID: Part II

* Warning: Technical Entry


If you're facing intermittent database connection to your fresh installed Oracle XE you may be victim of software counterfeiting. :D

ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was

Don't worry, I'm just kidding. I found it irritating at first time. provided search result from google, i found one simple solution.

This problem maybe because maximum number of processes allowed to run. Don't worry, just alter the database to allow maximum process.


1. type command below:

sqlplus "/as sysdba"


2. Enter this command:

SQL>ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;


3. Shutdown your database.

SQL>shutdown immidiate;

4. Start
SQL>startup

5. Wahlah! No more irritating ORA-12519!

PS: Bear in your blurry mind that this happen if you're connection exceed maximum connection. make sure you close your connection every time you have finished using it. (Sorry my bad English).

Thursday, April 22, 2010

Change Your ORACLE_SID

* Warning: Technical Entry


Salam and good day,

I'm sure if you're working on oracle DB, some of you use ORACLE XE as local database to test for your convenience. It's different from what is installed on your server. What we do, we change the SID to meet our need. But how? This tutorial will show you an example to change our SID from XE to ORCL.

Prerequisites:
Windows Vista (This is my setting you might use other OS as well).
Oracle Database 10g Express Edition (Of course its free to develop, deploy and distribute. download here)
Oracle DB was installed on the target machine.

Reminder:
Maximum 8 char for SID

Step-by-step guide
1. Shutdown the database.
sqlplus /as sysdba
shutdown

2. Use control panel to shutdown OracleService (In this case service name are OracleServiceXE and listener OracleXETNSListener) or issue this command in your command prompt:

lsnrctl stop
net stop OracleXETNEListener
net stop OracleServiceXE

3. Rename or copy SPFileXE.ora to SPFileORCL.ora. The file is at
C:\oraclexe\app\oracle\product\10.2.0\server\dbs 
 Depending on your installation setting.

4. Copy and rename C:\oraclexe\app\oracle\product\10.2.0\server\database\initXE.ora to initORCL.ora then modify the spfile line to point to the new spfile.

5. Assign this command in your command prompt to create new service and remove the old one.
oradim -new -sid ORCL -startmode auto -pfile C:\oraclexe\app\oracle\product\10.2.0\server\database\initORCL.ora 
oradim -delete -sid XE
6. Type this in your command line to start up your listener.
lsnrctl start
 7. We're almost done, Set your oracle SID to ORCL now. Type:
set ORACLE_SID=ORCL
8. Run this query after altering process is finish.

C:\Users\xx>sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Apr 22 19:30:14 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> alter system register;

System altered.

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
orcl

SQL>

9. orcl is our new SID.

Wednesday, April 14, 2010

Google Map

Salam.
Pernah dengar pasal iGoogle? Hah, satu page baru di tawarkan oleh google. Macamana aku tau pasal benda nih? Sejak aku pakai Nokia XpressMusic 5320-D ni, macam-macam pasal symbian yang aku selongkar. Walaupun telefon ni tidak lah secanggih N900-Maemo atau paling cikai E-71, malah tak termasuk dalam kategori smartphone pon. Mula-mula aku ingat sekdar Xpress Music. Apa sangatlah yang aku harapkan? tapi, dengan perisian tambahan macam yang Google sediakan, Hidup terasa lebih bermakna.

Dalam post kali nih, mari aku terangkan pasal salah satu aplikasi yang google ada bagi dalam bundled software dalam phone aku. Aku rasa semua orang tau pasal google kan? apatah lagi perisian google earth. Untuk phone aku, pre-install with Google (Kalau korang tak subscribe to unlimited data plan, baik jangan buat cam aku), dengan google maps, aku boleh kongsi kedudukan terkini aku. Benda ni amat berguna kala-kala kecemasan.

Katakanlah, tengah masuk hutan mana tah, tiba-tiba aku sesat, aku boleh suruh orang tengok igoogle untuk dapatkan koordinat aku. Canggih kan? Cuba klik link di bawah.

komander's Location

Amacam? teruja tak? teruja tak?. Pesanan aku pada kawan-kawan, kalau handphone canggih, setakat nak telefon and sms, henti kan je lah.. :D Dunia dah berubah, zaman dah mau. Cuma jangan lupa bayar bil, kalau tak macam orang mati kucing lah jawapnye.. Huhuhu.. sekian, renung-renungkan dan selamat beramal..

Friday, March 5, 2010

Technical: Database kene lock? Hohohoho

*Amaran: Nota technical

Aplikasi anda telah dibangunkan dengan jayanya. Bos anda memanggil untuk mesyuarat council of the eldest. Anda dengan bangganya ingin menunjukkan hasil kerja anda. Tiba-tiba, aplikasi yang anda telah bangunkan menunjukkan ada ralat berlaku. Anda selongkar file log untuk mengetahui apa yang berlaku sebenarnya. Sedang anda gelabah puyuh tadi, anda mendapati ralat yang berlaku adalah disebabkan oleh:

10/03/05 03:21:28 java.sql.SQLException: ORA-28000: the account is locked
Jangan risau. Anda boleh salahkan DBA di syarikat anda itu. Adakah anda tahu, apakah yang menyebabkan perkara ini berlaku?. Apa akan terjadi jika anda merupakan DBA suatu hari nanti? Apa yang perlu anda lakukan?. Jangan bimbang. Anda boleh unlock semula akaun anda dengan cara ini.


1. Lancarkan aplikasi sqlplus
sqlplus /nolog
 2. Connection String
SQL> conn /as sysdba
connected.
3.  Lancarkan arahan untuk unlock user tersebut.
alter user account unlock;
 Tahniah! anda telah berjaya!

Thursday, January 14, 2010

Aku pernah dengar pasal Google Translate

Tapi kat bawah ni bisa membuatkan aku gelak guling2. 

To deploy the Toy Store to a 10.1.3 OC4J instance you need to modify the orion-application.xml descriptor. Typically, when generating an ear file from JDeveloper this descriptor is created for you and the default file does not need to be altered for most deployments. However, to deploy to a UIX application to a 10.1.3 OC4J instance a modification must be made that adds a reference to the shared library that you created earlier and removes the ADF 10.1.3 libraries from the classpath of the UIX application. Note, the ADF Toy Store Demo already contains an orion-application.xml. The following section will show you how to modify this file and add the META-INF directory containing the file to the deployment profile. These procedures should translate to your current application deployment. For more information on creating deployment profiles for J2EE applications in JDeveloper 10.1.2, consult the JDeveloper online documentation.


Translated into this.

Untuk menyebarkan Toy Store ke 10.1.3 OC4J contoh anda perlu mengubahsuai Orion-application.xml deskriptor. Biasanya, saat membuat fail telinga daripada JDeveloper keterangan ini dibuat untuk anda dan fail lalai tidak perlu diubah untuk sebahagian besar penyebaran. Namun, untuk menggelar ke UIX aplikasi ke 10.1.3 OC4J contoh pengubahsuaian perlu dibuat yang menambah rujukan kepada shared library yang anda buat dahulu dan menghapuskan 10.1.3 ADF perpustakaan daripada classpath daripada aplikasi UIX. Nota, ADF Toy Store Demo sudah mengandungi Orion-application.xml. Bahagian berikut ini akan menunjukkan kepada anda bagaimana memodifikasi fail ini dan tambahkan META-INF direktori yang mengandungi fail ke profil penyebaran. Prosedur ini harus menterjemah aplikasi anda saat deployment. Untuk maklumat lanjut tentang cara membuat profil untuk penyebaran aplikasi J2EE di JDeveloper 10.1.2, membaca dokumentasi talian JDeveloper.
  Gulingan yang di lakukan mengalahkan gulingan apabila baca blog hapacrita. :D

Monday, July 6, 2009

Mamak melangkah maju kehadapan



Gambar di ambil sekitar pukul 7pm lokasi Giant kajang. Venue nk carik tempat nk bukak pose. perasan x kat sign board tuh? Restoran Al-IBM. perghh.. IBM dah jadik restoran mamak rupenye.. agak2 kalau nk carik part2 laptop IBM ade jual x?