Open Source

Open Source

Launch shell script silently at login

 

In OSX I needed a shell script to execute at login. There are a few different ways to perform this so I thought it might be helpful to document what your options are. I've switched over to Emacs which typically has a longer startup time than editors such as Vim. This is the shell script we will execute: #!/bin/zsh emacs --daemon Oftentimes Emacs will stay open during an entire user session of the OS, so the sooner I can launch it the better. OSX offers a few different startup options for us. First, we have Login Items available within...

Vim Tip of the Day - File Explorer Navigation

 

I don't know how I didn't come across this before, but when using the file explorer built into Vim, you can tell Vim to automatically switch the working directory to the current file you are editing.  Normally in Vim if you performed a ":cd c:\projects\blah" and subsequently navigated three folders deeper to edit a file (say “c:\projects\blah\foo\bar\foobar\fun.cs”), then choose to go back into the file explorer from your current location by issuing ":e .", the "c:\projects\blah" will be listed, not exactly where you might expect to be.  If you edit your _vimrc file and put the following command in when...

Creating Objects - Round 3

 

Ayende has been discussing the different ways of actually creating objects in .NET and the perf cost associated to each of them.  I thought I'd add to the mix one more method, using the DLR.  I've talked to several people who have identified concerns with the speed of the DLR so I found the results rather interesting.  The context is still the same, identify the time it takes to construct one million Created instances. The delegate: delegate Created CreateInstance(int num, string name); The structure: public class Created { public int Num; public string Name; public Created(int num, string name) ...

Code to Live Video from Tulsa TechFest

 

Jeffrey Palermo and I sat down with Chris Koenig while at Tulsa TechFest back in October to chat about the new ASP.NET MVC stack.  Josh Holmes just published an extract of our conversation out on Channel 9 here.  This was recorded back in October, right after the ASP.NET MVC stack was first made public by Scott Guthrie down at the ALT.NET conference in Austin, TX.  We discussed other things such as the open source movement and it's relationship to the Java counterpart but they didn't make the cut in the editing room.  You can watch the video directly here.  Have...

ALT.NET Super Summary

 

It's simple in my opinion: Spreading pragmatic .NET I wasn't there, however that's my interpretation of the vision. I think one of the core competencies any developer needs to espouse is passion. Passion is at the root of being a pragmatic developer, regardless of whether or not you’re doing .NET/Java/Ruby/LISP, etc. We are going through a hiring phase at work right now, during the interviews, passion is one of the top characteristics that I look for in a candidate. Passion is a catalyst for being pragmatic. Where does your passion lie?  

NHibernate Performance

 

I am doing some research into the use of NHibernate over the use of the current data access layer we use at work. Overall, the results are very good compared with what we current had in place (lazy loading all properties, limited caching strategies to name a few), however I'm curious if anyone wants to ring in on past experience they have had with NHibernate. Our DBA is concerned that we will be losing out on cached execution plans from SQL Server by moving to NHibernate from stored procedures. It is my understanding that parameterize SQL can...

Castle Presentation

 

I will be presenting at the September Iowa .NET User Group meeting, if you don't have any plans September 5th come on out for some free pizza and a presentation on the Castle MicroKernel/WindsorContainer. I will be giving an introduction to the dependency inversion principal, and then we will jump into MicroKernel and the extensions that have been built on top of MicroKernel to create WindsorContainer. My final demo will include a custom facility to extend WindsorContainer that will provide integration with the memcached distributed object caching system. I hope to see you out there!

IronRuby Emerges

 

So John Lam annouced the alpha release of IronRuby, he mentions that they did a lot of work on string and arrays, unfortunately, with the current release .NET types aren't able to execute Ruby mixins. I was hoping to do something like the following: require 'mscorlib' require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' list = System::Collections::ArrayList.new list.Add(5) list.Add(10) list.Add(15) list.extend Enumerable list.each {|i| puts i.to_i} The following code does execute: require 'mscorlib' require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' require 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Application = System::Windows::Forms::Application Form = System::Windows::Forms::Form Button = System::Windows::Forms::Button Point = System::Drawing::Point Size = System::Drawing::Size MessageBox = System::Windows::Forms::MessageBox window = Form.new window.text = 'Testing IronRuby'...

EventWaitHandle.Set

 

This blog has been pretty quiet lately, what's going on, has Nick fallen asleep? Nope, I've just been busy wrapping a few things up. Most importantly, I got married on June 2nd, and we took a few weeks off to head down to Hawaii and relax. If you've never been, my recommendation is to skip Maui and head right for Kauai. I will be presenting at the Cedar Rapids User Group on January 7, giving my presentation on Castle's MicroKernel/Windsor Container, so if you are interesting in hearing more about the light-weight IoC container come on...

DLR Hosting Services

 

I was poking around within the DLR code that was release yesterday within the IronPython Alpha release and I came across the Script class which allow local hosting of a script. Given a language provider you can then execute a block of code. Internally the ScriptEnvironmentSetup loads 4 LanguageProviderSetup classes currently IronPython.Hosting.PythonLanguageProvider Microsoft.JScript.Compiler.Hosting.LanguageProvider Microsoft.VisualBasic.Scripting.Hosting.VisualBasicLanguageProvider Ruby.Hosting.RubyLanguageProvider Unfortunately it appears they are only including the IronPython.Hosting.PythonLanguageProvider with this current release. A quick example of what you can do, the Script class is a wrapper around the ScriptDomainManager: using System; using Microsoft.Scripting; namespace IronPythonScriptHost { class Program { static void Main(string[] args) { string code = "print \"Hello\"...

Tailing your log file

 

In Unix we have tail -f which will allow a user to see during real-time the values that are being committed to a log file. I tend to use log4net as my logging utility, however I can't always use a console appender to view your log in real-time. On Windows, a good replacement is called Tail for Win32 which allows you to do the same thing, and also colorize the output based on keywords. A nice little tool.

Vim Commands

 

The other day I mentioned there are a ton of keyboard commands within Vim. This can initially make usage difficult if you're not familiar with the bindings. I've put together a simple sheet of basic commands you can find here. If you know of a good command that you think belongs on this sheet let me know and I will add it.

Choosing a Text Editor

 

By and large I live in Visual Studio day in and day out. I picked up a copy of the Pragmatic Programmer back in 2000 and I continue to re-read it every so often, it’s a treasure trove of great information, I highly recommend it if you haven’t read through it before. One of the points Dave Thomas and Andy Hunt make in the book is to pick a text editor and know it well. The goal here is being proficient and learning the keyboard binding that your text editor provides can further improve your daily efficiency....

MVC in ASP.NET

 

Jeffrey Palermo recently commented about a discussion he and the CodeBetter guys had with Scott Guthrie regarding adding new support for MVC within ASP.NET. While I didn't get a chance to talk to Scott, I hope they look at other features that current MVC frameworks provide that make the development cycle more fluid. For example, the process of extracting values submitted from the form can be tedious. Within MonoRail, the MVC web framework provided from Castle, if your controller inherits from the SmartDispatchController, you can take advantage of data binding back to the action of your...

Upgrading to Subtext

 

The other day I finally decided to replace CommunityServer with Subtext. After upgrading to CommunityServer from .Text a while ago, I found the user experience less than friendly. Subtext also is offering more features right now than CommunityServer such as cocomment and akismet support out of the box. Scott mentioned recently that CommunityServer is looking to potentially add cocomment support with the next release, I'd rather not wait. Blog spam is increasingly an issue, while I was working on the import process, I deleted 9,410 spam comments. Most importantly I now have the source code...

Drawing the line

 

Ted Neward recently commented about a comment that Scott Hanselman made during the patterns & practices Summit. Scott said that his company Corillian had built an abstraction layer atop of log4net. From Ted's perspective, the Java world has been dealing with too many layers of abstraction for the last decade they are paying the price for it (agreed). Ted also brings up YAGNI, suggesting that layers are added without an existing need. In my opinion they are both right (way to take sides huh?) Java is attempting to dig itself out of a hole, an example of...

Heartland Developers Conference

 

The 3rd annual Heartland Developers Conference will be October 26th and 27th in Omaha, NE. HDC has just sold out with over 500 attendees expected! Tim Gifford and I will be presenting on the Model View Presenter pattern within ASP.NET 2.0. It appears that Kent Tegels is presenting at the same time. He is covering the new Entity Data Framework which sounds intriguing. For those that are curious, we will be using NHibernate for our data persistence tool during the presentation. :-) Let me know if you'll be out there the night before...

Subversion on Google and CodePlex Errors

 

Google has recently provided access to creating Subversion repositories with you gmail account for projects here. After performing a small import, the SVN access Google provides is rather slow, hopefully they are still working on this. Microsoft released CodePlex at the end of June, a development community site which interacts with Team Foundation Server. CodePlex is currently limiting the amount of projects that are created to help scaling efforts. After accepting the terms and conditions to download the Jad Engine project, I got the following helpful error message: Hopefully some of the developers on CodePlex...

Rhino Mocks To The Rescue

 

A recent discussion on the Test Driven Development group brought in question the lacking ability of NMock for mocking classes. NMock will currently only mock an interface. The problem arose when the author wanted to mock a class that takes parameters in its constructor. His solution is to add an Initialize method to the interface and then every other method checks to confirm the object was initialized. While that is very mechanical and error prone - it does work, however there is another solution. Rhino Mocks allows you to create a PartialMock of a class...

Dependency Injection with StructureMap

 

I have posted previously about using Spring.NET as an IoC container and how we can implement some of this out of the box with the System.ComponentModel namespace. StructureMap is another dependency injection framework that in my opinon is much more approachable than Spring out of the box. Why? - Let's take a look at what it takes to start requesting services from the StructureMap container.   IRule rule = ObjectFactory.GetInstance<IRule>(); or for .NET 1.1   IRule rule = ObjectFactory.GetInstance(typeof(IRule)) as IRule; To begin with, StructureMap now supports generics (granted the 1.0.2 release of Spring does as well), however...

Asynchronous File I/O with NAnt

 

I recently needed to recursively iterate over a directory and change the content of files based on a search term. While there are certain NAnt tasks that have been defined to perform similar operations such as the foreach task used in conjunction with a loadfile and its associated filterchain and replacestring, I didn't see an easy way to recursively navigate the directory and perform my changes. A potential solution might have been nesting several foreach tasks and assigned the child directories to a property and subsequently call a different task to pull that directory out of the property, it didn't...

Extending Enterprise Library 2.0

 

Brian Button, formerly of the Patterns and Practices team just held a webcast covering how to provide custom design time extensions to the Enterprise Library console. I missed his session, however after reviewing the slide deck which he has provided, extending Enterprise Library appears much easier than when I had to do it only a year ago. Definitely worth checking out if you would like to integrate your own custom extensions within Enterprise Library.

Inversion of Control with Spring.NET

 

I have previously mentioned using the Spring Framework for the AOP support the framework provides, however Spring is deeply rooted in providing dependency injection or Inversion of Control (IoC). Spring uses a configuration file to manage type relationship mappings to objects, which can be stored in its own external XML file, an embedded resource within an assembly, or directly within your web.config or app.config file. For a simple example, we will define our own XML file (spring.xml), with the following contents:   <?xml version="1.0" encoding="utf-8" ?> <objects xmlns="http://www.springframework.net"> <object name="Database" singleton="false" type="SpringDemo.Database, SpringDemo"> <constructor-arg ref="SqlConnectionObject" /> <constructor-arg ref="SqlCommandObject" /> </object> <object name="SqlConnectionObject" singleton="false" type="System.Data.SqlClient.SqlConnection, System.Data"> <constructor-arg type="System.String" value="Data...

Ruby on Rails and .NET

 

There has been a lot of hype out in the development community over the past year regarding Ruby on Rails, even with Ruby alone. For those that are unaware, Ruby on Rails is a full stack web framework written in Ruby. While I've only read the first 100 pages of Agile Web Development with Rails, I can say that RoR is very intriguing. At a high level, RoR relies on a MVC architecture, using the ActiveRecord design pattern for data persistence. I've found radrails to be an excellent IDE for RoR if you're developing on a Windows machine. If...

Debugging Web Services

 

Recently I have been working on a mobile application running on a Pocket PC. The application uses XML web services to synchronize itself with SQL Server. Web Service Studio allow you to point to a web service to which it will generate the proxy, compile it, generate an assembly, and then reflect over that assembly providing you a user interface to the web service. You can then select any of the methods the web service exposes and it provides a UI to interact with you web services, showing you the results. This tool is very similar...

CruiseControl.NET

 

For those of you using CruiseControl.NET, and in particular the CCTray tool, here is a great link for audio sounds for your various build results. Does anyone have any favorites?

AJAX Search

 

I decided to update my search by adding a little AJAX support via Michael Schwarz’s Ajax.NET library. When implementing the Ajax.NET library within a user control, I found that the suggested method of registering you class with the library in the Load event doesn’t work properly. While the library does emit the Javascript references to the HTTP handler (the purpose of registering your class with the library), invoking a call to the proxy didn’t work correctly. This only appeared to be an issue with user controls, regular .aspx pages work correctly. By directly including the two...

Assembly Probing

 

As some of you are aware, I have been working on a UITypeEditor for a custom designer in Enterprise Library. This designer will support Inversion of Control (IoC) Containers for Enterprise Library. Part of the UITypeEditor allows selecting of an assembly and class, be it installed in the GAC or a private assembly. I was running into an issue when I would load a private assembly and attempt to get it collection of types. I was using the static Assembly.LoadFrom method which worked well, except when I called GetTypes(), a ReflectionTypeLoadException exception was thrown. ReflectionTypeLoadException contains a property called LoaderExceptions,...

Composite UI Application Block

 

The group behind the Composite UI Application Block (CAB) just released a community technical preview. CAB is based on .NET 2.0 and its purpose is to allow abstract complex UI design for smart clients. If you would rather spend time working on the business specific components of your application rather than getting caught up with threading and asynchronous requests you should check this out.

My Latest Article

 

My latest article has been published on The Code Project. Custom Data Binding Through Reflection discusses the use of both reflection and custom attributes to map data objects to UI elements. Check it out if you have a chance, let me know what you think as well.

Microsoft vs. Sun – Web Frameworks

 

Over the years both Microsoft and Sun have attempted to provide different programming frameworks to developers, yet as these frameworks are all vying for the same goal (i.e., higher developer productivity, easier integration, etc.), they are attacking their goal from opposite ends of the spectrum. If we look back at ASP, before .NET we see that Microsoft provided a framework centered on a COM infrastructure that allowed everyone to develop their applications in either VBScript or JScript. Mind you, there was no inherent framework for web development, at least, not in the sense that we tend to see it now....