giovedì, febbraio 10, 2011

Upgrading to asp.net 4.0 & MVC 3

Time to get my hand dirty with some new web app.

I setup a new account on somee, that hosts asp.net 4 apps for free.

Uploaded a fresh new “hello world” app created by Visual studio 2010.

Wanting to make something with asp.net and MVC I configured the web app to also support MVC 3 following instruction foun here. Nothing fancy, only few steps to get things done.

To ease this process I created another web app configured as MVC 3 and compared the two.

So I added references to appropriate assembly (some assembly not found directly, but for System.Web.Mvc.dll under C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll).

Then modified web.config adding relevant tags.

Same thing for global.asax.cs, registering filters into the app.

Also modify the .csproj file and especially add proper ProjectTypeGuids i.e.

<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

To start quickly I followed the pluralsight training video as suggested by Scott Guthrie.

In the /Controllers dir there’s (guess what..) the controllers. Named with the name we choose terminating with a “Controller” string.

Views are stored under the /Views dir, grouped in a dir named as the controller.

So if we want to create a “Hello” controller the directory structure will be:

/Controllers/HelloControlles

/Views/Hello/Index.cshtml

HelloController.cs
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6.  
  7. namespace FitCalc.Controllers
  8. {
  9.     public class HelloController : Controller
  10.     {
  11.         //
  12.         // GET: /Hello/
  13.  
  14.         public ActionResult Index()
  15.         {
  16.             ViewBag.Message = "Welcome to ASP.NET MVC!";
  17.             return View();
  18.         }
  19.  
  20.     }
  21. }

.cshtml is the razor file implementing the view.

The URL for this view is /Hello/Index.

martedì, febbraio 01, 2011

Cubatura albero

Sabato sono andato a tagliare qualche pianta.

Legna20110130

Incuriosito da quanto potesse essere il peso di una pianta, mi sono cercato le formule per fare la stima.

Ci sono parecchie formule.. quella più semplice prevede la misura della superficie alla base e ad una determinata altezza.

Formula di Smalian o della sezione media: V = ( S0 + Sn)/2 * H in cui:
S0 : area della sezione presa al colletto (pedale della pianta); Sn : area della sezione di punta (senza cimale).

Alla base il diametro (senza corteccia) è 54 in alcuni punti e 52 in altri… approssimo a 53.

L’altezza non l’ho misurata… calcolando che i pezzi di tronco erano lunghi 3,5, e che dovevano essere 6. Calcolo un’altezza di 21 metri, dove il diametro doveva essere di 10 cm.

L’area del cerchio è

….… Imbarazzato ……..\mathrm{Area}=\frac{\mathrm{circonferenza} \times \mathrm{raggio}}{2}=\pi r^2=clip_image002[5]

Quindi la formula risulta

 

clip_image002[21]

 
Quindi…

clip_image002[27]

2,4 metri cubi che dovrebbero pesare all’incirca 2,4 *860kg=2064kg ovvero 20 quintali.

A secco circa 10 quintali.