A while ago I saw the anime Fullmetal Alchemist and I was really starting to like it. An interesting melange of dark horror, funny kid stuff and magic in a very consistent alternate universe. Unfortunately the anime ended, in a somewhat unsatisfactory way.

Enter Brotherhood. This is the "continuation" of the original series to match the progress of the manga. I believe it will quickly tell the story up until the end, then ignore the previous ending and continue in a new way. Unfortunately I already know what is going to happen, having read the manga, and also don't especially like that storyline either. I hope it will not suck like Berserk did. After a brilliant start it just failed utterly.

Anyway, hopefully the anime story arches will be more interesting than those in the manga.

There are two things you need to do. First, set the project as having a neutral language. This is done in Visual Studio 2008 by going to the project's properties, selecting Application, clicking on Assembly information and setting the language. However, it doesn't set an UltimateResourceFallbackLocation. So you have to do it manually, by editing the Properties\AssemblyInfo.cs file and adding
[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.Satellite)]


The second thing is rather dumb. I haven't found ANY way to do it from Visual Studio. I just edited the csproj file manually. It needs
<UICulture>en-US</UICulture>
set in (under, actually) every <PropertyGroup> in it.

What that does is create a language folder in the bin directory when compiled with a localizable resource file. Using the locBaml utility in the Windows SDK you can turn a resources.dll in the language folder into a CSV, then back into a dll like this:
LocBaml /parse ProjectName.g.en-US.resources /out:en-US.csv
LocBaml /generate ProjectName.resources.dll /trans:fr-CA.csv /cul:fr-CA
.

You will not find locBaml in the Windows SDK folder except maybe as a sample project. The sample project can be downloaded here. Don't forget to compile it!

Some other useful links:
WPF Localization
Localizing WPF Applications using Locbaml
LocBaml + MsBuild + ClickOnce Deployment

Rick Strahl presents an easier and better alternative by using normal resx files! I don't want to copy (too much) from his post, so just read it:
Resx and BAML Resources in WPF

and has 0 comments
I was just installing a new system, with all the necessary tools of the trade (Visual Studio(s), Sql Server, etc) and after I've installed VS2005 I noticed that there was no entry for the Business Intelligence Studio. I've tried all kinds of "solutions" on the net, varying from using some complicated command line to running vs_setup (exe or msi) or even reinstalling everything (which I refused to do).

In the end the problem was simple enough: Visual Studio installed some SQL Express version and the SQL Server 2005 setup thought I already had Business Intelligence Studio installed, so it never did reinstall it. The solution is to run this command line:
setup.exe UPGRADE=1 SKUUPGRADE=1
on the SQL 2005 installation kit.

Warning:
  • the parameters MUST be upper case, otherwise it will not work
  • it may be that only one of those parameters is actually necessary, but I have tried them both, anyway
.

and has 0 comments
I have seen this used in a couple of places, the most prominent being LInQ. You run a method and then you chain another method to it and so on and so on. It's a nice improvement in readability and a good alternative to static methods.

The clearest example I can give you is on Wikipedia. Check it out. It's actually very easy to use and implement.

Tomorrow I start work on a WPF application that is supposed to be as modular as possible. Since I know almost nothing about WPF or modular applications, I started researching a little bit how it should be done. Basically I found only two ways I cared to expand my research on: Prism (patterns & practices Composite Application Guidance for WPF and Silverlight) and MEF (Managed Extensibility Framework).

Unfortunately I've only had time to do some Prism, although MEF seems to be the way to go. First of all it is a general framework, not limited to WPF/Silverlight and secondly it is used in the new Visual Studio 2010 release. What is amazing is that both frameworks come as freely available opensource.

Ok, back on Prism. The concepts are simple enough, although it takes a while to "get" the way to work with them. Basically you start with:
  • a Bootstrapper class - it initializes the Shell and the Catalog
  • a Shell - a visual frame where all the modules will be shown
  • a Module Catalog - a class that determines which modules will be loaded
  • an Inversion of Control Container - class that will determine, through Reflection usually, how to initialize the classes and what parameters they receive
  • a RegionManager - class that will connect views with Regions, empty placeholders where views are supposed to be shown
  • an EventAggregator - a class that is used to publish events or subscribe to events without referencing the objects that need to do that


