I am a pebble!

My life is that of a pebble – The pebble dances to the tune of the waves. It cannot do otherwise. With every movement, it rubs against hard surfaces and loses part of itself. As the river continues to flow, the pebble becomes smooth. Throw it at someone and it will hurt but hold it delicately in your hands and you can feel its gentleness. Nature wants the pebble to stay immersed in the river so it doesn’t harm and looks beautiful from the outside. And that’s where I belong, out of reach.

~AS

C# Interview Questions Based on Actual Experiences When I Was Looking for a Job

This is the process I went through whilst looking for a new Senior Developer position in London. I hope this helps other job seekers better prepare themselves.

Company A

1st Stage – Telephone Interview (30 mins)
General chat with the director about what the company does and where it’s headed. Looking to see I thought I would be a good fit.

2nd Stage – Practical Test (3-4hrs)
Create a basic web application using web forms, linq to sql and jquery ui. This assignment was sent by email and could be completed at home, so no time limit really. The project requirements was to create a page with a text field (Name of company) and 3 dropdowns (Speciality, Category and Location). When users type a name in the textbox, jquery autocomplete should be leveraged to suggest names of companies already in the database. Results should be displayed filtered by all 4 fields if specified. A sample data in spreadsheet format was sent but it was not normalised and a either a backup of the database or script to recreate it was asked.

Here the employer is looking for good coding skills and a layered project solution (Web, Data and Business layers).

Third Stage – Face to Face Interview (1hr30)
This was done at their office in Chiswick. I met the IT Director who asked a couple of questions about the things I’ve put on my CV and what I thought about the project I had to do, then was questioned by a Senior Dev about these:

1. Whether I’ve created a jQuery plugin before (and how)
2. My experience with Unit Testing
3. A couple of other technical questions which didn’t require much thought

Then I met the CTO again for a brief talk and the most important question there was what I would bring to the company.

Result
I didn’t get the job. They said I had strong technical skills but didn’t show much interest in the company.

Company B

1st Stage – Technical Test (1hr23)
I was asked to do an IKM (International Knowledge Measurement) .NET WEB DEV test. To be considered for the role, you need to get 90% and above. IKM tests are multiple choice questions with 1 or more correct answers. You cannot skip a question and come back to it and for each wrong answer, you are penalised more than if you don’t answer it (this is to prevent guesses I think). There were 33 questions to be answered in 83 minutes and before the test, it mentioned that on average people take 39 minutes to complete this.

Some of the questions which were asked are:

1. Which attribute flag to use for bitwise operator (i didn’t know, never used it in my life!)
2. try catch block code segments, which were correct
3. MVC routing
4. Code segments containing interfaces and classes, find out the output
5. Custom exceptions in .net

Although I scored 86%, the company still wanted to see me.

2nd Stage – Technical Interview with Technical Architect and Product Manager (1hr30)
I was asked 2 main technical questions – my understanding of SOLID principles and how I would go about designing a system. The requirements were that a short blog post (140 characters) will be submitted by multiple registered users of the company and this had to be displayed back to on the front end bearing in mind this is a high traffic website.

What was important here is to mention that the first time the page is requested, it will be cached until another post is submitted by someone else. Then on the front end, to use something like SignalR or another polling method to update the post widget with the latest items.

Result
I didn’t get this one either because they didn’t think I would be a good fit for their company and I didn’t know much about their products and services. They said I had strong technical skills though.

Company C

1st Stage – Telephone Interview (30 mins)
Basic introduction to the company and lots of technical questions as follows:

1. Choose two programming languages and talk about the differences – they wanted a client side scripting language like JavaScript and server side language like C#
2. What does .net code get compile to and what is used at runtime (code gets compiled to MSIL and at runtime it’s machine language)
3. What is a transaction in database terms? (going from one consistent state to another)
4. Properties of database transactions (ACID properties)

2nd Stage – Face to Face Technical Interview (1hr)
This was meant to be 1hr but lasted for 3hrs!!! There was a 15 mins presentation of the company, what it does etc. Then oral questions:

1. Explain the Garbage Collector (you should talk about Generation 0/1/2 and that it is non-deterministic)
2. What is IDisposable and what pattern uses this (when using the “using” keyword)
3. What is multi-threading
4. How to avoid a deadlock
5. Difference between the out and ref parameters when passing a value/reference type

Then technical exercises:

