Fremus.co.za

Demistifying Life and Web Development

Archive for July, 2010

Trying out Powershell 2.0

Recently I have been dabbling a bit with Ubuntu and I really liked the command line approach because it feels like you got this powerful sword that you can wield around. Linux is great, but I am still a Windows person (bad I know) but its the truth. So I was looking around and reading and at one point today I wondered if you can connect to a Linux shell through Windows Powershell, but it didnt seem to evident. All the thinking and reading got me to search for a Powershell 2.0 “download page”, which doesnt really exist. You have to download an update for Windows XP (if you are running Windows XP like me). Windows 7 has Powershell installed by default. Once you have downloaded and installed it you are ready to use Windows Powershell. I found two items under my Accessories –> Windows Powershell menu:

powershellscreenshot

The first item takes you directly to the command line and the second one takes you to an IDE for debugging and testing your Powershell scripts, which I found useful for syntax checking. My first script was just a test to print some text on the commandline:

powershellscreenshot1

To execute you run this in the commandline (if you have saved the script above to a folder called powershellscripts):

powershellscreenshot2

The code above was just for myself and so that I could get some of basic mechanics right. My goal was to create a script that could connect to a SQL Server database and retrieve data, and store it. I also found two places useful as reference for examples:

I looked at a few samples and came across a sample that connected to an OLE DB (Microsoft Access) and what struck me was that the code looked a lot like standard ADO.NET code, although there are a few differences. It seems variables are declared with a dollar ($) sign and there are no semicolons (being a C# person that was a surprise). With the sample I started creating my own sample that connected to a SQL Server 2008 Express database:

powershellscreenshot3

As you can see from the code parameters are passed with a param(…) and class instances are created with the new-object keyword. If you type a variable it will be printed as is the case with the $tbl variable.

I know there is a whole lot more that can be done, but I was surprised with how easily I could connect to a database.

  • Share/Bookmark
posted by fr3dr1k in SQL Server 2008,Windows Powershell 2.0 and have No Comments

Logging frameworks for C#

I find myself going to StackOverflow a lot recently if I need to search for an opinion on something related to C# or ASP.NET. Strangely you will find that in the first 10 results of a Google search you will find one, maybe two, pointing to StackOverflow. I digress, and the reason I am writing this particular blogpost is to make a list of logging frameworks available to .NET (C#) developers.

Before I go into identifying a few possible solutions I need to try and understand what my need is and what it is I want to achieve. I am going to be tackling various ASP.NET MVC projects within the next two to three months, and I cannot possibly see myself knowing where all the exceptions in my application will happen, or even try and code in such a way that all my try{}catch{} statements catch the correct exception. At the same time there is no excuse to overlook an exception if it happens more than once, you have to handle it. Having noticed how many exceptions a WCF service can throw I know for a fact that I cannot know all the exceptions beforehand either, so I need something, a tool that allows me to see the exceptions, and add it to my code so I can catch them. So the basic need is simple, have a mechanism in place that allows exceptions in my system to be caught.

You might be going, OMW you don’t log? Well I have been with several development teams and I can tell you that not a lot of development teams log system errors. And there is a host of other things they also don’t do, but that is not a part of this blog post.

I searched StackOverflow, and to me it seems there are a couple of choices available for logging in the .NET world:

Maybe I need to consider all the features offered and decide on the best alternative, which would be:

  • Ease of installation
  • Ease of getting to the exception logs

My intention is to start looking at each one of these this week, and make a decision by the end of the week.

  • Share/Bookmark
posted by fr3dr1k in C# and have No Comments

I remember…

A big field where I played rugby and cricket with other kids. We had our own tournaments going, even though we only had two or three players in the side. Cricket was played with no wicket keeper, any nicks behind were given out. We also limited scoring shots to the leg side only, off side scoring was not allowed. We had our rules in place, and the tournaments and matches played were memorable, and life changing. I only found out this year that one of the kids, a great childhood friend, died some time in 2008, which really saddened me because we had a lot of memorable times together.

We played rugby on a quarter of a full playing field, by playing vertically down in that quarter. So if you can imagine a rugby field for a minute, think of the goal line and the quarter mark, and imagine a group of kids, maybe 4-5 a side playing in that space. We had imaginary goal posts, so we kinda guessed if we kicked a drop goal, and we only had three in the scrum, but it was the memories that were created that have remained with me in my short 29 years of life.

The last time we played cricket I was in standard 7, grade 9, or about 15 years old, and since that time I have had little to no contact with any of my childhood playmates. Due in most part to people moving around, and moving to new neighbourhoods. I saw the friend that died a few times after that, but not frequently, and I guess it kinda signaled an end to that part of my life.

Looking back at these memories got me thinking about personal branding and finding inspiration in my life through stories. Stories are sometimes the best way to communicate a value or a lesson, and I can personally say that I have learnt most of my values through the lessons in my life. In saying that I guess the first important aspect of my personal brand is that I love stories, stories about life and stories that reflect determination and character. Playing cricket as a young boy was about being able to play cricket, no matter where we played. We had our favourite spots, but often our spots weren’t available and we made plans, we adapted. We even kept stats of each game for each player, and there was always a lot of competitiveness for being the player with the most runs or the most wickets. We were free though, free to play and be, and that is the second aspect of my life that I have always tried to treasure, freedom. You know the feeling you get when you are in a swimming pool and you are all alone and you can swim freely without knocking into anyone? Freedom to run around on open fields, to sleep late in the school holidays, to express yourself in any way you wanted to, thats what I valued the most. How do you reflect that in a personal brand?

  • Share/Bookmark
Tags:
posted by fr3dr1k in Personal and have No Comments
Get Adobe Flash playerPlugin by wpburn.com wordpress themes