How ASP.NET fails – Ready to Quit ASP.NET

This post by Stefan Rusek express exactly how I feel about ASP.NET from the UI/Web perspective. (Check also the Hacker News thread on it)

I would add that, over the years, the whole .NET framework has grown to a over-engineered beast. It’s coherent and consistent, but still a beast. So several parts of the framework simply goes too far on the Object Orientation and builds a excess of classes, realtions, patterns and so on, sometimes making very painful the decision on how to correctly implement things. That’s why you feel so liberated when trying some other alternatives like Ruby on Rails (which, I have to say, seems to be growing too much recently).

Using ASP.NET also drives you to blindly use those architectures, patterns and practices, that Microsoft loves, without realizing that usually simpler is better, and without giving a second thought on how and why you are doing what you are doing (LINQ, three tier architecture, and so on). I’ve seen horrible real-world examples of this.

On the other hand, the .NET framework has some very interesting features like being a complete infrastucture, and C# is evolving in very nice ways, like the new dynamic features. Good things can be done with .NET, but you have to question  the “correct ways” as presented by Microsoft.

CSS Palette: Watch the Palette within a CSS

CSS Palette

I’ve written a quick toy to easily watch the colors used on a CSS. You pass the URL of an online CSS and it will parse the colors and build a palette for you. It’s useful if you want to reduce the amount of colors you’re using by spotting the almost duplicates that usually arise when writting code.

Color “sorting”

To display the colors in a nice order I wrote a “compare” color function to use with the sort method of the Array. It uses a basic color quantization by calculating the euclidean distance between the color and a origin at (0,0,0) black. Ruby code:

  #compares colors using the position 
def compare_colors(a,b)
color_position(rgb(b)) <=> color_position(rgb(a))

#returns the color "position" relative to (0,0,0) as euclidean distance
def color_position(rgb)
#Ruby 1.8.7 ya tiene reduce
#Math.sqrt(rgb.reduce{|dist,comp| dist+=comp*comp})
dist = 0
rgb.each{|comp| dist+=comp*comp}

One-line parse of the colors of the CSS

Once the CSS is downloaded with the standard net/http methods, it takes only one line to parse it and build an array of distinct colors (Ruby functional style is awesome):


Generating the palette using DIVs

I wanted to show the colors as a single strip of squares that would resize with the browser window. This was a bit tricky because positioning DIV side by side had to be done by creating nested DIVs: the first one is displayed inline which makes possible to wrap the with the size of the window. The second div is displayed normaly as block and has a fixed size of 100x100px:



The CSS Palette is permalinked on the rightbar.

ImageMagick and RMagick on Vista

The current version of the Ruby Gem RMagick (2.9.0-x86-mswin32) comes bundled with ImageMagick installer 6.4.8-6-Q8-windows-dll which is pretty new. I have had some problems after installing both as the instructions indicated with my rails app as Mongrel throwed some CORE_RL dll not found, so I uninstalled both and reinstalled ImageMagick running the exe As Administrator, and everything seems ok now…

Ruby 1.9.1 / 1.8.7 “dual” mode on Ubuntu

I think this may be the most convenient way to have the shinny new Ruby 1.9.1p0 to play and a normal Ruby 1.8.7 on Ubuntu:

  • Install Ruby 1.8.7 and everything else from apt/synaptic
  • Download and extract Ruby1.9.1
  • Use –program-suffix=1.9 while configure to “tag” all the executables
tar jxvf ruby-1.9.1-p0.tar.bz2
cd ruby-1.9.1-p0/
./configure --prefix=/usr/local --program-suffix=1.9 --enable-pthread --enable-shared
sudo make install
ruby --version
ruby1.9 --version

Try inside irb to check differences.