Easy right? I don't even need to say more. But just in case you don't have a four digit IQ, better watch this four part video walkthrough:
Creating a modular application using Prism V2 - part 1
Creating a modular application using Prism V2 - part 2
Creating a modular application using Prism V2 - part 3
Creating a modular application using Prism V2 - part 4.

I did try to take the WPF Hands on Labs project and mold it with Prism and it partially worked. The problem I had was with the navigation controls. These work as a web application, where you call the XAML and it has to be a file somewhere, and you have events for the calling and returning from those "pages". I could find no way to encapsulate them so I could build no modules out of them and the whole thing collapsed.

So, for a quick walkthrough on using Prism with WPF.
Creating the core:
  1. create a new WPF application project
  2. reference the Prism libraries
  3. create the Bootstrapper class by inheriting UnityBottstrapper that will determine the Shell (a WPF window class) and set it as the application MainWindow, as well as create the type of ModuleCatalog (either take a default one or inherit one from IModuleCatalog) you want
  4. create the layout of the Shell and add region names to the controls you want to host the loaded modules (example <ContentControl Grid.Row="0" Margin="2" Regions:RegionManager.RegionName="SearchRegion"/>
.

Creating a module:
  1. create a new library project
  2. add a class that inherits IModule
  3. the constructor of the IModule can have different parameters, like an IRegionManager, an IUnityContainer, an IEventAggregator and any other types that have been registered in the container (I know it hasn't been initialized in the core, the catalog takes care of that). The IoC container will make sure the parameters are instantiated and passed to the module
  4. register views with regions and any additional types with the IoC container in the Initialize method of the module
  5. create view classes - WPF controls that have nothing except the graphical layout. Any value displayed, any command bound, any color and any style are bound to the default DataContext. The views will receive a view model class as a constructor parameter which they will set as their DataContext
  6. create the view model classes - they also can have any types in the contructor as long as they are registered with the IoC container, stuff like the eventAggregator or a data service or other class that provides the data in the view model.
  7. provide all the information needed in the view as public properties in the view model so that they can be bound
  8. subscribe or publish events with the event aggregator


As you can see, most of the work is done by the modules, as it should be. They are both communicating and displaying data using the event aggregator and the binding mechanisms of WPF. There are some differences between how WPF and Silverlight approach some issues. The Prism library brings some classes to complement the subset of functionality in Silverlight that are not needed in WPF. However, one can still use those for WPF applications, making a transition from WPF to Silverlight or a mixed project more easily maintained.

The video walkthrough (as well as my own text summary) are based on the rather new Model-View-ViewModel pattern, which many people call a flavour of MVC. It was created specifically for WPF/Silverlight in order to separate behaviour from user interface.

Expect more on this as soon as I unravel it myself.

and has 0 comments

A while ago I was writing about the novel Infected, a sci-fi thriller written by Scott Sigler. In it, an automated alien probe was using biological reconstruction to create a portal for unspeakable (and not described) evil that awaited on the other side. Alien probes being as they are, the operation failed, but not permanently, since the probe remained undiscovered and ready to plan more mayhem.

Enter Contagious, Sigler's latest book, also freely available in weekly installments on his personal blog in both MP3 and PDF versions. Is the guy too nice or what? Today the final episode was released and I can finally comment on the book.

It is clearly a better book than Infected. Not by too much, but definitely more intense. It's like Aliens to the Alien film, only for Infected :) The probe is logically doing all kind of stupid stuff, including duplicating part of his functionality in the brain of a little girl. I mean, we humans have enough trouble as it is with girls, be them small or grown up, albeit the alien probe had no idea I suppose. The US centric approach was kept, there are more explosions, lots of killing, contagious yet centralised alien organisms... in other words, a decent sequel. The only thing I couldn't really get is the father-son relationship between Perry and Dew. Couldn't believe that for a moment, although it may be my fault.

All in all I read all chapters with pleasure, anxiously waiting for the next episode. It would make a nice manga :) I can only thank mr. Sigler for allowing me to read his book without feeling like a thief getting it through a file sharing service.

So, is humanity doomed in this one? Well, yeah... I mean, we still have girls... and besides, I can't possible spoil the ending now, can I? Rest assured that there will be a third book and our favourite aliens may still get rid of the human infestation and bring the love of God on our planet. Hmm, why did I say that? My tongue feels funny, too.

This is only a bookmark. If you want to know how to do this, read this link from Microsoft: Walkthrough: Using ASP.NET Routing in a Web Forms Application.

Well, you might laugh out loud when you read this, but it is an achievement for me. I wanted to update a table (table A) which had a connection to another table (table B) through a many to many table (table A2B). I had changed A2B to link A to a new table C. I wanted to reflect that change in my Entity Model.

So the first step was to right click on the model and do an "Update Model from Database". Then went through all the steps and clicked Finish. Now entity A has both a collection of Bs and a collection of Cs. I wanted to delete the B collection but, to my chagrin, no delete option was available.

The epiphany came when I managed to select the graphical link from entity A to entity B. The link has the delete option! Which, I have to admit, does make sense. So whenever you want to remove an association between entities... well, select the association and delete it, not the entity properties.

and has 0 comments
I was trying to do something that is usually a drag: create a query with variable parameters. Something like Google search, where each query has a number of words and you want to search for each of them. How can one do this with Linq? More than that, Linq to Entities, which is pretty much making my life hell nowadays.

The idea would be to start with a IQueryable object and keep adding queries to it. This isn't so bad when you want to do an AND operation between your individual query strings.
var dc=new MyEntities();
var content=dc.Content;
foreach (var filter in filters) content=content.Where(c=>c.Text.Contains(s));


But what if you want to do an OR operation? Then you would want to be able to add stuff to the lambda inside a singe Where method. I won't get into the details, rather give you a link. I am not an expert on this myself, so it would be pointless. The more important thing is that you can do this a lot easier by using a library called LinqKit, which adds some very useful extension methods for Linq, enabling you to dynamically create queries, lambdas, etc.

There are other 'lighter' versions of this method on the Internet, unfortunately most of them are usable only with Linq to SQL, not the Entity Framework. For example I've read an interesting blog entry about this, tried the code, and got an ugly error: "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities". LinqKit also did this in its earlier versions, but the Albahari brothers fixed it. So, as far as I can see, I recommend this library for real life linq composition.

Update: after a ton of searching, I found people that had the same problem as I did. It seems the culprit was Google Friends Connect. So sorry if you cannot "Follow me" anymore, I just removed the offending widget. Now the chat and the feedjit list and the shareit button work on IE8 as well. Maybe I can fix it somehow, but until then...

Today, out of the blue, without me changing anything in the blog or making any update, I started to get a lot of weird browser errors when viewing the blog with Internet Explorer 8. Things like 'Could not complete the operation due to error 800a03e8' and 'Unable to modify the parent container element before the child element is closed (KB927917)'.

Due to this (as yet unexplained issue) I have disabled the "share it" button on each post and the Jabbify and Feedjit widgets for anything that implements document.documentMode (i.e. Internet Explorer 8). I am sorry for the inconvenience. I will try to solve the issue, somehow.

I have determined that these weird errors are caused by trying to inject through javascript elements in the page before the page has finished loading. I have tried to delay the loading of these scripts until the page has rendered completely, but since they are external js files from various third parties, I have been unsuccesful. I will contact the various parties maybe they can change their js code, although I am not hopeful.

and has 2 comments
I haven't watched too many movies recently because I've mostly switched to TV series. They're more comfortable as they last under one hour, I don't have to waste a lot of time negotiating with my wife which film to see and they're regular. Bottom line, they're like soap operas for old people. And I am, inevitably, getting old. There should be a whole blog post about that, though, so back to the subject at hand: the list of TV series I have been watching.

This is a bit depressing, almost everything I have been watching is either at the end of the season or the end of the series. The economic crisis and everything, I suppose, or maybe people have finally started to move off TVs and switch to computers, as I have, and the income for any TV production has decreased dramatically.

So Stargate, both SG1 and Atlantis, has finally ended. A new Stargate Universe series in on the way, something a little darker, so something like the Deep Space Nine of the Stargate franchise. That should probably be the best series, and yet I predict the worse TV ratings. And that's because people are morons. Not to mention that at least a quarter of the original Stargate fans (those that weren't in the gun battles) were watching the series because of the green scenery on alien worlds.

