I forgot my WordPress password. For the life of me, I couldn’t remember what it was, because it had always been stored in the browser cache and I never bothered to write it down anywhere. In order to reset it, I clicked the “Forgot password” link offered on the WordPress login page. However, apparently my server can’t send emails, since the password reset mail never arrived. What now?
Luckily, the server is under my control. I used PHPMyAdmin to access the WordPress database, and looked at the rows in the wp_users table. Shame – the passwords are encrypted (probably using MD5) so I couldn’t see what my original password was. Now I could just overwrite the password with a new one – properly MD5 encrypted – but I wasn’t quite sure what sort of encryption WordPress really uses. Read more
If you’re using GMap.NET to add maps to your .NET application, then the time may come when you want to calculate the area of a polygon on your map. In my case, I have an application that allows users to actually create polygons using a GMap.NET control, by placing and connecting markers to shape their polygon. Since the map system is used to indicate the limits of an area occupied by a rural community, it’s necessary to calculate how many hectares the delimited area occupies.
Google Maps actually provides a function in its API to calculate polygon areas:
Even so, unfortunately GMap.NET does not offer access to this API. Moreover, your GMap.NET control may be configured to work with a different map provider from Google Maps, like Bing. Consequently, you’ll have to implement your own polygon area calculation algorithms. Luckily, this is not all that complicated, and algorithms are available on the net. Read more
It’s always a good idea to use enumerations for properties that have a limited set of valid values, rather than a number. This allows your code to check whether you’re assigning a valid value to the property, and the individual values have easy-to-read names. However, the names you use cannot contain spaces or other non-alphabet characters, and are limited to the English language (you cannot use characters like á, õ etc.) Read more
Nhibernate is a great Object Relational Mapping library. It allows you to forget about your database and focus on writing classes that interact with each other without any tedious CRUD code. It works beautifully, up until the point where you need to optimize your code.
Loading data with NHibernate can take a long time when you need to join results from multiple tables for a master-detail view. You can read all the records from the master table in one go, but when you access the fields of the resulting object instances to get at the child elements, then each access will result in a separate database query. Worse – if your mappings are not configured to use lazy loading, NHibernate will execute these queries even before you access the child fields, so let’s assume that you’ve configured NHibernate to use lazy loading, at least. If you’ve got 100 master objects, with 10 detail objects each, then you’re looking at one query to load all the master objects, and 100*10 = 1000 queries to load all the detail objects!