1. A program was written on paper that does string manipulation (tokenisation) and you had to tell the output. It was using indexOf and SubString but since there was a do-while loop, you had to calculate values of all local variables on paper. It turned out the interviewer had an initial string of “This is Value1” and you were looking for the word “is” and you would miss out that the first occurrence of “is” would be in “This”.
2. Following on the previous exercise, I was asked how I was going to rewrite the program by using recursive calls to the method and I was only allowed to modify certain sections of the code, not everything.
3. On paper, a set of tables was shown and I was asked how to make it better (had to normalise them)
4. A database schema was shown and i was asked to write SQL queries for inner joins, left joins, group by on paper.
5. There was also a Psychometric test (aptitude) where I was given increasing levels of difficulty to solving a certain mechanism they use for their product.

This was followed by a chat with one of the managers, whereby he wanted me to talk more about the technical stuff I’ve done in my previous jobs (technology used, why and how) and then questions about why I wanted to join their company.

Result
This was one of the hardest interviews I’ve had and I thought it was going to be just 1hr, not 3hrs!!! It was absolute torture and I wanted to just leave in the middle of the interview but I gave it my best shot anyway. I know I didn’t do well but if the interview was that hard, I don’t think I want to work there and have my stress levels jump through the roof everyday. I also have a life outside work and I’d rather take a pay cut than become a zombie. I was later informed I didn’t get the job.

Good luck if you’re seeking a new opportunity!

UPDATE

I had two other interviews after those and got job offers for both. I took up one of them and I’m very happy with the salary and the job I’m doing ūüôā

That’s it – I’ve gone vegetarian now!

I woke up yesterday (26 December 2014) and I felt it was high time I stopped eating meat. I’ve wanted to do this since a long time but there were 2 reasons which¬†prevented me from doing it.

First, it was more convenient – if I’m hungry, I can just make a chicken burger and have that with bread and I’m all sorted. If I’m out and about, I can always get a Zinger burger at KFC. If I wanted to cook a nice meal, you can’t go wrong with chicken which is what I’m used to anyway.

Secondly, I want to put on some more muscle mass and meat is an easy source of protein which is crucial in bodybuilding. I was scared I wouldn’t be able to bulk up if I stop eating meat but the truth is I wasn’t gaining lean muscle mass anyway because I don’t train as hard as I need to (I hardly exercise btw :D).

I guess when I woke up, I thought enough was enough and I could go on procrastinating about this and never get it done. It is boxing day and the Christmas and 2015 New Year celebrations are still intense and in my mind, I’m thinking maybe I should wait till January and have this as a New Year Resolution instead. However I know deep down it’s an excuse and if I put it off for another day, then I’ll never be able to do it.

I just bought 36 chicken burgers, chicken sausages and still have some chicken breasts in the fridge and tuna cans in the cupboard and I’m thinking I should probably get through these first otherwise it’s going to waste. But then I know myself too well now and decided to just go with the flow, so let’s see what happens next.

Using Jabbr chat with MySql database

I wanted to integrate a .net chat application for my Mauritius Chat project and came across Jabbr which has most if not all of the features I wanted. However it works with SQL Server Express by default but I wanted to use MySql instead. The reason for that is that I’ve got a dedicated where I’m running MySql because it’s free compared to SQL Server 2008/2012 and I didn’t want another service for SQL Server Express to run just for one application – I have to use the limited RAM carefully. So this post is all about how I finally managed to do that.

First thing first – you have to download the source code from Jabbr repository on Github, There’s a Download Zip button on the left hand side.

Next you’ll need to download the MySql .Net Connector 6.9.3¬†and install it. If you have previous versions of the MySql .Net connector, like I did, you’ll have to uninstall that first.

These are the changes you’ll need in your web.config file:

Connection String


<connectionStrings>
<add name="Jabbr" providerName="MySql.Data.MySqlClient" connectionString="Database=Jabbr;Port=3203;Data Source=localhost;User Id=YourUserName;Password=YourPassword;"/>
</connectionStrings>

Entity Framework


<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>

You will also need to reference the MySql.Data.Entity.EF6.dll in your project. You will find that where the MySql .Net Connector has been installed and you will have to choose the assembly according to the .net version you’re using, in my case .net 4.5.

Problems I encountered

When you recompile the project, you’d think it will work but for me it didn’t because it kept complaining about this error:

