Monday, December 19, 2016

Stop the annoying beep when pressing TAB on bash windows

I find the constant beeping by bash when I press the tab key super annoying. Especially if you have headphones on, its a killer. The simple way to turn it off is as follows:

Add the following line to the ~/.inputrc file:

set bell-style none


Restart your bash and you shall attain beepless nirvana!

Saturday, July 16, 2016

Paste JSON as Class ! [Visual Studio]

One of Visual Studio's coolest feature - copy the json that you to 'class'ify ;). And click on "Paste JSON as Classes" and voila you a class made of your json ingredients !



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!

Tuesday, May 24, 2016

Javascript being cached during development time by Visual Studio and Internet Explorer

So I am working on this website and need to make some changes to a javascript file in the site. The changes I made was to disable elements of div containers having a particular tag. I make the change and hit F5.

The divs are not disabled. I add a break point to the JavaScript file in Visual Studio and see that the break point is not enabled indicating that something is amiss. The changed JavaScript was not loaded at all.

Searching this led me to the following post on StackOverflow.

The answer essentially is to do a CTRL+F5 or try to open the link in a different browser.

How To - Develop a Simple Outlook 2013 Add-in in C#

This post explains creating a simple outlook add-in using Visual Studio 2013 and some details on accessing various mail properties in the add-in.

Required Tools

  • Visual Studio 2013 ( you could also work with Visual Studio 2012)
  • VS tools for Office - Download and install from here : http://blogs.msdn.com/b/lightswitch/archive/2014/03/03/office-developer-tools-for-visual-studio-2013-march-2014-update.aspx
    • The executable starts the Web Installer which looks like the following:

Creating a Project

Create a new Outlook 2013 Add-in by selecting New Project -> Office / Sharepoint -> Outlook 2013 Add-in as shown below:


This will create a partial class called ThisAddIn.cs with two methods
  • ThisAddIn_StartUp
  • ThisAddIn_Shutdown
As is obvious - any initialization operations can be done in the StartUp function and any cleanup in the Shutdown function.





References

  1. Ribbon Designer - http://msdn.microsoft.com/en-us/library/bb386089.aspx