software, productivity & more
Software Development
Git for Dummies
Jan 13th
Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Here is a fantastic guide for beginners: http://rogerdudler.github.com/git-guide/
Thanks.
Localization in ASP.Net MVC Projects
Aug 11th
Hello all,
As I am new to .Net Framework & ASP.Net MVC, I was looking in to various articles that would give clear step by step instructions as to how to add localization to ASP.Net MVC Projects. Especially, localization of string resources.
Here is a fantastic article on Localization in ASP.Net MVC projects.
Thanks to the author.
CHARFORMAT to LOGFONT
Jun 13th
Thought someone might require this conversion.
CharformatToLogfont(CHARFORMAT & cf, LOGFONT & lf, COLORREF & cr)
{
lf.lfCharSet = cf.bCharSet;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH;
if ( (cf.dwEffects & CFE_BOLD) == CFE_BOLD)
{
lf.lfWeight = FW_BOLD;
}
CDC dc;
dc.CreateDC(_T("DISPLAY"),NULL,NULL,NULL);
lf.lfHeight = -MulDiv(cf.yHeight/20, dc.GetDeviceCaps(LOGPIXELSY), 72);
dc.DeleteDC();
lf.lfUnderline = ( (cf.dwEffects & CFE_UNDERLINE) == CFE_UNDERLINE);
lf.lfStrikeOut = ( (cf.dwEffects & CFE_STRIKEOUT) == CFE_STRIKEOUT);
lf.lfItalic = ( (cf.dwEffects & CFE_ITALIC) == CFE_ITALIC);
lf.lfWidth = 0;
_tcscpy_s(lf.lfFaceName, LF_FACESIZE, cf.szFaceName);
//save color separately because LOGFONT does not accept color
cr = cf.crTextColor;
}
LOGFONT to CHARFORMAT
Jun 13th
Thought someone might require this conversion.
LogfontToCharformat(LOGFONT & lf, COLORREF & cr, CHARFORMAT & cf)
{
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET
| CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_OFFSET;
cf.dwEffects = 0;
if (lf.lfWeight >= FW_BOLD)
{
cf.dwEffects |= CFE_BOLD;
}
if (lf.lfUnderline)
{
cf.dwEffects |= CFE_UNDERLINE;
}
if (lf.lfItalic)
{
cf.dwEffects |= CFE_ITALIC;
}
if (lf.lfStrikeOut)
{
cf.dwEffects |= CFE_STRIKEOUT;
}
//temporary create DC
CDC dc;
dc.CreateDC(_T("DISPLAY"),NULL,NULL,NULL);
cf.yHeight = 20*long( 0.5 + fabs(double(72*lf.lfHeight)/dc.GetDeviceCaps(LOGPIXELSY)));
dc.DeleteDC();
cf.yOffset = 0;
cf.crTextColor = cr;
cf.bCharSet = lf.lfCharSet;
cf.bPitchAndFamily = lf.lfPitchAndFamily;
_tcscpy_s(cf.szFaceName, LF_FACESIZE, lf.lfFaceName);
}
Linq – Distinct by a particular column
Apr 16th
I had a list of tags for a particular user. I wanted to show only unique tags. I initially thought there would be something an inbuilt ‘distinct’ operator in Linq. Unfortunately not. I then discovered the Distinct() function. But it doesn’t support filtering the results by a particular column.
Thanks to this StackOverflow question that set my direction. It says that I must use the ‘group by’ operator, which I did.
Following is the code that I ended up with:
//distinct tags for a particular user
var tags = from t in _db.Tags
where t.UserId == userId
group t by t.Name into g
select g.FirstOrDefault();
Since the query returns a group, we must select the first item in the group. Hence FirstOrDefault().
Thanks.
Why I upgraded to Entity Framework 4?
Apr 8th
I was happily working with Entity Framework 1 until I read at several places about its lack of important features that are normally expected from an ORM framework. I started thinking seriously about upgrading to Entity Framework 4 (yes, the next version after Entity Framework 1) after I read this No Confidence letter. It lists all the issues that EF1 has and also suggests improvements. Several architects signed it.
So I upgraded to Entity Framework 4. This required me to upgrade my projects to Visual Studio 2010 & .Net Framework 4. Along with this, I also upgrade my MVC 2 project to MVC 3 with the help of this article.
Although POCO & Persistence Ignorance are the two most-liked features, they did not interest me because I had already generated the Entity classes from the database in EF1 and mapped them to my own model. What interested me was Lazy Loading and Foreign key association.
Entity Framework 4 addresses several issues and it has undergone a major rework. Worth upgrading.
Thanks.
HTTP Test Client
Mar 3rd
When developing a RESTful Web service in ASP.Net MVC I was looking for a HTTP Test client that I can be used to test the RESTful API that I had created. It is easy to test HTTP GET with a browser. What I was looking for in the tool was the ability to HTTP POST/PUT/DELETE to any Url. Thanks to Stackoverflow where chris recommended a fantastic freeware tool called Fiddler
Definition from Fiddler’s website: Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and “fiddle” with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.
Thanks.
RESTful Web Service Using ASP.Net MVC
Feb 9th
Piers Lawson wrote excellent series of articles to guide you to write RESTful web service using ASP.Net MVC framework.
There are several parts (24 at the time of writing this post). But I think the first 12 parts are good for beginners to start with.
Part 1 – Part 2 – Part 3 – Part 4 – Part 5a – Part 5b – Part 6 – Part 7 – Part 8 – Part 9 – Part 10 – Part 11 – Part 12
Thanks.
REST for dummies
Feb 8th
In order to create a Web API for one of our products, I am learning about RESTful Web Services.
If you are just starting on REST, then here is the link that explains REST very clearly: How to Create a REST Protocol
To supplement this it is important to know the Common REST mistakes that developers make.
Thanks
Tools to compare & sync Sql Server databases
Oct 4th
One of my projects wanted me to look for a good software to compare and synchronize Microsoft Sql Server databases. Here is a list of free and commercial tools. I have not installed and tried all of them so I cannot tell which is the best. Thanks to my colleagues who had given me links to some tools.
RedGate – SQL Compare seemed to be the leader. If you are looking for a free tool then you can try Open DBDiff. We wanted a tool that can help use copy diff data between the databases being compared. This is what “Scripting” means in the below table. We couldn’t find any free tool that can compare data and also generate script for migration. Thanks.
| Software Name | Price | Primary Features |
| MSSQL.SchemaDiff | Free | Schema Only/No scripting |
| RedGate – SQL Compare | $395/$595 | Data & schema/Scripting |
| ApexSQLDiff | $399.00 | Schema Only/Scripting |
| Innovartis – DB Ghost Schema Compare | $350 | Schema Only/Scripting |
| Sofotex – DB Synchro Compare | $499 | Schema Only/Scripting |
| SQL Accessories – SQL Examiner | $300 | Schema Only/Scripting |
| SQLDelta | $330 | Data & schema/Scripting |
| Tetratrax – Database Compare | $195 | Data & schema/Scripting |
| AdeptSQL Diff | $320 | Data & schema/Scripting |
| Open DBDiff | FREE | Schema Only/Scripting |
| DatabaseCompare | $199 | Data & schema/Scripting |
| SQL DB Tools – SQLDBDiff | $60 | Data & schema/Scripting |
| SQL Effects – SQL Accord | $139/FREE | Advanced schema compare/Basic schema compare |
| DBComparer | Free | Schema Only/Scripting |
| StarInix Database Compare | Free | Schema Only/No scripting |
| Yessoft Sql Server Compare | Free | Schema Only/No scripting |
| BucketsoftData Comparisons Express | Free | Data & Schema/No Scripting/One table at a time |
| SCT | $99 | Data & Schema/No Scripting |