Posts

How to configure nginx and uWSGI to serve Django projects

This time a post about Python...lately I was dealing with a Django based project. One of the tasks in the project was to deploy the application using nginx and uWSGI. To document the process and to help others I decided to post a short explanation on how to configure nginx, uWSGI and Django to work together. Unlike most articles I found over the internet I'm not just laying down the final configuration but I'm trying to explain what happens in each step – hopefully it will be useful to others.

Java 7 Working With Directories: DirectoryStream, Filter and PathMatcher

My previous post was about Java 7's new java.nio.file.Path class  this time I want to continue and explorer some of the other new file system related APIs in Java 7. java.nio.file.DirectoryStream DirectoryStream provides an easy way to iterate over directories content, but more than that it introduces a solution for a long existing problem of listing within very large directories. If I wanted to list folder entries using previous Java versions I had to use one of the java.io.File's list() or listFiles() overloaded methods: // Pre Java 7 Directory Listing Example File f = new File("c:/tmp"); String[] names = f.list(); // At this point Java listed all files in c:/tmp and loaded their names into an array of Strings for (String name : names) { System.out.println(name); } The problem with the old API is that once I asked a File object to list its entries it would immediately scan the folder creating an array of strings (or file objects if l...

Java 7 - Path Manipulation Using java.nio.file.Path

Lately I had the feeling it's about time to starts looking into Java 7 EA, it has been under development for some time now and by the latest news it should be released soon. So I downloaded JDK 7-EA and Netbeans 7 (Eclipse doesn't support Java 7 language changes yet) and looked for interesting changes in the release notes, the first few I've noticed are the I/O enhancements on which I decided to write a post or two starting with a short coverage of the new APIs for path manipulation in the new java.nio.file.Path interface.

Hibernate/JPA Identity Generators

Introduction As usually it has been a long time since I have last posted in my blog, and even longer (about half a year) since the last time I wrote about Hibernate but finally I have fond the tome for that. This post is about Hibernate standard compatible (TABLE, SEQUENCE, IDENTITY, and AUTO) identity generators: it explains what the identity generators are and illustrated the different considerations need to be taken when choosing identity generation strategy. Environment Hibernate - 3.5.6-Final PostgreSQL - 8.4

Under the Hood of Java Strings Concatenating Performance

Image
Introduction In my previous post I covered some of the more sophisticated Java strings management issues (Collators, Normalizer, interning, substring). Few of the readers of that post left comments asking about StringBuilder vs. StringBuffer vs. the built-in concatenation (+) operator performance. To have a closure to the subject I decided to elaborate on Java strings concatenating. Is It Important? In java we talk a lot about strings concatenating which brings up questions about the importance of that. As always the answer depends on the scenario, if we just want to take two strings and print a message composed out of these strings it is probably doesn't matter - we can use the + operator or String.concat() method and get it done. It is more important when we are processing mass of data and loop a logic performing strings concatenating.

Four Things to Remember about java.lang.String

Image
Hi, Usually this (and my old ) blog is more Hibernate, Spring and other JEE/Server side technologies. Still on my day to day work (and mainly when I lecture) I see a lot of misunderstanding/misconception about basic Java tasks. I decided to drop some notes about such subjects from time to time - and today four issues about java.lang.String: Strings are immutable - a very basic one, just a reminder  Strings Equality, Normalizer, and Collator - an overview of strings equality in a Locale sensitive  environments (including accented forms) The substring() method might cause memory leaks - in some scenarios the usage of String.substring() method can cause memory leaks String.intern() - how to improve strings equality performance and memory footprint using String.intern()

Hibernate 3.5/JPA 2.0 - New Query Expressions

Hi all, As usual it took me a long time to write to my blog again but finally here it is - in this post I continue writing about JPA 2.0 (my previous post is here ), more than that this is the first entry I'm publishing in my new (the old one is here ) blog - Congratulations to me :-). Anyhow in this post I'm trying to go over some of the new functions introduced by JPA 2.0 to the JPA query language. As always my platform is Hibernate but I am using only JPA standard annotation and query syntax. The post includes the following: The INDEX function (and the @OrderColumn annotation) The TYPE expression, and The four types of case expressions My environment Hibernate 3.5.2-Final PostgreSQL 8.3