Nowadays quite lots of sites are AJAXy, especially their back-end part. This introduces one interesting issue with sessions and password protected areas. Typical scenario is: password protected URL initiates a server-side check for valid user is logged in or in other case redirects to login page. What happen when session is expired by timeout? Session data is wiped from the server, so already logged user becomes like a just comer. Next request to the server will eventually redirect him back to login dialog. But not in case of AJAX. Usually AJAX requests are written in the way not to support sudden session break and this situation can lead to a very unpredictable behavior. How to fix it quick? Continue reading

Quite often I was in need a function to scale an image to the size right to fit into bounding box.

For example, displaying images of real estate or product image in the shop site. Images can be different sizes, less or bigger of target size, portrait or landscape, etc..

I wrote little helper function in PHP that does that tasks using two modes: FIT and FILL. It uses standard PHP-GD extension.

Continue reading

Nowadays many sites uses embedded map from Google for purposes like showing object location, drive-in way or more complex stuff. Recent Google Maps Version3 (V3) API becomes very powerful, but remained very clear and easy to use. While developing site for real estate company I faced with necessity to display fancy, complex overlays on top of the map when user clicks on the marker. There are some standard ways of showing so called info-windows. The problem is that it is not possible put complex formatting there or catch mouse clicks events. To solve it I have to to dig into API internals and recent version V3 has some surprises here. Continue reading

Some weeks ago I switched to Nginx and quit Apache and was quite happy with it. I was so happy that completely forgot about my Mercurial repositories hosted on same server. This happen when I was in hurry and needed to push and pull some changes,  damn. At first I quickly restored Apache, did all needed changes and switched back to Nginx. For sure, I did not like this way and explored how I can connect Mercurial directly to Nginx. I was quite surprised how easy it is and how flexible. Continue reading