.Net

Sharing the code between multiple exceptions

Today I had a situation where I wanted to do same opertation in case of different exceptions. I came up with something simple

Here is the situation:

try{
  // Exception throwing code
}catch(MongoConnectionException ex){
  // Some code here
}catch(IOException ex){
  // Some code here
}catch(SocketException ex){
  // Some code here
}

Now this looks already quite ugly. Not for you? Ok then its ugly for me ūüôā

So what I did some may consider it even more ugly but I can atleast share the code

I did it so that

try{
  // Exception throwing code
}catch(Exception ex){
  if(ex is MongoConnectionException || ex is IOException || ex is SocketConnection){
    // Do some specific logic or setting of state for these type of exceptions
}
  // Do some common logic here
}

If you find some problem in doing this please let me know so that I can fix my code as well ūüôā But this reduced my code.

Thanks

Ruby

“failed to create jvm: error code -4 ” Ruby Mine

I faced this issue today when starting RubyMine. And going thorugh Ruby Mine manuals https://www.jetbrains.com/ruby/help/tuning-rubymine.html I figured it out how to fix this.

Right click on you Ruby Mine shortcut icon and click on Open File location just to reach to the folder which contains the Ruby mine .exe

Now open rubymine.exe.vmoptions edit -Xmx to 512m

Now start ruby mine and the error should be gone and it should open fine.

Hope this helps.

Uncategorized

Porting to mighty WordPress

It’s an exciting day as I am moving to use the mighty WordPress for my blogging which also means its very sad as somehow I failed to maintain my own created blog.

But with the increase of responsibilities I have to let go something’s.

I am very happy to get into WordPress and the cooles apart from all the geeky stuffs they have to get the things done easily they also provide a very nice Windows phone app to add/update/delete posts of pages; which is awesome for the but obvious reason that I love windows phone.

Here some snapshot’s of it

wp_ss_20150615_0001 wp_ss_20150615_0002 wp_ss_20150615_0003 wp_ss_20150615_0004

But adding these snapshots were a pain through mobile but still its possible.

So far so good. Lets see how this works out.

.Net, Azure

Integrating SSL to Azure Websites

freessl

So after very very long I have finally got some time to share something. Today I will share how to integrate SSL with Azure Website; trust me it can be a bit of pain to get this working specially if you are quite new to this. So in this article I will explain it with all pictures; which I feel is the best way to explain or learn.

So to try this two things is a must.

  • You should have a registered domain. Do not use *.azurewebsites.net for registering SSL since almighty Microsoft provides the SSL support for azurewebsites.net domain. So if you are planning to use *azurewebsites.net then you do not need to have a seperate SSL certificate.
  • The SSL Provider we are going to use here i.e RapidSSL send a mail to the domain administrator mail id which is actually a set of email id’s which RapidSSL support. Here is the list of all supported email id’s (admin@yourdomain.com,administrator@yourdomain.com,
    hostmaster@yourdomain.com,webmaster@yourdomain.com,
    postmaster@yourdomain.com)

Ok Lets get started not.

First go to the URL www.freessl.com and click on TRY button to try with freessl or you are quite sure to buy it then just buy. I will use the free version which is valid for 1month.

Now on clicking on the TRY button you will get series of forms to be filled for which I have attached the screenshots.

freessl_pop1

freessl_pop2

freessl_csr

Now this is the point we need to generate the CSR (Certificate Signing Request). We can do it using IIS Manager or OpenSSL as well. But lets use IIS though we would openssl in later stage but for this purpose lets use IIS Manager.

So press start in windows OS and then type IIS; and you will get IIS Manager. If you do not find it then go to Control Panel -> Program Features -> Turn windows features on or off.

So if you find the IIS manager then you just follow these snapshots

iis_open_feature

iis_create_cert_dialog1

iis_create_cert_dialog2

iis_create_cert_dialog3

Now after you have save this file. Open this file in the Notepad and copy the content and paste it to the freessl website ; here

freessl_csr

Now after pressing the submit you follow these

freessl_continue1

freessl_continue2

freessl_continue_domain_approver

freessl_orderno

After this you should get a mail on the Domain email id you have selected after clicking the link provided on that you should get your CSR to the registered email address. And if you look at the end of the mail you will see the Web Server certificate. Copy that and save it as myserver.crt. Now right click on this file and press install certificate.

Now we need to generate the .pfx file which is needed to be uploaded to the azure. So lets do that.

First lets get the private key; which we get from teh CSR request we made

On the start serach mmc.exe then File -> Add/Remove SnapIn; select Certificates and then Local Computer.

Now go to folder level Personal -> Certificates and you should find the certificate www.whynotme.com.

Click on next and select yes then again next and select to PKCS #12. and then the location of the file and save it as file name privatekey.pfx

Now we need to generate a .pfx file which is password protected and accepted by Azure website. So lets use OpenSSL to generate this.

We need 3 files for this

  1. Private Key file
  2. Web Server Cert from RapidSSL
  3. Intermediate or Chain Cert as bundle which you can get it here and save it as Intermediate.pem

