Archive for the ‘Technology’ Category
Getting started with Mercurial on Windows
Microsoft made a big move recently by supporting Mercurial on Codeplex. The company I was working for in 2009 was contemplating moving to a DVCS (Distributed Version Control System) and had we made the move, we would have gone to Mercurial. So I’ve been using Mercurial off and on for the last 8 months and have been pleased with the ease of use and the clean command set.
First get and install TortoiseHg - http://tortoisehg.bitbucket.org/
If you are just starting with Mercurial here are some basic commands that will get you going. For the sake of this article, I’m going to use Orchard as the example repository.
-Orchard source url: https://hg01.codeplex.com/orchard
-Clone repository: hg clone https://hg01.codeplex.com/orchard
-Clone repository (named working directory): hg clone https://hg01.codeplex.com/orchard my_dir
-Pull source from remote: hg pull -u
**Note: ‘-u’ is important since it updates your local working copy after pulling the latest
-Local commit: hg ci -m “some message”
**Note: Remember that you are committing to you local repository, you still need to ‘push’ to your remote repository.
-Push commits to remote: hg push
**Note: this command will likely request your credentials
-Check status of local files: hg status
-View the commit log: hg log
-View the most recent commit: hg tip
If you prefer to use visual tools then just type ‘hgtk’ at your command line and you will see all of the commands that will launch visual Mercurial tools. The following is an example for the visual log.
-View visual log of commits: hgtk log
If you have been using git or bazaar, then switching to Mercurial should be trivial.
What I’ve shown here is just the very beginning set of commands for Mercurial. If you want to dig deeper, then you’ll want to read the Hg Book.
An Iowa City Blogger
I met Bill Sorenson at the Iowa Code Camp recently and figured out that he has been blogging on tech topics for quite some time. Go check out his blog here.
Func<T> based Generic List Initializers
A couple of weeks ago I was writing some code to initialize List<T> but my technique was very verbose and it seemed to be a distraction from what I was trying to do. Plus it seemed that every one else was writing about getting their func on.
So I looked back at some code that Nick Parker had written:
1: public class Builder2: {3: public static TType Create<TType>(Action<TType> actionOnTType) where TType : new()4: {5: var item = new TType();6: actionOnTType(item);7: return item;8: }9: }
And tweaked it to initialize a list:
1: public class Builder2: {3: public static List<TType> CreateList<TType>(long size, Func<TType> initExpression)4: {5: var items = new List<TType>();6: for (long i = 0; i < size; i++)7: {8: TType item = initExpression();9: items.Add(item);10: }11:12: return items;13: }14: }
Now I can initialize a list like this:
1: List<Door> doors = Builder.CreateList(100, () => new Door {IsOpen = false});
Just for the record the Func initialization above could handle much more complex scenarios if needed. My usage is very simple.
Another variation on this is to create an extension method that does the same initialization like this:
1: public static void Init<TType>(this IList<TType> values, int size, Func<TType> initExpression)2: {3: for (int i = 0; i < size; i++)4: {5: TType item = initExpression();6: values.Add(item);7: }8: }
And here is how you would use the extension method version:
1: var doors = new List<Door>();2: doors.Init(10, () => new Door());
Thanks to Nick Parker for some suggestions as I was working on this.
Something I would like to figure out is how to do this based on IEnumerable instead of IList. If you have ideas regarding implementing this on IEnumerable please add them as comments.
Also, if you want to see where I was using this, pull down the subversion source here: http://subversion.assembla.com/svn/solon-tools/trunk/Puzzles
Learning Python
I’ve almost learned Python several times in the recent past, but now I’m committing to learn it. Some of my learning resources are The Python Tutorial and Dive Into Python. What are other good online resources?
I’ve installed Python 3 on my machine and also have IronPython setup so I can keep up with Microsoft’s implementation. Another goal with IronPython is to be able to us it in an ASP.NET project.
You can stop putting Change History in source, it’s 2008
CHANGE HISTORY
========================================================
AUTHOR LAST MODIFIED DESCRIPTION
========================================================
v-someone 2008-08-21 Initial Version
It’s official, we are at the end of 2008 and there are lots of good source control tools out there(some of the best are free).
You don’t need to keep putting change history comments in your source if you are using source control. If you add comments when you commit your code this will be handled for you.
Unity at CRineta
Jeff Brand from our North Central Microsoft office came to CRineta and gave a very good talk on Unity, Microsoft’s dependency injection container.
From my experience when people talk about IOC/DI they end up skipping basic concepts, but Jeff didn’t. It was really good because he went back to the very beginning and built a live code example along the way. And as he built the code base, he introduced all the core concepts.
I learned a lot and think I’ll introduce Unity into my current project. Structure Map has been on my list to learn for awhile, so I’ll probably use it to compare for usability and features.
Iowa Tech is Heating Up
Early this year I blogged about the general state the .NET community in Eastern Iowa and Iowa in general. Some of the goals on January 1st were to see more techies blogging, more speaking, to run our first camp and to see the tech community grow in general.
So here is an update. We had an incredibly successful first code camp at the University of Iowa conference center on May 3rd. We had around 130 people attend over the course of the day with about 25 people presenting.
On the blogging front, Tim Barcz has really taken his blogging up a notch and has moved over to the devlicio.us community. Chris Missal has been doing some nice work with ASP.NET and jQuery and I hope to see some more good blogging from there.
Bryan Sampica, Javier Lozano and D’Arcy Lussier(well he’s Canadian, but that’s close enough) are writing “ASP.NET 3.5 Programmers Reference“. This is very cool to have two Iowa authors writing a major programming title.
I’m sure there are other good bloggers in Iowa who are doing good writing, let me know in comments who else is out there.
Our next code camp in Iowa is just a couple of weeks away on November 8th. It is being held at the DMACC West campus in West Des Moines. We have great speakers from Colorado, Minnesota, Iowa, South Dakota, Kansas, Texas and Ohio. We are also introducing a new format called a fishbowl in two of the sessions. Register here if you haven’t already.
The Cedar Falls / Waterloo area is getting a new Ineta group (tentatively Cedar Valley INETA) headed up by Josh Flory. We hope to see good things happen up north.
CRineta webcasted it’s first user group meeting presentation in October which was interesting. We have some work to improve this medium, but it has a lot of potential for reaching people that can make it into the meetings. Josh Flory is the primary person who made this happen, so thanks to him.
The University of Iowa has a new Ruby group as well, which is a great development.
We have 2 1/2 months left in 2008 so let’s finish this year off well.
By the way, Tim Barcz, Derik Whittaker and I might have some big news in a week or two but I can’t officially announce it yet.
ASP.NET MVC goes Beta
I just saw that ASP.NET MVC went beta based on a tweet from Kevin Dente. Time to do some upgrades and see what is new and changed in this release.
jQuery, MIT and GPL
/*
* jQuery 1.2.6 – New Wave Javascript
*
* Copyright (c) 2008 John Resig (jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
* $Rev: 5685 $
*/
This text is the header in the jQuery 1.2.6 release. It’s obvious that it is dual licensed under MIT and GPL, but isn’t it still weird that Microsoft will support and will package a library with text that says “GPL”?
Props to the people at Microsoft who took the risk to push for this really good 3rd party JavaScript library.
YUI 2.6.0
In case you missed it, YUI did a nice update recently to version 2.6.0. A lot of controls like the Rich Text Editor have made it out of beta and there are some new one added like the Carousel.
I’m looking forward to testing these updates in several ASP.NET/ASP.NET MVC projects.