| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 22 | 23 | 24 | 25 | 26 | 27 | 28 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | 8 | 9 | 10 | 11 | 12 | 13 | 14 | | 15 | 16 | 17 | 18 | 19 | 20 | 21 | | 22 | 23 | 24 | 25 | 26 | 27 | 28 | | 29 | 30 | 31 | 1 | 2 | 3 | 4 |
Subscribe to this feed:
|
|
Archives:
| May, 2010 (1) |
| March, 2010 (1) |
| November, 2009 (1) |
| September, 2009 (1) |
| July, 2009 (2) |
| June, 2009 (1) |
| May, 2009 (1) |
| March, 2009 (5) |
| February, 2009 (3) |
| July, 2008 (1) |
| June, 2008 (2) |
| May, 2008 (1) |
| April, 2008 (2) |
| March, 2008 (4) |
| February, 2008 (4) |
| December, 2007 (2) |
| October, 2007 (2) |
| September, 2007 (1) |
| June, 2007 (1) |
| May, 2007 (4) |
| April, 2007 (4) |
| March, 2007 (2) |
| February, 2007 (4) |
| January, 2007 (3) |
| December, 2006 (1) |
| November, 2006 (4) |
| October, 2006 (7) |
| September, 2006 (2) |
| August, 2006 (14) |
| July, 2006 (9) |
|
Need to generate create scripts for your SQL Express database? Here's a little batch I've used several times recently to do just that: @echo off
SET DatabaseFileName=DbName
ECHO Generating code for %DatabaseFileName%
ECHO Generating create script 'CreateDatabaseSchema.sql'
"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\SqlPubWiz.exe" script -C "Data Source=.\SQLEXPRESS;AttachDbFilename=%CD%\%DatabaseFileName%.mdf;Integrated Security=True;User Instance=True" -noschemaqualify -schemaonly -nodropexisting -f CreateDatabaseSchema.sql
To use, just drop in a .bat next to the .mdf, change DbName and run. It will output 'CreateDatabaseSchema.sql containing create script for all of the tables and stored procs in the database.
I've recently started playing with NDepend again. This tool is a sort of data mining utility for your code. Feed it your assemblies and it can tell you almost anything about them. Using a custom query language with a SQL-like syntax, you can dig into all sorts of metrics and useful information. Out of the box, it ships with tons of useful queries for common code problems. I ran some of our code through it and got dinged on some of the code complexity queries: In this case, I had several huge methods that needed to be broken up and optimized. Thanks to NDepend's prodding, I spent some time refactoring using ReSharper, and whittled those down to 0s:  That's helpful, but not nearly everything that NDepend can do. For example, the code I'm testing with is involved in some multithreading, so with a little digging through the docs, I came up with this query to show all methods that change state (besides property and event setters), but don't use any locks: WARN IF Count < 0 IN SELECT METHODS WHERE !IsDirectlyUsing "System.Threading.Monitor" AND ( ChangesObjectState OR ChangesTypeState ) AND !IsConstructor AND !IsClassConstructor AND !IsPropertySetter AND !IsEventAdder AND !IsEventRemover This doesn't guarantee thread-safe code, but it definitely helps drill down to potential problem areas. Another area I can see us using this in is to provide metrics for our customers. Generally they are not concerned with things like Cyclomatic Complexity, but some simple numbers may be useful. We use FinalBuilder, so it's possible we could run NDepend's console utility to roll the numbers into some XML and publish to their customer wiki. For example, here's a quick query to spit out the total number of tests for a project: SELECT METHODS FROM ASSEMBLIES "TestAssemblyName" WHERE HasAttribute "NUnit.Framework.TestAttribute" Once we get a customer set up with these metrics, we'll post more about how to automate that. Until then, go check out NDepend!
SharePoint is a great product, but one area where it really lacks is in it's Rich Text Editor. It doesn't work in anything but IE, and doesn't include an image upload feature. With a little digging, I found this free replacement from Telerik: http://www.telerik.com/community/free-products.aspx (ASP.NET RadEditor for MOSS Lite) Installation is non-obvious in the normal sharepoint way: - Run stsadmin.exe to install a wsp
- Deploy in central admin
- Turn on in site settings -> site features
- Restart IIS.
It comes with a chm help document (which if you’re using vista you’ll need to unblock to view) that outlines the steps. To turn on for a Wiki, follow the steps in ‘Using RadEditor in List Items’, and you'll have a much more usable SharePoint Wiki!
If you're not familiar with jQuery, it is a JavaScript library that lets you quickly access page elements using CSS-like selectors, and then do common effects, animations, and transformations against those elements. It nicely brushes away browser-compatibility issues and gives you a clean, simple way to do client-side "stuff". It ships in ASP.NET MVC, so I've been using it in one of our first MVC apps, and love it. What I particularly like, though, is using it to develop 'convention over configuration' for the app's client-side behavior. Instead of wiring up each individual form element, button, etc., I can declaratively say 'all elements with this class should behave this way.' This is done once in my site.master, so that in the actual pages, applying a behavior is as easy as including a css class name on an element. Let's look at some examples. The first step in most jQuery code is to wire up the document ready function. This tells the browser to execute some function whenever the document finishes loading, which believe it or not is quite difficult to do in a cross-browser way that plays well with other scripts. To do this, I have a script in my site.master's <head> section that looks like this: <script type="text/javascript">
$(document).ready(function() {
//TODO: set up conventions
});
</script>
The dollar is how you select page elements in jQuery. $(document) says "get the current document" (also non-trivial in un-aided javascript). You can also use css-like selectors. For example $("#myButton") will return all elements with the id "myButton". $(".initialFocus") will return all elements with the class "initialFocus". Which leads to my first "convention":
$(".initialfocus").focus();
Now, in any page that uses the master page, if a particular field should get focus when the page loads, simply specify the class "initialFocus":
<input type="text" class="initialfocus" name="somefield"/>
Or, in MVC parlance:
Html.TextBox("QuantityDelivered", currentTransaction.QuantityDelivered, new { @class = "initialfocus" })
Which is a nice UI touch, but let's look at something more advanced. I also want a convention to let me specify that a field can be populated using a pop-up date chooser. For this, I download the jQuery UI framework, and set up the convention:
$(".shortdate").datepicker();
Similarly, I add 'shortdate' as a class to any textbox, and the date chooser appears on the element. If I decide I want to change some behavior site-wide, I have one simple place to change it. For example, I could use one of the dozen other jQuery date pickers, or roll my own.
It's also possible to 'stack' effects. For example, this application displays informative message as a div with the class name "messageBox". If one of these appears when the page first loads, it hides after a few seconds. To accomplish this, you simply 'stack' an "animate" (which in this case is just used as a 5 second delay), followed by a fadeOut:
$(".messagebox")
.animate({ opacity: 1.0 }, 5000)
.fadeOut("slow");
All told, this particular app currently has 6 'conventions', with more planned:
$(document).ready(function() {
$(".initialfocus").focus();
$(".shortdate").datepicker();
$(".longdatetime").datepicker();
$(".print").click(function() { window.print(); });
$(".delete").click(function() { return confirm("This record will be deleted. Are you sure you want to continue? Click 'Ok' to delete this record or 'Cancel' to stay on this page."); });
$(".messagebox")
.animate({ opacity: 1.0 }, 5000)
.fadeOut("slow");
});
So, go get jQuery, whether or not you're using MVC. With just a few lines, you can really spice up an application's client-side experience.
I blogged about NArrange a while back, but there's a new version out that makes it even better. It adds support for organizing code without adding #region directives, which I'm beginning to agree are evil. The end result is a code file organized by member type and access level (ie fields, properties, private, public, etc), and then alphabetically. It includes a configuration tool which lets you set up a configuration file with all of the rules you want it to follow. To turn off #region directives open a configuration file in narrange-config, and change Formatting -> Regions -> Region Style to 'NoDirective'.
I'm a visual person. I've tried to join the keyboard-shortcut-cult. I've tried Enso, Live Desktop, Google Desktop, and just about any productivity-promising app Hanselman recommends. I love the idea, but somehow never end up using them. I never can remember the shortcuts, or even that they are there. But then again, it is Visual Studio, right? We do have Graphical User Interfaces for a reason. I'd just about given up on trying, until I learned one humble little keyboard shortcut that all by itself has saved me tons of time in VS: CTRL + . Any time you see the VS smart tag on some code, press that. Don't think, just do it. It will do your bidding, before you even know you bid it. Need to implement an interface? : <interface> Ctrl + . <enter>. Add a using namespace? <class name> Ctrl + . <enter>. Rename a variable? <rename> Ctrl + . <enter>. If you need pictures, here's more: http://haacked.com/archive/2008/06/23/visual-studio-smart-tag-expansion-tip.aspx
I was all about CleanSweep and DiskDoubler way back when I was 15 and they promised to double my disk to a whopping 40MB. Nowadays I usually shy away from these 3rd party clean up utilities. Partly because they tend to be spammy and questionable themselves, and partly out of principal - shouldn't the OS handle keeping itself tidy? But recently, with less than a GB left on my disk, and my system crawling, I decided to try out a few. Here are some winners I found: - JkDefrag - a free, faster, smarter defrag utility. It still uses the windows defrag API, but can be scheduled, run as a screensaver, etc. It also does some additional optimizations.
- SpaceMonger - a disk usage analyzer with a brilliant UI. Not free, but worth it.
- CCleaner - a free clean-up-everything utility. Temp folders, cache, registry, and all of that stuff the OS _should_ do, but doesn't (or at least doesn't do it all in one convenient UI). Unlike similar apps, this one is adware free (if you uncheck the 'yahoo toolbar' on setup) and has a clean, simple UI.
Between those, I managed to free up 10+ GB!
Configuring Virtual PCs' network adapters can be confusing. If you think about it, you're taking a network card, which typically has one IP address and one MAC address, and making it work for two computers. Add to that security issues - you may not always want a virtual pc getting out over your network- and things get complex quickly. Recently, though, I wanted to set up a SharePoint demo on a virtual machine, and wanted a setup that: - Allowed my host pc to connect to the web server on the virtual pc.
- Allowed the virtual pc to connect to the internet.
- Allowed the virtual pc to connect to my host pc
After a little digging, I came across this post on Ben Armstrong's blog that spelled out how to install the 'Microsoft Loopback Adapter' and wire it up to a host network adapter. It worked as advertised, but I had to reboot and forgot to set the loopback adapter in the virtual machine network settings. In retrospect, both pretty obvious steps, but, for posterity, here are full instructions for the above scenario (Most of these are straight from his post - be sure to check his blog out for much more Virtual PC info): Install Microsoft Loopback Adapter: - On the host operating system go to 'Control Panel'
- Go to 'Add Hardware'
- In the 'Add Hardware' wizard, click 'Next'
- When the 'Is the hardware connected?' page appears, select 'Yes, I have already connected the hardware', and then click 'Next'
- In the 'Installed hardware' list, select 'Add a new hardware device' and then click 'Next'
- In the 'What do you want the wizard to do?' list, select 'Install the hardware that I manually select from a list (Advanced)', and then click 'Next'
- In the 'Common hardware types' list, click 'Network adapters', and then click 'Next'
- In 'Manufacturer' list, select 'Microsoft'
- In the 'Network Adapter' list, select 'Microsoft Loopback Adapter', and then click 'Next' twice
- In the 'Completing the Add Hardware Wizard' page, click 'Finish'
Turn Internet Connection Sharing on, on the adapter that you want to share, NOT on the loopback adapter. Typically this is your Wifi or LAN adapter. - On the host operating system go to 'Control Panel'
- Go to 'Network Connections'
- Right click on the network connection that you use for Internet connectivity and select 'Properties'
- Click on the 'Advanced' tab
- Check the option to 'Allow other network users to connect through this computer's Internet connection'
- If you have multiple network adapters you will need to also specify that you are sharing the Internet connection with the Microsoft Loopback Adapter.
- Click 'OK'
At this point, I had to reboot. Your mileage may vary. Finally, in the virtual machine's settings, change the network adapter to use the loopback adapter: - In Virtual PC, go to Settings -> Networking for the machine
- Set Adapter 1 to 'Microsoft Loopback Adapter'
- Click 'OK'
I got my beta invite today and tried out Windows Live Mesh. There a are a couple similar services out there, not the least of which is Microsoft's own FolderShare. But what makes Mesh interesting is the promise of true, seamless synchronization between PCs, mobile devices, and the web. Your data just appears everywhere you want it to. In theory, there's no need to use ActiveSync or any other tool to sync up. Add to that a sharp, clean UI and this is an interesting new product (Excuse me, Technology Preview). By sheer coincidence, I also played with Peer-to-Peer binding in Windows Communication Framework. This lets you very easily expose your services in a P2P manner, and also uses the term "mesh" to describe the "cloud" into which your application is connecting. I haven't quite figured out when I could use it in a typical line-of-business app, but there's something fun about being able to dress up your services in P2P, Message Queuing, or any of the other suits WCF offers, just by adjusting configuration.
Did you know there was a "hidden" code-generation feature in VS2008? Text Templating Transformation Toolkit (aka T4) actually debuted in VS2005 Guidance Automation Toolkit, but shipped baked into VS2008. This gives you CodeSmith-style code-generation templates that can be used in your projects to generate code from any source. Simply add a text file with the extension ".tt", and VS will add a "Transform Templates" button to the solution explorer window. Here's a video that shows some of the basics: http://msdn2.microsoft.com/en-us/vs2008/cc308634.aspx
|