Now we have the private key as .pfx file but we need .key file to generate the final .pfx file. So lets extract the .key file from privatekey.pfx.

You can get the Open SSL installer from here. INstall it in C:\openssl drive with all its binaries. Open command prompt and type the following

set OPENSSL_CONF=c:\OpenSSL-Win64\bin\openssl.cfg

And to generate the .key file

C:\>.\OpenSSL-Win64\bin\openssl.exe pkcs12 -in privatekey.pfx -nocerts -out privatekey.pem

C:\>.\OpenSSL-Win64\bin\openssl.exe rsa -in privatekey.pem -out private.key

Now we have all the files lets generate the final .pfx file which should be uploded to Azure by just running the following command

C:\>.\OpenSSL-Win64\bin\openssl.exe pkcs12 -export -out whynotme_ssl.pfx -inkey private.key -in myserver.crt -certfile intermediate.pem

So the final file which should be uploaded is whynotme_ssl.pfx

Go to your azure website -> Configure; search for Upload Certificate.

ssluploadcert

ssluploaddlg

In the ssl bindings section of the CONFIGURE tab, use the dropdowns to select the domain name to secure with SSL, and the certificate to use. You may also select whether to use Server Name Indication (SNI) or IP based SSL.

sslbindings

  • IP based SSL associates a certificate with a domain name by mapping the dedicated public IP address of the server to the domain name. This requires each domain name (contoso.com, fabricam.com, etc.) associated with your service to have a dedicated IP address. This is the traditional method of associating SSL certificates with a web server.
  • SNI based SSL is an extension to SSL and¬†Transport Layer Security¬†(TLS) that allows multiple domains to share the same IP address, with separate security certificates for each domain. Most modern browsers (including Internet Explorer, Chrome, Firefox and Opera) support SNI, however older browsers may not support SNI. For more information on SNI, see the¬†Server Name Indication¬†article on Wikipedia

Click Save to save the changes and enable SSL.

Thats it. Now try https://yourdomain.com

Hope it works for you as it worked for me. Please leave a comment good or bad or improvements all are appreciated.

Reference : Enable HTTPS for an Azure web site

.Net

C# + REPL + Scripting -> Life is Good

cshell_logo

Alright this time I have again made my life a bit easy by finding a solution for problem where I want to test a library but I do not want to create .Net Solution using VS and then type class and all those. Since I want to just test the working of an API so I do not want to go soo long. Someone will say then use IronRuby and do it; but then we do not get Syntax Highlighting, Code completion, intellisense and etc. (productivity enhancing tools).

So I get this nice tool called¬†CSHELL; its a REPL for C# script (isn’t that cool).

So let me show you how I have experimented this tool by solving one of my simple issue.

Problem Description:

¬† ¬† ¬† ¬† ¬†¬†As you all know we in Platform team working on DB renewal stuff and we often need to check various different Databases and their functionality. This time I wanted to check Couchbase’s functionality on¬†How to get the list of buckets in a default pool. Terminologies may be confusing for some who does not understand about Couchbase but in simple term Bucket is a collection of JSON documents.

Steps:

1) Run cshell -> Download it from here. It is just an .exe so you can just run it. (Tips: Better to pin it up with the Taskbar for easy access);

2) You will see this main window.

CShell Main Window

3) Now I want to have the reference to Couchbase .Net SDK.

CShell Referencing DLL

4) Select the required ones

CShell Referencing DLL

5) Now I have written the statement in the script to check the problem which I described earlier. So here is the snapshot of it:

CShell Intellisense

You see I get the intellisense. isn’t that nice? And if you see a bit above that I was using a class without the reference (that too two time¬†(tongue)) and it gives me a colourful error . That’s neat.

CShell Linq Intellisense

Intellisense with LINQ as well. Nice!!

And finally I get the result which I want.

CShell Final Result

That’s it. It took me just 5 mins to do this. Time creating this blog post is not counted¬†

More info you can find in http://cshell.net/.

Please share if you find something useful as well or something which does not work. Its a good way to use C# as a scripting language. 

Thanks

Cloud technology

First ever Windows Azure Conference in India

WinAzure2

This post is all about my experience at India’s first ever Windows Azure conference. This event was on March 20th and 21st 2014 at Bangalore. This event was to showcase the power of mighty Windows Azure to Developers, IT Professionals, Business Decision Maker, and Service Providers.

Microsoft India has been excellent in conducting this event.

From the day I have heard about Windows Azure I have been soo fascinated with this technology, but I confess that I know only bits of it; this subject is huge by huge I mean really huge. It has soo many features and details hidden to it. BTW this small website of mine is also powered by Windows Azure.

Microsoft like to call Windows Azure as the Cloud OS. Well it is.

So my journey to this conference starts with the registration which I came accross on twitter, I did no long to get registered even I forgot to take permission about this to my boss. I was like I will attend this no matter what happens.