Battlestar Galactica 2003. A brilliant reinvention of the old BSG concept, with a fantastic first season, faltering second season and abysmal third and forth seasons. This series has ended as well, and in the worse possible way: "God did it!". There is a spin off prequel, though, called Caprica. The pilot was released already and it was decent enough, although the religious crap is there from the very beginning.

Doctor Who 2005. Another remake of an old classic. Weird and ... weird. I can't stop watching it, but I also can't say why I do. It's a sci-fi, supposedly, and it's British :). Not to mention Christopher Eccleston played as the doctor for the first season, accompanied by beautiful Billie Piper as the female sidekick. This series has not ended, but it is on hiatus, one that will only end next year :(

And since I mentioned sexy Billie Piper, here is a non sci-fi series for you: Secret Diary of a Call Girl, where she is a call girl. Based on a book written by the infamous Belle de Jour, it is funny, honest and not so full of bullshit. And it's British :) Ok, enough with the British smiley, but you have to admit, being the second class citizen as TV series are concerned makes room for a lot of ingenuity and originality. The series has two seasons already and a third on the way, after Billie recovers from her pregnancy.

Eureka. Another sci-fi I am watching only because it is sci-fi. A wonderful concept, where a small village is actually a think tank of all the most brilliant scientists America has to offer. Of course, this would have been a fantastic show if made by the Russians. But being as it is, it is mostly a comedy, with the science put there only as comic prop. The say a fourth season is planned for mid 2009, but with TV series dropping like flies, who know.

Regenesis. Canadian show. Had 5 seasons then it died. Interesting topic, about an international team tasked to prevent and fight off disease outbreaks. It was pretty nice in the beginning, then it went all sci-fi and then it just collapsed. Think of it as 'Doctor House works at the CDC'. Too bad they had to abandon all pretense of reality. As we can see, disease outbreaks are as real and present as they can be these days.

And speaking of House MD, I am watching it, too. Only this time it's all because of inertia. My wife likes it, and I prefer it to romantic comedies. With the fifth season ending with House being taken to a psychiatric hospital, who knows if there will even be a sixth season. The medicine was gone from the show a long time ago, anyway.

Jericho. The US is nuked. And not just once, but a nuke in every major city. What will the average small town American do in a time of chaos and lawlessness? Great concept and a great first half season. Then it all went south. It was still decent, although infected with the Lost bug, when they cancelled the show. Fans were outraged, media companies did not care. As usual. And they wonder why they are losing money and audience like the Titanic took on water.

Numb3rs. Started great and it is still decent at the end of the fifth season. I will continue to watch it, even if the math has gone from it and it basically is now a police procedural series. What I do like about it is that the dynamic of the characters is very well designed. People really are people in the show, not just cardboard characters. It could turn out to be a show about nothing, and I would still watch it. Good job, Scott brothers!

Lost. This is a show I hate with all my heart. I am not watching it, my wife is, enough said it starts with some people crashing on a deserted island and now people die and get resurrected from episode to episode. J. J. Abrams, I hope you die a quick death and roast in hell forever! This horrible thing has reached the end of the fifth season and people still want more, so it will probably get to season six. Meanwhile, all shows have begun having pseudo mystical crap mixed in with simple scenarios and having big booming sounds whenever some crisis of absolutely no magnitude is born. Lost has invented the sound effects for dramas just as some show invented laugh-over for comedies.

Grey's Anatomy. Beautiful looking doctors that are always in some crisis or another, all of them emotional, while trying to avoid showing anything about actual medicine. Wife watches it, I stay away. Season five just ended and the show is going strong.

Private Practice. A Grey's Anatomy spin-off!! Second season just ended.

Ugly Betty. After three seasons of tortuous mental ineptitude, even my wife can't watch that crap anymore. That doesn't mean it is not high in the ratings.

Prison Break. I actually watched the first season and I thought it was nice. I could barely watch the second season and somewhere in the middle I just stopped. It's a show about absolutely nothing. Fourth season just ended (or is about to).

Criminal Minds. This is a police procedural about a crime unit tasked to profile serial killers and find them. It shows at least in principle how the mind of the killer works and it is not solely focused on the law enforcement agency. Most episodes are just watchable, but some are really nice and make everything worthwhile. The last good episode was about a guy killing people in red cars because his wife was killed in an accident involving a red car. By the end of the series we find out that the killer was driving the red car at the time and he suppressed the memory.

Terminator - The Sarah Connor Chronicles. The Terminator has evolved from hunky Schwarzie to liquid Robert Patrick to manipulative bitch Kristanna Loken to teenage girl Summer Glau. Lucky for us, the new Terminator Salvation movie is not about a child Terminator. Or is it not? Actually, this Terminator series was quite decent. Not good, but definitely watchable. So guess what? Low ratings! The show was cancelled after only two seasons.

Southpark. This animated parody series was brilliant when it started and it is still brilliant after 13 seasons. Usually an episode is a parody to a movie or a real life situation, all involving 4Th grade school children in a backwater town called Southpark. Sometimes they get to use too much toilet humour, but more often than not, the Southpark episodes are great.

Dexter. Oh, this is a show that I just love. Psychopathic killer Dexter Morgan is a Miami police crime scene technician and his policeman father, recognizing his mental persuasion, has taught him "the code" or "how to kill only serial killers and not get caught". Based on a book that I found worse than the show, the show has reached season 3 and I can't wait for the fourth season to start.

Big Love. This is a strange one. It is a series detailing the life of a Mormon family, one guy, three wives. As this marital arrangement is both illegal and controversial (since one major religion embraces it) there are all kinds of interesting developments. I for one think it is a very brave thing to do to make a show like this and Tom Hanks is one of the executive producers! The third season just ended, but I think the quality of the show is starting to go down as it turns more and more to cheap and unrealistic drama.

Fringe. J.J.Abrams again. He takes X-Files, adds a mystical twinge to it and the infinite puzzle of starting story arches and taking them nowhere and he creates Fringe. I am not watching it anymore, but for the episodes I did watch at least half the credit is due to John Noble, interpreting Dr. Walter Bishop.

Eli Stone. This was crappy to begin with. And it ended in a shameful cancellation after only two seasons. Imagine a lawyer that is also a psychic. Actually, he is a prophet of God. Geez!

Heroes. "Oh, you have to watch Heroes, it is so cool!". After my initial fear of starting to watch something about super heroes, again!, I got convinced by all the people telling me to watch it. Unfortunately, that only has proven I keep stupid company. The show is not only bad, it is beyond stupid. Third season has ended, the fourth is on its way.

Legend of the Seeker. Well, when I heard the people that made Xena and Hercules were doing another show I thought I would never enjoy it. But I do. It is still rather idiotic, but at least it doesn't turn battles into comedy scenes. People really do die, even if in the most clean ways. What a good horror series this would have been. The first season is close to its end and I suppose it will have a second season at least.

True Blood. I had to see it to believe it. Vampires in a small American town in which everybody actually behaves like in a small isolated town: they are superstitious, bigot, stupid, sneaky, mean. The story is a bit weird, but I allow it :) Second season is set to start on the 14Th of July.

