Dealing with configuration files in Subversion

Tags:

Here’s a quick tip on how to deal with configuration files when working with Subversion. This probably applies to other VCS’s too like CVS or Git. You probably have noticed this: you have a configuration file or such, and you need to keep it in SVN, but committing it would be a problem as updating it on other machines would …

Another idea for using models with forms

Tags:

Matthew Weier O’Phinney wrote about using Zend_Form with models. His approach puts a form inside a model, which then uses the form to validate itself. While this idea is not bad, I find it being upside down – I think the form should use the model to validate itself, not the other way around. But how would you utilize a …

Sandboxing Rhino in Java

Tags:

I’ve been working on a Java app which needed Rhino for scripting. The app would need to run untrusted JavaScript code from 3rd parties, so I had to find a way to block access to all Java methods, except the ones I wanted. This would not be a problem if there was an easy way to disable LiveConnect – the …

Reusable “generic” actions in Zend Framework

Tags:

Sometimes you will need nearly the same functionality in many actions. This can lead to unnecessary code duplication if you aren’t careful, and there’s been a couple of occasions on #zftalk, where people have been asking for a good practice to avoid this. There are several ways to deal with this, such as moving the code into a separate function, …

JavaScript margin/block commenting system

Tags:

On Djangobook, they used to have this interesting commenting mechanism on their book’s pages: Each paragraph in the book could have comments, by use of a JavaScript commenting system which would display the amount of comments on each paragraph when you hovered over them with the mouse. You could also click on the little bubble which displayed the count, and …

The problems faced by a common model interface in frameworks

Tags:

You sometimes see people asking why the Zend Framework (or some others) don’t provide a library for the Model part in MVC. While ZF provides data access classes in the form of Zend_Db and related components, it doesn’t provide any concrete examples of how you would implement a model class. This often confuses especially beginners. Providing a common base model, …

Scraping HTML with Python

Tags:

Have you ever had to write a script that scrapes data from an HTML page? Was the page horribly bad HTML too? If so, you probably know how annoying and time consuming it can be to write a script that reliably fetches data from such a mess. I was recently asked to write a script that scrapes an ASP.NET page …

Thoughts on unit testing and application design

Tags:

Here are some thoughts and observations regarding application design and unit testing in the quiz-project I recently wrote about. When I was writing the Amazing Programming Language Guessing Script, I didn’t first write any unit tests. Partially because I just wanted to test something quickly, partially because I didn’t think there was any point in doing it. When I later …

Programming language guessing game

Tags:

Some of you asked me about the “quiz” thing that showed up in one of the screenshots in my NetBeans review… Well, here it is: During that weekend when I was trying out NetBeans, I wrote a small Zend Framework + Doctrine application which attempts to guess a programming language the user is thinking of, based on a set of …