Quantcast
Channel: Reza's Weblog
Browsing latest articles
Browse All 50 View Live

Simple Tomcat and Apache HTTP Server Configuration

It took about an hour to do this seemingly simple thing so I write it here not to forget it later! I needed Apache server to be as an interceptor for tomcat calls.install both Tomcat and Apache...

View Article


SCEA Exam

I paid and registered to take the first part of SCEA (Sun Certified Enterprise Architect) exam. Even I have been studing for the past couple of months and everything was almost OK! But there was a...

View Article


Choosing an IDE - JDeveloper 11g

To start a new open source project I was looking for some handy IDE. I tried the following famous ones:  Eclipse (SDK 3.2 and ee) IntelliJ Idea 7 (beta) Netbeans 6 (nightly builds) JDeveloper 11g...

View Article

Target Typing in Java

Target typing is a language feature wherein the type of the variable in which a result is to be stored influences the type of the computation. Java does not have it, and then the following expression...

View Article

Java's compound assignment operators

The compound assignment operators are +=, –=, *=, /=, %=, <<=, >>=, >>>=, &=, ^=, and |=.The Java language specification says that the compound assignment E1 op= E2 is...

View Article


Iterating a Map

I am sorry to post this fairly simple piece of code here but I usually forget how to iterate a Map so I wire it here not to forget it again:                    Iterator it =...

View Article

String Concatenation with +

The + operator performs string concatenation if and only if at least one of its operands is of type String; otherwise, it performs addition. In this case 'a'+ 'b' prints an int number not the string...

View Article

Internet in Iran

Around a year ago the Iranian minister of communication and telecommunication said that "home users" DO NOT NEED more than 128 KB Internet speed and all ISPs were banned to give home users faster...

View Article


String Interning

Java provides two basic mechanisms for equality testing. The “==” operator can be used to test primitive values for equality, and can also be used to determine if two object references point to the...

View Article


Using Pattern.quote

We know that for replacing all the periods in "a.b.c" we can use replaceAll method of String. It take a regular expression and a replacement string.This is a mistake:...

View Article

Integer Underflow

It is stupid that java underflows when it reaches the boundries of some primities types. For example: int i = Integer.MAX_VALUE + 1; goes back to the lowest possible int which is also a negative...

View Article

Java's Mathematical Infinity

We have the mathematical representation of infinity in double or float:double i = Double.POSITIVE_INFINITY;and it behaves like mathematical infinity so that i == i+1; is correct! In Java adding a small...

View Article

exit(0) over finally

I have always thought that finally blocks are executed in any circumstances; but that wasn't true! public class Test {    public static void main(String[] args) {               try {...

View Article


IE for Linux

Our client at work reported that some javascript is not working on IE but it was working on firefox. I was at the edge of taking my whole dev environment back to windows on my dual boot windows/Ubuntu...

View Article

Apache Rewrite Rules

I have always been thinking that apache rules are useless! but recently I came across a situation that left me with no choice other than using apache redirect rules. There was a web based project with...

View Article


insideApps

The other day, I was trying the new open source application monitoring tool called insideApps. Features seem to be good but the installation process is lengthy and does not go smoothly. I encountered...

View Article

Java Frameworks and Pattern Usage by Developers

A couple of days ago I was thinking of the last time I used a pattern in my daily programming. I think it was 3 months ago! Then I tried to find out why. What I mean about a pattern is a GOF or J2EE...

View Article


Delete the Returns of a SQL Select Statement

I needed to delete the rows returned by a complex and nested select statement. Something like this: DELETE FROM table1 where table1.x NOT IN (SELECT table1.x ...) Which was not possible in MySQL or at...

View Article

Logging Tips