Californication. Oh, oh, oh! David Duchovny has just become my personal idol. His character is a writer, intelligent, middle aged and totally cool. A bit too sexually active, but that plays well into the cool description. This is just one of those shows I can't not love. I can barely wait for the third season, sometime in late 2009.

Breaking Bad. I can't really relate to the main character, but the show is sound. A chemistry teacher finds out that he has terminal cancer. In an attempt to make a lot of money quickly in order to leave his family with a decent life, he starts cooking methamphetamine and selling it with the help of a local pothead. It is a show both funny and scary. His family doesn't know a thing, which adds to the tension. Not as good as Dexter, but pretty close. Can barely wait for the third season to start.

I am also starting to watch Entourage. Mark Wahlberg is playing a young actor "making it" in Hollywood. At least this is what I have read about it. It already has 5 seasons and I wonder if there is going to be a sixth. But I have still to start watching it and telling you what I think.

And at the end, last but not least, the anime series: Naruto Shippuuden and Bleach. I only started watching Bleach because of a friend liked it. I think it is barely watchable. I do read the manga, though, and that has gone way further than the anime. Surprisingly enough, though, the anime has some mini story aches that are not found in the manga. Licencing issues? Of Naruto I have already spoken of. I think it is pretty nice, although only at an emotional level. The manga is also way ahead and both manga and anime have story arches the other doesn't have. Both these series are shounen, meaning the type of story where the male character goes through increasingly difficult challenges which he overcomes, mostly through strenght of will and not something real like lots of work and exercise :) They still feel good, though, to immature males such as myself.


