15 Years Ago…

Posted: October 19th, 2011 | Author: | Filed under: Tech | No Comments »

20111019-194951.jpg


Banned iPhone 4S Promo

Posted: October 14th, 2011 | Author: | Filed under: Tech | No Comments »

ASP.NET MVC View Converter

Posted: June 21st, 2011 | Author: | Filed under: .NET, Tech | No Comments »

The new Razor view engine was introduced with ASP.NET MVC 3. Applications that were built on earlier versions of MVC are most likely using the Web Forms view engine. To take advantage of the new benefits of the Razor view engine the existing Web Form views will need to be converted. For work, we were looking to convert our views to Razor views. To assist in this, we used an open-source tool from Telerik. You can download it here. It reduced some of the work for us, however, there was still additional work that was needed after running the views through the converter. Most of the work involved merging the multiple code blocks that the converter created. Overall, I would estimate that we cut down the conversion time approximately 30 – 40%.


Setting Default Isolation Level in SQL Server Management Studio

Posted: June 5th, 2011 | Author: | Filed under: Tech | No Comments »

As a software developer, it is very common that you may need to run an ad hoc query against a production database. If the ad hoc query is not written properly, deadlocks can occur. These deadlocks can bring down other applications that are using the same database and tables. These deadlocks can be avoided by adding the with(nolock) hint to each table in the query. Remembering this hint every time a query is written can be difficult. Recently, a co-worker pointed out a way to change a setting in SQL Server Management Studio so the default isolation level is set to “Read Uncommitted” which has the same effect as having the with(nolock) hint on all the tables of your query. This way, one does not have to remember to add the hint manually.

To change this setting, select Tools and then Options. Once in the option window as shown in Figure on, look for the settings under Query Execution, SQL Server, and then Advanced. Within that menu you will see an option for “SET TRANSACTION ISOLATION LEVEL”. Change this setting to “Read Uncommitted”. After completing this step, click OK and then make sure to exit out of all instances of SQL Server Managment Studio to ensure that the setting is saved.

After doing this, you will no longer have to worry about being the guy that wrote a query that brought down the production system.


Coalesce Operator in C#

Posted: May 26th, 2011 | Author: | Filed under: .NET, Tech | No Comments »

The coalesce operator in C# is a simple operator that I recently discovered. The coalesce operator is being used on line 14 of the code below. In the example below, finalString is being set to the first object that is not null, starting from the left. In this case, finalString will be set to “thirdString”. The use of the coalesce operator can simplify code since it can be used instead of null checks or the more complex conditional operator.

using System;

namespace TestApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string firstString = null;
            string secondString = null;
            string thirdString = "thirdString";
            string forthString = "forthString";

            string finalString = firstString ?? secondString ?? thirdString ?? forthString;

            Console.WriteLine(finalString);
            Console.ReadLine();
        }
    }

The following code is an example I often find where the conditional operator is used to set a value for a sql parameter before calling a stored procedure.

cmd.Parameters.AddWithValue("@Name", customer.Name == null ? "" : customer.Name);

This code could utilize the coalesce operator to simply the statement further.

cmd.Parameters.AddWithValue("@Name", customer.Name ?? "");

Figuring out what is using a port in Windows

Posted: April 27th, 2011 | Author: | Filed under: Tech | No Comments »

While trying to run a Java web service in Eclipse I was getting an error stating that “Port 8080 required by Tomcat V5.5 Server at localhost is already in use”. I shut down IIS, but I was still receiving this error. After some research I figured out that you can find the process id that is listening on a port by typing “netstat -aon | findstr 0.0:8080″ into the command line. Once you have figured out your process id you can figure out what application is running under that process id by typing “tasklist | findstr <process id>” into the command line. In my case, the process id was 2096. I found out that SQL Server Reporting Services was running under port 8080. I shut down reporting services and then I was able to start Apache Tomcat.


Measure Activity, Sleep, and Calorie Consumption with Fitbit

Posted: April 16th, 2011 | Author: | Filed under: Tech | No Comments »

I’m no Oprah, but I thought I would share one of my favorite things anyway.  Fitbit is like a pedometer on steroids with a comprehensive website to support it. This isn’t any ordinary pedometer though. It measures your activity during the day and while you are asleep. On the device itself you can see your daily steps, recent activity, and calories burnt for the day. The real magic happens when it syncs with the website and it syncs flawlessly. There is a small base station that you leave plugged into your computer. Whenever you come within 15 feet of your computer the Fitbit will send all of the data to your computer which will upload it to the website. Your Fitbit can hold many days of data so if you aren’t by your computer for a few days (yeah, right) there is no problem. The website is very well put together with a lot of AJAX goodness and data galore. You can also *easily* track what you are eating. This has been great for me. It’s amazing how much you cut back on food when you actually keep a food log. Especially when you can compare calories consumed directly against calories burned. You can even compete with your friends for the most steps in a given week. There are many other features that I haven’t mentioned here, but if you want to know more then check out their site.  Thanks to Steve for pointing out one of my new favorite things.