Schema specified is not valid. Errors:
(15,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘When’ in type ‘JabbR.Models.Attachment’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘When’ in type ‘CodeFirstDatabaseSchema.Attachment’.
(40,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=True,DefaultValue=,Precision=]’ of member ‘RequestPasswordResetValidThrough’ in type ‘JabbR.Models.ChatUser’ is not compatible with ‘MySql.timestamp[Nullable=True,DefaultValue=,Precision=0]’ of member ‘RequestPasswordResetValidThrough’ in type ‘CodeFirstDatabaseSchema.ChatUser’.
(66,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘When’ in type ‘JabbR.Models.ChatMessage’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘When’ in type ‘CodeFirstDatabaseSchema.ChatMessage’.
(95,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘LastActivity’ in type ‘JabbR.Models.ChatClient’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘LastActivity’ in type ‘CodeFirstDatabaseSchema.ChatClient’.
(96,12) : error 2019: Member Mapping specified is not valid. The type ‘Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]’ of member ‘LastClientActivity’ in type ‘JabbR.Models.ChatClient’ is not compatible with ‘MySql.timestamp[Nullable=False,DefaultValue=,Precision=0]’ of member ‘LastClientActivity’ in type ‘CodeFirstDatabaseSchema.ChatClient’.

Basically in the Jabbr code, some of the properties (especially for DateTime) are marked as DateTimeOffset which is stores the date/time as an offset of UTC, rather than the server date/time. However the DateTimeOffset type was being mapped to datetime in MySql and Entity Framework realised it was not a proper mapping. I tried to check for solutions online but couldn’t find any and since this was not a big deal for me (storing the date/time as UTC), I ended up replacing the properties marked as DateTimeOffset as DateTime. When you do this, you also have to modify some parts of the code where it uses DateTimeOffset.UtcNow with just DateTime.Now. I’ve used replace/find and there are less than 5 occurrences if I remember correctly.

Okay at this point, the application compiles¬†but when browsing the site, the application tells me that there’s not database/matching tables yet so I would need to use the Package Manager Console and run the command Update-Database. When I did that, it failed at one specific migration. So I tried to see what was happening by issuing a Update-Database -verbose command and I noticed MySql was complaining about a variable was not declared. That specific migration to was to rename a column from Proivder to Provider, something like that. So I thought I could just exclude that particular migration and do the rename manually but the migration still failed at another point.

I therefore decided to delete the whole Migrations folder so that the schema is created from what’s in the code without having to run it any migrations (this is only good if you’re just setting up the website and you don’t have any data yet). I had to comment out the Migration calls in Startup.cs and run the following command in Package Manager Console: Update-Database

I also issued Enable-Migrations so that if I make any changes, then these are tracked.

In the end, I was able to run Jabbr chat with a MySql database. Now I need to create a custom membership provider so that logins details are checked against the Users table which resides in another project, so I might need to create an API for that.

Setting Git on external hard drive or USB flash in Windows

At home, I usually work on personal projects and I wanted an easy way to back up my data and put my code under source control. I decided to go with Git for this and use my 250Gb external hard drive for the remote repository (you can use a USB flash drive as well if you want).

So the first thing to do is download Git Extensions and install the software. I installed mine on the C drive in Windows 7 using the default settings.

The next thing was to let Git know where my local repo for my project is. So I browsed to the folder where my project was located (the directory which contains all the C# source files from Visual Studio) and right click. This gives you the option for “Git Init here” which when chosen creates .git directory marking this folder as your local working directory. Open your Git Extensions program and do a commit to get your codes under source control (locally).

Once that is done, you’ll need to create a remote repository on your external hard drive or USB stick. Just create a folder there eg H:\Git\MyProject and when you right click in the folder, you will be able to click on the “Git Bash” option which will open a command line tool. Type the following command in there:

git init –bare

This will create a bare repository in the current directory.

Go back to¬†Git Extensions and do a push now. It will ask you where to push to and you just need to enter the location of the¬†remote repo you’ve just created and voila, all done.

Notes

Although I was able to set up the local repo using Git Extensions, I was not able to do the same for the remote repo, hence I’ve used the command line in Git Bash.

The local repo contains all your source code (it’s a working copy after all) but the remote one has only git files. My local repo was 8Mb while the remote one was only 0.5Mb so I was worried it was not a proper backup of my data. However that was not the case – I tried to get another working copy from the remote repo just to make sure that if my computer crashed, I would still be able to get all my source codes from the external drive and that worked perfectly. Actually it’s better because the size of the remote repo backup was way less than the working copy.

Tere Dard Se Dil Aabaad Raha English Translation

This is a lovely song from the movie Deewana starring Divya Bharti, Shah Rukh Khan and Rishi Kapoor.

Lyrics

Tere dard se dil aabaad raha
From your pain, my heart was prosperous/affluent
Kuch bhool gaye, Kuch yaad raha
I forgot some, remembered some
Naseeba bhi kya rang laya
Faith/luck too, has brought its different colours
Kaha laake hum ko milaya
Where has it brought us to meet
Apni wafaa ke gul khil na paaye
The flowers of our trust did not flourish
Milke bhi tujhse hum mil na paye
Even after meeting you, we didn’t really meet
Darde dil hum kaise sahen
How can I stand this heartache
Door bhi hum kaise rahen
How can I stay far away too
Tera gham tere jaane ke baad raha
Your sorrow was there after you left
Kuch bhool gaye, kuch yaad raha
I forgot some, remembered some
Jaane wafa tujhko kya de
My life, my faith, what can I give you
Dil Keh raha hai dua de
Heart tells me to give blessings
Armaan bujhe hain sapne duaan sa
Desires are extinguished, dreams are broken
Mar mar ke hum to zinda yaha hai
I am still here alive after dying over and over
Bekhudi main hum ko gaye
I had lost all conscious/senses
Phir juda tujhse ho gaye
Then I was separated from you
Chahat ka jahaan barbaad raha
The universe of love was destroyed
Kuch bhool gaye, kuch yaad raha
I forgot some, remembered some

Conversation of my Mind to my Heart

Mind : I know you’re hurting badly but that’s affecting me a lot now and I cannot function properly

Heart : I’m sorry but I can’t help myself

Mind : For our sake, forget her and move on

Heart : I’ve tried to but it’s out of my control

Mind : Just do what it takes to stop this madness

Heart : Alright, I’ll have to stop beating then

Mind : No, you know I cannot exist without you

Heart : …and I cannot live without her

Mind : We’re both screwed then!
.
.
.
Soul : Don’t worry guys, when the two of you are long gone, I’ll use the memories of the Mind to cherish the love of the Heart and immortalise your existence¬†

EPiServer Dynamic Content not Rendering on page

After spending like 4hrs trying to find out why a dynamic property was not being loaded properly on a webpage, I finally stumbled upon a website with such an easy solution. Basically we had a custom dynamic property which was supposed to output some data but EPiServer was not rendering the control properly.

In the source code, I expected to find :

<a style=”” href=”/Video/Vimeo/60255727/” class=”trigger-video” data-trackingid=”&lt;a href=”><span></span>
<img src=”/Global/PersonalCover-Screengrab.jpg” alt=”Personal cover” />
</a>

…but here’s what I saw instead:

<div data-classid=”b30218a7-77fc-43dd-a844-81935aa9b35e” data-dynamicclass=”Video Plugin” data-state=”VgBpAGQAZQBvAEkAZAA=&amp;NgAwADIANQA1ADcAMgA3AA==|VAByAGEAYwBrAGkAbgBnAEkAZAA=&amp;PABhACAAaAByAGUAZgA9ACIAIgAgAG8AbgBjAGwAaQBjAGsAPQAiAF8AZwBhAHEALgBwAHUAcwBoACgAWwAnAF8AdAByAGEAYwBrAEUAdgBlAG4AdAAnACwAIAAnAFYAaQBkAGUAbwAnACwAIAAnAFAAbABhAHkAJwAsACAAJwBQAGUAcgBzAG8AbgBhAGwAQwBvAHYAZQByACcAXQApADsAIgA+AFYAaQBkAGUAbwAgAGwAaQBuAGsAIABoAGUAcgBlADwALwBhAD4A|SQBtAGEAZwBlAFUAcgBsAA==&amp;LwBHAGwAbwBiAGEAbAAvAFAAZQByAHMAbwBuAGEAbABDAG8AdgBlAHIALQBTAGMAcgBlAGUAbgBnAHIAYQBiAC4AagBwAGcA|SQBtAGEAZwBlAEEAbAB0AA==&amp;UABlAHIAcwBvAG4AYQBsACAAYwBvAHYAZQByAA==|QQBsAGkAZwBuAFIAaQBnAGgAdAA=&amp;” data-hash=”jpJE7dVU4KCYCarsF+2bNaNENaNdJwG1niTwbyZc7CY=” contentEditable=”false” class=”epi_dc”><div class=”epi_dc_h”><div class=”epi_dc_l”><div class=”epi_dc_title”>Video Plugin</div></div><div class=”epi_dc_t”><a href=”#” class=”epi_dc_editBtn”>.</a><a href=”#” class=”epi_dc_previewBtn”>.</a></div></div></div>

EPiServer was not rendering the control properly but was just outputting the string.

The fix is really easy. All I had to do was change the way the dynamic content is being output in code.

So instead of this:

<%= CurrentPage.MyDynamicContent %> // wrong

I used this:

<EPiServer:Property runat=”server” PropertyName=”MyDynamicContent” />

Note that this is the way to render dynamic content in EPiServer but there’s a way you can force the literal output as well to work.

Going to the gym after 10 years!!!

Honestly, you shouldn’t wait that long but for me it must have been more than 10 years since I last did any kind of exercise. I was quite active before but since I’ve come to the UK, the cold weather has made me a couch potato and it doesn’t help that I work in an office and sit all day long staring at the computer.

Anyway, I thought a decade was quite a long time and something needed to be done. I’m not getting any younger and I’ve started to feel my body is not as flexible and strong as before. So I signed up for a gym membership with Fitness First (1 month just in case, lol). Since it was a short term contract, it’s ¬£62 but if you go for 4 months contract then it’s ¬£52 and your yearly membership, it’s ¬£42. I’d rather pay a bit more expensive but have the option to cancel within 30 days as I’m still not sure of my commitment as I’ve got loads of things going on as well.

Few things I didn’t think ¬†about were joining fee for the club (¬£20, but they forgot to include that in my bill, yay!), appropriate clothing and footwear when exercising in the gym and parking which fortunately is not far from the club and members get 2hrs free. I’ve also been persuaded to take a personal trainer as well – 4 sessions for ¬£15 instead of ¬†¬£30, I just thought why not ūüėÄ

And on my first day in the gym, the personal trainer was talking to me about posture and correct way to do things which was all good up until he asked me to do 10 press ups. I could hardly manage 4! I still did 10 though but they were not press ups, after 5 they were more like trying to get your body up any way you can using your hand, lol.

We did some bench press as well with little weights, well he thought they were little but I thought he was trying to kill me, haha. Yes, I know, my body is used to laziness and intermittent smoking hasn’t done me any favours too. We got through some rowing, arm curl for bicep and tricep and finished with lunges. I thought he said lunch btw.

By the end of the session (about 1hr) which to me felt like an eternity, my arms and legs were aching. I was glad I survived and I’m sure I’m going to build up the resistance if I persist. I must admit, I always thought I was a handsome guy until I saw myself in a gym mirror which made me looked too skinny. But then again handsomeness is to do with the face, right?

Now I need to plan my diet better because training without proper nutrition is stupid. However I’m planning to become vegetarian as well, so I’m not sure how that’s going to work out.

Learning EPiServer and Extending Its Functionality

So I’ve recently joined this company and they use EPiServer as a base and build custom functionality on top of that. Therefore I was required to learn how the CMS works in order to fulfill my role as a .NET Web Developer.

The very first thing I needed to do was to get a dev version on my local machine. ¬†On Episerver’s website, I downloaded the version we used most in the company (EPiServer CMS 6 R2) and then I launched the installation process. The setup did not go smoothly as it got aborted because it could not create the database. My Windows credentials were not given the right permission on MS SQL Express 2012 (blame the System Administrator!). Anyway, once that got sorted, I installed the Alloy Tech sample website from EPiServer Deployment Centre. However that was just a blank project with just core files, contrary to what I was expected to see. The thing is I was following a tutorial from a blog and it had screenshots of what the website was supposed to look like but the end result for me was completely different. Later I found out the blog was outdated.

Next it was time getting used to Page Types, something that the CMS uses a lot. Once you get an understanding of that, everything else starts to make more sense. Then comes the querying of the CMS, for example, search for a a list of specific page type starting from the homepage. You can achieve this by creating a criteria query or using PageTypeBuilder (PTB), the latter being more strongly typed. Note that PTB is an open source project which needs to be imported in the project before you can use its awesomeness.

So far so good but still a long way before mastering the CMS; the coding is the easy one ūüôā