And that was it. Hopefully you will forgive me for not providing links. Just google it! :)

and has 4 comments
I was installing a Visual Studio project made by a very cool team and, as they are very cool, it had this very complex folder structure for every little class and test and long names on the folder and so on and so on. Therefore, when trying to create a file on my Windows XP computer, the installer of the project failed with the strange error: 'the file name you specified is not valid or too long'.

I was under the impression that the path was no longer limited to 255 characters in Windows XP, but I was wrong. The MAX_PATH constant in Windows XP is 260. Everything over that causes an error unless specifically using a UNC formatted path (starting with \\?\). Weird huh?

Here is a technical description of the path concept in Windows: File Names, Paths, and Namespaces.
And here is the KB article with the "solutions": You cannot delete a file or a folder on an NTFS file system volume.

The scenario is this: You use a ScriptManager, a TextBox and a Button and your project is at least referencing the Ajax Control Tookit library. You expect when pressing Enter in the TextBox to get to the button Click event. Instead you get the Microsoft JScript runtime error: ‘this._postBackSettings.async’ is null or not an object javascript error.

I found the solution here: JScript Exception in AJAX Control Toolkit. Basically, put the textbox and the button in a Panel and set the DefaultButton property to the button id.

Today a new AjaxControlToolkit was released. I had hoped that at least they noticed the patch I made the effort of sending them, the one that fixed the dynamic TabPanel issue. But no. Three more controls and probably most of the same old bugs.

