Excel WEEKNUM function in C#
After MANY attempts I finally figured out how to reproduce Excel's WEEKNUM function in C#:object Weeknum(DateTime date, Int32 retType) { DayOfWeek dayOfWeek = retType == 1 ? DayOfWeek.Sunday : DayOfWeek.Monday; var cal = new GregorianCalendar(GregorianCalendarTypes.Localized); var val = cal.GetWeekOfYear(date, CalendarWeekRule.FirstDay, dayOfWeek);Read More »
ClosedXML now evaluates formulas!
If you're dealing with Excel files and need a way to resolve/evaluate formulas then I've got great news. ClosedXML now evaluates formulas! Here's an example of this beauty in action:var wb = new XLWorkbook(); var ws = wb.AddWorksheet("Sheet1"); ws.Cell("A1").Value = 1; ws.Cell(Read More »
uninitialized constant Factory
So I added factory girl to my application like so:
group :test, :development do
gem 'factory_girl_rails'
end
I created the folder ./test/factories
and in it I copied a simple factory from the web:
Factory.define :user do |user|
user.name "John"
user.email "john@doe.com"
end
And I got the error: "in `<top (required)>':...Read More »
Running Ruby Programs from Notepad++
You don't have to leave Notepad++ to run your Ruby scripts. Just press F5 (or go to Run -> Run...), enter the following in the textbox:
cmd /K ruby "$(FULL_CURRENT_PATH)"
And then click Save As... to give it a name (I use the creative "Run Ruby") and the shortcut key...Read More »
Rails Testing on Windows (The Fast and Easy Way)
If you're developing Rails applications on Windows you've undoubtely found testing to be very painful and slow. This post will show you how to speed up and automate your tests. To be honest this post should have been titled "How to configure Rails + MiniTest + Autotest + Spork + Growl...Read More »The invocation of the constructor on type 'blah' that matches the specified binding constraints threw an exception.
This one got me running around for a while. The solution is to copy the binding information from your WCF project to the front end application that uses it....Read More »async/await
.Net 4.5 has a new feature that allows you to easily do asynchronous programming. You achieve it by the use of the async and await keywords.
At first I thought it was a "nice to have" feature but I wasn't as excited as I was with the introduction of lambdas... Until...Read More »An application without a save button?
I'm building a data profiler (don't have a name yet) and having to hit the save button seemed kind of odd. The problem I see is that if I'm doing something it's because I want it to be saved eventually, so why not *now*.
Apparently I'm not the only one in...Read More »Error VSP1712: Invalid File
This error is thrown by Visual Studio when you run out of disk space.
I got this because I ran multiple performance profiles of my pet project ClosedXML and forgot to delete them as I was testing. Apparently not many people forget to do this because I couldn't find anything...Read More »
Creating Excel files with ClosedXML
For the last 6 months I've been working on an open source project to make Excel files and now it's at a point where I can start "promoting" it. I called it ClosedXML and it's hosted on Microsoft CodePlex.
The reason for the name is simple, after seeing how horrible it is...Read More »
The Case Against TDD
To be more precise the title should have been "The case against enforcing Test Driven Development (TDD) as a strength jacket onto developers". I have absolutely nothing against people using TDD if it helps them write better code. The problem I have is with forcing developers to think and behave...Read More »
The right tool for the right job...
I'm a big believer in the 80-20 rule because I see it work almost every day while developing business applications. After gathering the requirements and sketching the application, we try to identify that 20% of effort which will give us 80% of the results. Usually after building it, our...Read More »Tracing and Debugging - Part 3
On previous posts we've seen how we can implement tracing for our applications. The only (major) problem with it is that we're setting up the tracing via code. What if we want to turn it on/off, output to different files and/or a database, or change the verbosity of the output?...Read More »
Tracing and Debugging - Part 2
In part 1 we looked at how we can implement tracing and debugging to know what our program is doing and any error it may encounter. In this post we'll take a look at more ways to use the Trace and Debug classes,...Read More »Tracing and Debugging - Part 1
This is the first in a series of posts to shed some light into tracing and debugging techniques. We'll start with the basics, configurations (via code and settings file), and then move on to more advanced topics like implementing your own customized trace listener and using aspect oriented programming to...Read More »