I noticed a lot of enhancement in production environment performance when we turn the logging from debug to info. Another best practice is this piece of code:if (loger.isDebugEnabled()) {...

View Article

Fixed IP addresses in Home LAN with Netcomm Router

I was wondering for a while how I can have fixed IP addresses on my home LAN. I needed that because I was getting different IPs after a each boot and this was a problem in port forwarding since I had...

View Article

Image may be NSFW.
Clik here to view.

Hibernate Column Level Lazy Loading

Suppose we have "Event.hbm.xml" with a "formula" in one of its properties called "name". The formula is a big select statement that I don’t want to call every time I fetch the object. Hibernate 3...

View Article


Inner Iterator Loop

I made this stupid mistake again recently! I want to iterate two Sets. One inside another for every element.Iterator itr1 = set1.iterator(); Iterator itr2 = set2.iterator(); while (itr2.hasNext()) {...

View Article


UML Designer with JavaFX

I was planning to write an online UML designer with JavaFX. I found a couple of similar applications such as http://www.websequencediagrams.com/  and one more that I think was flash based and I can't...

View Article

Invocation of init method failed; nested exception is...

I was getting this error: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: OneToOne or ManyToOne on com....channelCategory references an unknown entity:...

View Article

Dell XPS M1330 vs. Leveno SL 300

I ordered a 13" XPS M1330 Dell online from Dell Australia and I got it damn fast from their factory in china! But there was a small problem with that. The left palm rest area was getting a bit warm. It...

View Article


From Pragmatic Programmer

These are some tiny portions of the Book: The Pragmatic Programmer From Journeyman to Master Be a Pragmatic ProgrammerIn order to be a Pragmatic Programmer, we're challenging you to think about what...

View Article

Left Handed Laptop

I am looking for a left handed laptop! It might seem odd but I am serious.I have a Lenovo SL300. The problem with that is the heat exhaust is on the left and sometimes I can't use my own wired mouse as...

View Article

Remote Debug Tomcat 6 in Windows

This might look like a stupid post but it took me 20 minutes to be done! I was trying to configure tomcat 6 for remote debugging with Eclipse in Windows. The only catch was putting: "-Xdebug" and...

View Article

Scrollable Windows cmd

Sometimes the Windows command line window is not scrollable by mouse and you just have to use the side scrolls which is a bit annoying. If you right click on the window title and tick QuickEdit Mode...

View Article



Image may be NSFW.
Clik here to view.

Choosing a VPS

I was after a good/cheap VPS provider to host some small projects using Tomcat/Apache/MySql. My criteria were: RAM:  around 1 GBHDD:  more than 4 GBBandwidth:  more than 60 GB (Calculate yours roughly...

View Article

Apache - DWR - Tomcat

I had this stupid problem: My application works fine under http://localhost:8080/mycontext/ but when I try to remove the ports using Apache ProxyPass OR mod_jk then DWR does not work. Solution: I...

View Article

Configuring Apache VirtualHost

The complete configuration is as follows for CentOS 5.x, Tomcat 6.x and Apache 2.2.x. Looking at my previous post I am using mod_jl in order to direct DWR calls to Tomcat too, but you ignore...

View Article

Post HTML friendly code into JRoller

I use this great tool: http://www.elliotswan.com/postable/ when I need to post HTML/XML into my posts. It escapes them.

View Article


Linux Security Applicaitons

For a quick Linux security you can consider these products:iptables : They are complicated and powerful like assembly. The package is usually already installed in most of the distros and there are many...

View Article

Google Apps instead of Apache James

I was struggling with Apache James for the past couple of weeks on my VPS but having a secure, reliable and 24/7 mail server is not easy! This was until I found Google Apps! It can empower you domain...

View Article

Access Eclipse SVN Through Proxy

You just simply need to edit [global] section in this file: C:\Documents and Settings\\Application Data\Subversion\servers and set:http-proxy-exceptions = you might want to exclude your usual...

View Article


Adding Authentication to Squid3 on Ubuntu

Configuration file location: /etc/squid3/squid.confCreate file passwd in /etc/squid3/sudo chmod o+r passwdAdd username and passwords you want using: sudo htpasswd passwd your_username. You can find...

View Article


Quick EasyMock

EasyMock documentation sucks! Stages of using EasyMock:Creating mock objectsExpectations setting and behaviour. As EasyMock documentations says: if you would like to use matchers in a call, you have to...

View Article

Send email when JUnits fails using ant

In your junit tag you at least need these attributes: haltonfailure="false" haltonerror="false". This is the portion of script to call junit and see if it is failed and then send email: <target...

View Article

Paypal and Dynamic Price

If you want to use Paypal for your online purchases and prices are dynamic (come from database and are not hardcoded) your need to use a a non hosted/non code protected button. Follow these steps:In...

View Article

Apache Permission Error

The famous error "You don't have permission to access / on this server" on Apache might have some other rare reasons apart from the following:The file and folders should have enough permissions, at...

View Article


Template Method Pattern in Spring

Many people do not like Template Method pattern but I usually use it and it has been useful in some situations. Although in Spring Framework there is a small trick to apply. Imaging this:public...

View Article

Resize and compress an image in Java

Using this simple code you can reduce the quality of an image and change its size as well:BufferedImage originalImage = ImageIO.read(new File("in.jpg"));double scale = 0.5;  // 50 %int newW =...

View Article


How to handle returning a large result set to user?

Question: How to handle returning a large result set from database to users of a JavaEE web based application? This question may have many answers but in the context of our project we came to the...

View Article

HTC Desire 1 Week Experience

I got an HTC Desire a8181 almost a week ago. It is a 2.2 Android phone and quite different from my old Iphone 3G which was too damn slow after stupid Apple ios updates (rip offs)!While I am enjoying...

View Article


Why do we have Agile today?

Why didn't we have it 20 years ago?! Why Agile enthusiasts insist on not having too much design before hand, less documentation, not much emphasis on architecture,etc ? why are we able to actually...

View Article

Port Forwarding on DG834GUv5

Dummy's guide to open ports on DG834GUv5: 1. Using any computer wired connected to the DG834GUv5, open any Internet Browser on the computer. 2. On the address bar, enter 10.1.1.1 then press enter key....

View Article

Australia and Migrants

I see these days the immigration laws have been tightened a little, for example IELTS score has been raised to 7 in all bands to get 25 points. This is in fact a good thing as people when they come...

View Article

Python Web Hello World

This is a Python CGI Web Hello World for Windows and Linux. Install ApacheInstall PythonCreate 1.py as following.Put 1.py in htdocs directory In httpd.conf uncomment and add .py to AddHandler so you...

View Article


Goodbye JRoller

This is going to be my last post here. I am saying goodbye to JRoller after a couple of years and moving to Wordpress. I found Wordpress an easier platform to work with; more support for code insertion...

View Article

Browsing latest articles
Browse All 50 View Live