Here in Scribd we are using Git as primary version control system. We have tons of branches created, merged and destroyed every day. Someday I hope to describe our workflow with Git, but today I want to write about some useful techniques of working with this incredible tool.
It’s implied that you know what is Git itself and how to work with it. Below you can find some advanced tricks, that should be helpful for you (at least they were helpful for me).
Read the rest of entry »
I have not posted anything here for a long time. It’s hard to start blogging again, so I will write a short tips and tricks series called “Memo“. Today I’m going to talk about two Ruby gems I’m using in all my Ruby on Rails project: mysql and memcached. Every time I try to install or update those gems on Mac OS X following error occurs:
1 2 3
| Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension. |
And then I’m googling on how to install these gems. It’s time simplify my life and post commands here.
Read the rest of entry »
Some time ago I have started posting about Facebook Application Platform (see my posts about setFBML and Facebook libraries for .NET). Today’s topic is fb:editor. As you may see, Facebook has nice look and feel, and all applications usually adapted in some way to its interface. fb:editor FBML tag allows you to create forms which looks just like native ones, but it has great limitation: it generates it’s own form tag, so can’t be used within ASP.NET server form. In this short post I’ll show HTML generated by fb:editor and a way how to use it in your ASP.NET application.
Read the rest of entry »
Operator ??, that was introduced in the .NET 2.0, takes first place in my top used C# idioms list a long time, but unfortunately it is rarely used in projects I’ve participated. Therefore these snippets could be found in production code very often:
1 2 3 4 5
| public string Caption
{
get { return ViewState["Caption"] != null ? (string) ViewState["Caption"] : ""; }
set { ViewState["Caption"] = value; }
} |
Read the rest of entry »
Often in ASP.NET application we see a code which looks like this one:
1 2 3 4 5
| if (Cache["SomeData"] != null)
{
string name = ((SomeClass) Cache["SomeData"]).Name;
//.....
} |
Experienced developer, even if he is not a paranoiac, will find possible problem immediately — NullReferenceException. That’s because of caching implementation in ASP.NET. In ideal case an object, that has been cached, will stay there up to application restart, but in real world it could be deleted between two calls: by the garbage collector when memory is over (because cache uses weak references WeakReference); by another thread to refresh cached data.
So the code I have mentioned before works in 99% of all cases, but sometimes you will get errors in your log, which can not be reproduced easily. Here is right cache usage approach:
1 2 3 4 5 6
| SomeClass someClass = Cache["SomeData"] as SomeClass;
if (someClass != null)
{
string name = someClass.Name;
//.....
} |
Do not relax your vigilance, it’s exactly what they are waiting for! (about bugs)