Simple CSS Trick

At best I’m a CSS hacker, but every now and then, I actually learn something cool about CSS.  Today, I finally figured out how to make a dynamically expanding div container.

Basically I have a ‘mainContent’ div container where the height is unknown based on the content (additionally, I have a floating div).  In order to dynamically grow the content div I use this style:

#mainContent {
	border: 1px solid #000000;
	overflow: hidden;
	width: 100%;
}

div.left {
	width: 45%;
	float: left;
}

div.right {
	width: 45%;
	float: right;
}

 

The key here is the ‘overflow: hidden’  on the “container” div (id is mainContent).  This works well both in Firefox and IE (7, not sure about 6)

Probably everyone knows this already, but figured I’d share  šŸ™‚

Advertisements

ASP.NET MVC Preview 3 Release

http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx

I’ll write up more as I explore…

Update: so far… excellent work.  The different return results from Actions are very powerful  – JsonResult, ActionResult, ContentResult

Take the JsonResult.  Previously I created a ‘ToJson’ extension method with a response.write on a void action call.

With preview 3, I return a JsonResult instead, and use the ‘Json’ function that does the same thing my extension method was doing and then returns the JsonResult.  For example:

        public JsonResult SetClaimReadyToPrint(string id) //claimid
        {
            try {
                Claim claim = ClaimsDao.GetById(new Guid(id), true);
                if (claim.ClaimStatus == ClaimStatus.P)
                {
                    return Json(new JsonData(true, "Claim has already been paid");
                }
                claim.ClaimStatus = ClaimStatus.R;
                ClaimsDao.Save(claim);

                return Json(new JsonData("Set to Ready to Print"));
            }
            catch (Exception ex) {
                return Json(new JsonData(true, "Error setting to ready status " + ex.Message));
            }
        }

I am using my ‘JsonData’ class- a serializable object to store the results

With just content, I use the ContentResult – this replaces any ugly ‘response.write’ calls.

The best part of all (outside of readability and no response write!) is that it’s easy to test!

Ruby on Rails

After my IronRuby posts, I thought I would go back to Ruby on Rails, get it setup again and pick up where I left all from a few years ago.

My first step this time was to grab ‘RadRails’ from Aptana.  I setup a RoR project and right away realized I didn’t have the standard ‘mysql’ database, etc…

At first I started to go get it, but then thought : why go through that, when I have a database installed (MS SQL 2005).  Quick google search on RoR with Sql took me here:

http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServer

Quick, clean, and to the point – excellent.

Ran the sqlserver adapter gem, setup the security, copied the ADO.rb file as it says, updated the database.yml and I was ready.

Aptana has a nice ‘homepage’ they give you as part of the setup of a new RoR project, which took me through about 3-4 steps to create a scaffolding.  I like Aptana’s tasks at the bottom of the editor: Generators/Rake Tasks, etc… so it was rather easy to setup.

Luckily for me it all ran well, and I ran the app. Presto, works great.

It’s VERY interesting coming back to RoR after looking at Monorail and then the use of the MS MVC.  All I can say is that I have a much different perspective of rails now  šŸ™‚

I’m big into jQuery – and I understand Rails is more ‘prototype’ oriented ?  Not a big deal, but I’d like to stick to my jQuery.  So I’ll have to investigate this.

Also, this time around, after working with NHibernate, etc.. I’m curious how RoR ActiveRecord matches up.

IronRuby

As a complete newbie, I’ll share some experiences as I learn:

1. a good intro – watch the 5 minute movie: http://www.ironruby.net/

2. some important getting started with IronRuby on the wiki: http://ironruby.rubyforge.org/wiki/wiki.pl?BuildingIronRuby

Update:

3. Defining MVC Routes and Views in IronRuby:  http://haacked.com/archive/2008/04/22/defining-asp.net-mvc-routes-and-views-in-ironruby.aspx

Now if I could just figure out how to set the environment variables to run rake (yes, I’m a serious newbie here!) I must have had a faulty install, I reinstalled ruby and it works fine

My new dream is to run a MS MVC application written in IronRuby.  Perfect.  šŸ™‚  (I think this is better than IronRuby on rails approach)

Vista Home Premium to Vista Ultimate – 10 hours and 20 minutes…

Due to getting the M$Shaft, I had to upgrade to Ultimate.  It cost another $180 to do it.  The entire reason was because M$Shaft decided that Home Premium wouldn’t have the authentication required in it’s IIS – so I can’t run Reporting Services.  Then, the Virtual PC doesn’t support Home Premium either.

But ok, so I get the upgrade.  It took 2 hours to examine my machine to check compatibilities.  It took another 8 hours (I started it at 6am this morning, finished at 2pm) to perform the upgrade.  Then another 20 minutes to ‘check my computer performance’.  I run a Core 2 Duo with 2 gigs of Ram.

On the package it said 32-bit or 64-bit.  I was happy, thinking I would upgrade to 64-bit.  But no, nowhere did it say that you can only go from 32-bit to 32-bit.  So another major disapointment.  I suspose when I buy 2 more gigs of memory to run this hog, I will have to reformat and take another 10 hours to install the OS.

Lets be frank – I only run windows software on this work laptop in order to run my development environment.  That is shame, as I would be more than willing to run Linux, etc… if it could run all my software.

I guess once MS hooks you into using some of their software, they proceed to rake you over the coals in expenses.  $180 and 10 hours to upgrade… amazing.

šŸ™‚

Oil

Ok, this is a first and hopefully a last.  I tend to stay strictly technical here on this blog.

But, I have to comment on this one  šŸ™‚

Rant start:

Basically, I think the US suffers from an energy management problem.  We are very dependent on oil. 

GDub summed it up here:

“It’s not enough. It’s something but it doesn’t solve our problem,” Bush said. “One of the interesting things about American politics is, those who are screaming the loudest for increased production from Saudi Arabia are the very same people who are the fighting the fiercest against domestic exploration, against the development of nuclear power and against expanding refining capacity.”  (site reference http://news.yahoo.com/s/ap/20080517/ap_on_go_pr_wh/bush_mideast )

Reducing dependency on foreign oil MUST be a priority.  The impact of gasoline prices effects EVERYTHING in our economy.  It raises the price of shipping, production, etc… – which in turn causes the added price to be applied to everything we buy as a consumer.

This election season, I urge everyone, regardless of your political party views to make sure your candidate and congress representative is working to allow the US to be dependent on it’s own resources vs. foreign dependencies.  We have the resources, but politics blocks those capabilities. 

Rant over.

Back to coding…  šŸ™‚

Sharp Architecture

Billy has posted his new best practices with asp.net mvc, nhibernate and spring.net.  This is the same architecture that I have been using (we have conversed on a few emails) and it’s a good setup. 

Those 3 frameworks together can provide a good sound solution.  Spring.net handles the dependency injection of controllers and dao/repository objects as well as manage the nhibernate session and transactional support.

As he mentions in the documentation, Ayende’s NHibernate Query Generator is a ‘must have’ for me with nhibernate. It integrates into Visual Studio and gives a ‘linq like’ expression language for your dao/repositories.

Great stuff as always from Billy.  Here is a direct link to the codeplex setup: http://www.codeplex.com/SharpArchitecture

(Side note:  It would be good to see Spring.NET provide Entity Framework support for handling the DataContext.)

I’d like to add into this architecture the use of jQuery for all the client side/ajax/UI control needs.  Obviously there are several good javascript packages available (Prototype, Dojo, YUI). I have found jQuery to handle just about everything I have needed in my projects.  jQuery allows for the use of unobtrusive javascript development.

examples of how I’m using jQuery:

  • good ajax support – including jQuery forms – allowing forms to be posted via ajax with validation
  • validation support
  • table sorting/paging support
  • autocompletion
  • tab controls
  • date controls
  • input masks
  • modal popups
  • etc…

the jquery website has links to hundreds of user created solutions.  (I use Firebug as well for debugging my javascript and ajax code)