Here are more details: New release of the Ajax Control Toolkit

and has 0 comments
I don't pretend to know much about mathematics, but that should make it really easy to follow this article, because if I understood it, then so should you. I was watching this four episode show called Story of Maths. Its first episode was pretty nice and I started watching the second. The guy presented what he called the Chinese Remainder Theorem, something that was created and solved centuries before Europeans even knew what math was. It's a modular arithmetic problem. Anyway, here is the problem:

A woman selling eggs at the market has a number of eggs, but doesn't know exactly how many. All she knows is that if she arranges the eggs in rows of 3 eggs, she is left with one egg on the last row, if she uses rows of 5, she is left with 2 eggs, while if she uses rows of 7, 3 eggs are left on the last row. What is the (minimum) number of eggs that she can have?
You might want to try to solve it yourself before readind the following.

Here is how you solve it:

Let's call the number of eggs X. We know that X 1(mod 3) 2(mod 5) 3(mod 7). That means that there are three integer numbers a, b and c so that X = 3a+1 = 5b+2 = 7c+3.

3a = 5b+1 from the first two equalitites.
We switch to modular notation again: 3a 1(mod 5). Now we need to know what a is modulo 5 and we do this by looking at a division table or by finding the lowest number that satisfies the equation 3a = 5b+1 and that is 2. 3*2 = 5*1+1.

So 3a 1(mod 5) => a 2(mod 5).

Therefore there is an integer number m so that a = 5m+2 and 3a+1 = 7c+3. We do a substitution and we get 15m+7 = 7c+3.

In modular that means 15m+7 3(mod 7) or (7*2)m+7+m 3(mod 7). So m 3(mod 7) so there is an integer n that satisfies this equation: m = 7n+3. Therefore X = 15m+7 = 15(7n+3)+7 = 105n+52

And that gives us the solution: X 52(mod 105). The smallest number of eggs the woman had was 52. I have to wonder how the Chinese actually performed this calculation.

Let me summarize:
X 1(mod 3) 2(mod 5) 3(mod 7) =>
X = 3a+1 = 5b+2 = 7c+3 =>
3a 1(mod 5) =>
a 2(mod 5)=>
a = 5m+2 =>
X = 15m+7 = 7c+3 =>
15m+7 3(mod 7) =>
m 3(mod 7) =>
m = 7n+3 =>
X = 15(7n+3)+7 = 105n+52 =>
X 52(mod 105)
.

For me, what seemed the most hard to understand issue was how does 3a 1(mod 5) turn into a 2(mod 5). But we are in modulo 5 country here, so if 3a equals 1(mod 5), then it also equals 6(mod 5) and 11 and 16 and 21 and so on. And if 3a equals 6(mod 5), then a is 2(mod 5). If 3a equals 21(mod 5), then a equals 7(mod 5) which is 2(mod 5) all over again.