Sunday, June 26, 2016

Add custom CSS to your blogger blog

Once you start writing stuff regularly on your blog you will soon start to need custom stuff - like adding custom styles to the blog. This is how you do it on blogger.

1. Select the blog to update and in the Options Menu click Options

2. Click on the Customize button next


3. Next Select Advanced and Add Css as shown below


Add your CSS there and refer it in the HTML of your blog.

Monday, June 20, 2016

Azure Command line tools - uploading blob to storage account

Most of your "cloud" workflows would require automating some operations that are part of your cloud service. I recently had to upload a blob to blob storage as part of a batch file. How to do that ? azure cli comes to the rescue.

Install Azure CLI as mentioned here : https://azure.microsoft.com/en-in/documentation/articles/storage-azure-cli/

That makes available the 'azure' command on your command line.



The help is quite exhaustive.

To upload a blob I used the following :

azure storage blob upload -f FILE_ON_DISK --container YOUR_CONTAINER_NAME --connection-string STORAGE_BLOB_CONNECTION_STRING

Use the --quiet option if you want to overwrite an existing blob on the cloud.

Sunday, June 5, 2016

Loading Excel (.xlsx) files in C#

So I needed to write an app (console) that would read and process an excel file. A quick search would lead me to this stackoverflow post which suggests using the Linq-To-Excel package.

Linq-To-Excel has a Nuget package and is easily installed. This nice little snippet in that post is self explanatory:

var data= new LinqToExcel.ExcelQueryFactory(@"MyFile.xlsx");

var query =
    from row in data.Worksheet("MySheet")
    let item = new
    {
        Id = row["Id"].Cast<string>(),
        Name= row["Name"].Cast<string>(),
        Age= row["Age"].Cast<int>(),
    }
    select item;

    foreach ( var item in query) {
        Console.Writeline(item.Id "\t" item.Name);
    }

Except that the following run time exception will be thrown when you start iterating through the results (the microsoft.ace.oledb.12.0 provider is not registered)


This is easily resolved by installed the Microsoft Access Database engine from this page : - and there you go - load up any excel file just like any simple TSV!