Walter Bagehot

I work in a bank. I was struggling to offer a pithy quote to a boss who is retiring soon. I came across this English chap, Walter Bagehot from the 1800s, whose ideas about banking endure to this day. He was also the editor for The Economist. Good stuff!

The greatest mistake is trying to be more agreeable than you can be.

The greatest pleasure in life is doing what people say you cannot do.

The real essence of work is concentrated energy.

You may talk of the tyranny of Nero and Tiberius; but the real tyranny is the tyranny of your next-door neighbor.

All the best stories in the world are but one story in reality - the story of escape. It is the only thing which interests us all and at all times, how to escape.

It is good to be without vices, but it is not good to be without temptations.

My new favorite line of JQuery

//alternate row appearance
$(”table > tbody tr:odd”).addClass(”odd”);

A close runner-up is this:

//bump up the contents of cells by removing first BR
$(”td.list-of-stuff-delimited-with-br”).find(”br:first”).remove();

I normally would handle stuff like this on the server side, but these save me the trouble, and considering it’s a presentation layer thing, doing it on the client just feels right.

Add Deployable Dependencies

Had a devil of a time getting my MVC app to run on a new server.

Until I ran across this handy tip:
http://www.britishdeveloper.co.uk/2011/06/adding-mvc-dependencies-to-project-for.html

Just right click the project and choose, “Add Deployable Dependencies”

Nice.

PetaPoco, MvcContrib Grid and Pagination

I’m using PetaPoco and MvcContrib in my current project.

I had a devil of a time finding a decent example of paging a grid in an efficient manner.

Here’s what I’ve got so far.

The Action should look like this:

——————— public ActionResult Index(int? page) { //Normally, with a big ORM, using AsPagination to lazy Paginate would work fine. //but it’s in-efficient to do this using PetaPoco //var  dbPage = Db.Query<SomeModel>(”") //    .AsPagination(page ?? 1, 10); //…so we’ll do it the PetaPoco way for efficient results var dbPage = Db.Page<SomeModel>(page ?? 1, 10, “”); //see if the Db really ran efficient sql Trace.Write(Db.LastCommand, “SQL to get resulsts”); //instead of AsPagination use CustomPagination which provides a “TotalItems” param var viewModel = new CustomPagination<SomeModel>( dbPage.Items, (int)dbPage.CurrentPage, (int)dbPage.ItemsPerPage, (int)dbPage.TotalItems); return View(viewModel); } —————————-
————–

@using MvcContrib.UI.Grid;

@using MvcContrib.UI.Pager;

@using MvcContrib.Pagination;

@model IPagination<SomeModel>

@{

ViewBag.Title = “Some Stuff”;

}

<h2>

Some Stuff to Page in a Grid</h2>

<div id=”grid”>

@Html.Grid(Model).AutoGenerateColumns()

</div>

<div id=”pager”>

@Html.Pager(Model).First(”First”).Next(”Next”).Previous(”Prev”).Last(”Last”).Format(”{0}-{1} of {2}&nbsp;&nbsp;&nbsp;&nbsp;”)

</div>

</div>

————————-

Here is an extension method to wrap up the CustomPagination.

So now the action method can be a bit tighter

And the View needs to look a little something like this:

Hope that helps
-Denis

Weird.

For a while there all my requests to google were going to various pages at microsoft. Yipes. Smelled like a nasty virus. Didn’t expect to see anything like that on my MAC! All browsers behaved the same. I opened my hosts file. Nothing odd there. After reading the hosts file it stopped doing it.

Very strange.