How Hard Are URLs in Text?

   Abandon all hope you who read this, for this is where you will find how simple programming problems can turn out to be really hard. For our current project we wanted to implement a seemingly simple functionality – when the user posts a comment via a text area new lines should be converted to "<br />" in the resulting HTML, HTML tags should be encoded so our project would not be vulnerable to script injections and users would be able to post HTML in the comments and finally URLs should be detected and converted to links. Sounds simple? As soon as I was charged with this task I remembered reading a post by the wise Jeff Atwood on his famous blog Coding Horror about how hard URLs can be. The post deals with the issue of a closing parenthesis at the end of a URL and I immediately decided that I was going to ignore this issue like most systems do. However while working on this task I hit many more walls...
Posted by:   Stilgar
02:37 03.09.2009

JavaScript for the Elite

JavaScript for the Elite
   Ever since I asked myself and tried to find out why people tend to hate JavaScript I have been loving the language. My research revealed that JavaScript has many cool features from the very beginning. The reason people are hating it are the sucky browsers. Every browser has its own implementation which causes problems. What is more JavaScript's main use is to deal with the dreaded DOM. Luckily in recent years people seem to discover the power of JavaScript and appreciate the fact that the language is very well suited for the untyped nature of the DOM. As you probably know I do not believe that the Web should be rich and made to resemble desktop applications. Unfortunately this means that I did not have a chance to write complicated JavaScript and use the language to its full potential. The stuff I did was really simple validation and calculations like adding two numbers. However our current project is more user-centric and requires rich UI so it seems like the time has come for me to write some elite JavaScript...
Posted by:   Stilgar
18:36 02.08.2009

Silver Splines

Silver Splines
   In order to pass the last exam left and graduate from the University of Plovdiv I had to create a small program that draws some splines. I picked Bézier curves as they seemed to be one of the simplest kind of parametric curves...
Posted by:   Stilgar
04:15 11.07.2009

Image Resizing in C#

   I got complaints from millions of readers that I have not posted any programming articles with actual code lately. I do not have anything to write about right now so I decided to pull out some old code. It seems that this one is the most useful piece of code I have ever written. I originally wrote it for my first project and then wrote it again for this very no-blog. I have been asked by several people how to do this and it seems that it is a common problem so maybe someone will find it with the help of mighty Google...
Posted by:   Stilgar
02:44 12.06.2009

Going Random on an Enumerable

   I have not published any programming articles recently and I know that a throng of readers eagerly await them so I decided to share an interesting task that was brought up by a guy on IRC. You have an enumerable sequence and you are required to write a method that selects a random element from the sequence with just one iteration over the sequence. This means that you are not allowed to call methods like Count because it will iterate through the sequence. You are not allowed to save the elements in another collection. Of course an even distribution of the results is required (i.e. every element should have equal chance to be selected). When you are ready look at the full text to see my solution...
Posted by:   Stilgar
00:37 26.01.2009
First Previous 1 2 3 4 5 6 7 8 9 10  ... Next Last