But I was lucky to have got the permission from my boss Jan Mattson to go for this event, even though I had a Sprint planning meeting on the same day.

wac_start

The event was divided into basically two main parts Develop and Deploy + Manage; I went for Develop module.
The event started with the key note by Mr. Bhaskar Pramanik, Chairman of Microsoft India. It was very very interesting to hear him. He showed soo very cool statisctics of Windows Azure. Here is the image of it:

azure_stats

Some interesting fact which mentioned were:
1. Over 1000 new customers sign up for Azure everyday.
2. 55% of the Fortune 500 use WIndows Azure.
3. Azure Revenue Growing 200% +

Wow that sounds very cool and promising.

Then there was the expected key not by the new CEO of Microsoft Mr. Satya Nadela.

satya_speech

He has been talking mostly about the future of Cloud and Mobile. So Microsoft is a cloud first company.

But after that comes the CIO of Fortis Hospital who speaks about their partnership with Azure. Yes Fortis uses Azure. Nice real case example of a big organization using Azure.

Then the events get started with Azure Website. They have shown some basic ways how website can be deployed to Azure quickly. Some of the ways they have been showing were:
1. FTP
2. Thru Visual Studio
3. Thru GIT
4. Thru DropBox
5. Thru TFS

In my coming posts I will try to cover these and show some examples on how to do it.

Now the next event was all about Mobile Services provided by Azure. This event was actually in my personal opinion was not planned very well. It had lots of glitches in between. But it was about the services like
1. Push notifications
2. Publishing app with diff platform support etc

To be frank I did not understand much with this event I would rather  read the documentation and learn by myself.

Next event was about Windows Azure Media services.

azure_media_services
They talked about the Live streaming of SOCHI Olympics which was hosted by Windows Azure.

They also talked about various media formats supported by Azure and how the streaming can be smooth by Smooth streaming technology.

Next we had lunch time; ok the food was good (it was free) but then they made us stand under hot sun which was still ok since its free hahaha..

Now the next event was about SQL Azure; well what to say I am not an SQL guy so this was a kind of bad choice of me sitting for this event. But what I liked in that event was how to take the backup of the database using SQL Server Management Studio. But the event was very theoritical and less hand on but still it was good nothing to share about lets move on.

This was the last event Windows Azure Websites Deep Dive.. aah very nice and informative event. They showed some cool stuffs like
1. Kudu Console
2. Remote debugging of Azure website
3. Visual Studio Online
4. Web Jobs
5. Zapier.com (very cool website)

Overall very very informative I liked this session the most.

Above topics are huge and lots of details in themselves. I will talk about these as seperate posts soon ūüôā

That’s¬†the end of the first day. Soo much I have learnt from it. Saw so many bright minds on this event got inspired by them to great extent. Very happy to be part of this event

Second day I could not join since taking two days leave from office work was not feasible.

What I get from this? Lots of knowledge which you will see in the coming posts of mine and this very cool Windows Azure Pendrive

azure_pendrive

Database

Starting with Mongooo!!

MongoDB

PS: This post is ported from my own old website sherryummen.in to here. 

MongoDB comes under the type of NoSQL databases. Now the question arise What is this NoSQL? lets keep it simple we can say NoSQL can be seen as something non relational database (though someone can argue that we can design relational database with NoSQL).

But anyway talking about MongoDB, so MongoDB is the leading NoSQL database till this date.

  • Its a Document-oriented database
  • It stores document in BSON format
  • Its written in C++
  • Its cross-platform
  • It has 32bit and 64bit but 64bit is recommended, because¬†of the limitation of 2Gb data size in 32bit
  • It has both open source and commercial License
  • It supports vast range of language; I use mostly C# driver for my work.

Installation:

First of all setting up the mongodb envireonment. Its very simple.

You need to download mongodb from here

Unzip the file to a location; in my case it would be C:\

Open up a command prompt CMD.exe (Ofcourse I use Windows)

console_mongo_start

So if you see the window like this then you are in good track

After this lets start another command prompt and do some testing whether our connection to mongodb instance works and lets run some commands.

So start a new command prompt and do the following

mongo_connects

So now we are connected and we can run some commands in order to test the working so try the following commands

console_mongo_test_commands

very simple example which saves a document to the DB ‘users‘ and then we use ‘find‘ command to display all the values inside the DB

Now, lets some GUI tool to do this. I am not very in favour of command lines; though they are very powerfull but still I like to use GUI tool. SO for our case we will use free tool called RoboMongo.

Its a free tool to use. Starting with how to connect to the mongo instance (Installation is very straight forward so I skip that part)

Open robomongo and click on Create you should see the below screen and fill in the boxes according to your settings. Thats it 

robo_mongo_startpage

Now you should see the nice clean UI of Robomongo and you can view all the documents

robomongo_startpage

You can infact execute shell commands here as well by typing the command and pressing F5

robomong_shell_command

So thats all to just get started with mongodb and setup your small testing environment.

Further I will post more as I learn more about MongoDB.