Tuesday, July 14, 2020

"Hello World" : Azure Functions Tutorial

Creating a new service in cloud comes with all sorts of boiler plate tasks, managing a VM, managing deployments, keeping the software's updated etc. Azure Functions, enables a developer to just focus on small functionality pieces and underlying infrastructures takes care of all the boilerplate.

See the source image

Azure Functions support a variety of trigger points, ranging from HTTP, Webhooks, Event grids, IOT and many more. For a complete list look up here.

Azure functions, just like conventional Serverless computing stack, brings in financial savings. You pay per the resources you use, instead of paying for reserved resources upfront.

Azure functions, triggered via HTTP developing and managing REST apis super simple, removing most of the boiler plate out of the way.

See the source image



Visual Studio supports out of box and provides for a great interface for running and testing these functions locally as well as publishing directly to Azure cloud.
It does support few languages, obviously C# and in addition F#, Javascript etc.

Lets get started with our hello world example

1. Create a new project in Visual studio and Choose Azure Functions as template


2. Choose Http Trigger as type of Azure Function application



3. To run the project locally, just run the project, should launch the console and lets you know the endpoint on localhost, to be used for firing the apis



4. To test the application, use POSTMAN application to fire the api published on console, example  :http://localhost:7071/api/Function1




Publishing the project on Microsoft Azure if straightforward from here

1. Right click on project from Solution Explorer
2. Choose Publish



3. One you choose the right subscription setting, application would get published as a Azure Function.

4. Just like local setup, you can test it from Postman via an api like : http://mysite.azurewebsites.net/api/SampleFunction


Sunday, July 12, 2020

Reading Office documents, Word (.docx) etc. in C#

If you have a requirement of manipulating office documents programmatically in a platform independent way, i.e. with out office interop assemblies, NPOI in one of the best choices available.

  


NPOI is .NET avatar of ever popular Apache POI project. It continues to be open source library for manipulating any Office file formats. If you have ever used Apache POI's Java implementation, NPOI would be straight forward.

For example if you want to print the entire text in a docx file, below is a such an example function :


        public static void PrintAllText(string path)
        {

            Stream is1 = new System.IO.FileStream(path, FileMode.Open, FileAccess.Read);
            XWPFDocument doc = new XWPFDocument(is1);
            int i = 0;

            while (i < doc.BodyElements.Count)
            {
                var runText = (doc.BodyElements[i] as XWPFParagraph).Text;
                Console.WriteLine(runText);
                i++;
            }

        }

Another example if you want to read a word and get all the images from a .docx file, below is one such sample

        public static void ReadImages(string filePath)
       {
            string path = filePath;
            Stream stream = new System.IO.FileStream(path, FileMode.Open, FileAccess.Read);
            XWPFDocument doc = new XWPFDocument(stream);
            int i = 0;
            var list = doc.AllPictures;
            while (i < list.Count)
            {
                XWPFPictureData data = list[i];
                Console.WriteLine("Name" + data.FileName);
                Console.WriteLine("Details" + data.ToString());
                i++;
            }
       }


Here are some of the important links for NPOI

  1. NPOI Home Page
  2. Git Page

Saturday, July 11, 2020

Kids Learning Scratch

Kids are adapting to new age technologies faster than anytime in history. Computer education is not left behind in this trend. Easy access to devices (laptop's , tablets etc.) have revolutionized how early kids are starting with computer education and programming fundamentals.

To balance and meet this demand, there are several platforms which provide programming platforms specially developed and designed for early boomers. Scratch is one such platform. I was amazed by how simple the experience to engaged young kids and introduce them to concepts like Controls, Events, Loops etc.

Here is the one such video of Ianshi teaching her friends of similar age an introduction to Scratch.



Saturday, May 4, 2019

Windows Bluetooth : Mystery of Auto Connect

I use Windows10 on my personal machine and one fine day found myself struggling with Bluetooth connectivity on it.






 The device in question (external speakers) still shows up in the paired device section but would not connect automatically, even when the speaker is switched on in range of Bluetooth of Windows 10 machine.



Fed up with manually connecting speaker every single time, tried to look up on Windows trouble shooting page and found nothing in this regards.

From all the solutions mentioned in net, the below one works for me

1. Press Windows Key + R Key.
2. Type services.msc and scroll down to Bluetooth Support Service in the list.
3. Right click on it and select Properties.
4. Set up Start up type to Automatic from the dropdown list.


And voila speakers connect automatically from here on !!

 

Tuesday, October 23, 2018

Finally Oreo is here for A9 Pro devices

Samsung has finally released the Android OREO update for Samsung A9 Pro devices.







Why is this important you ask ? Well for one it has been released a bit earlier than expected than Samsung earlier estimates which slated this release for December 2018. No pun intended on "bit earlier" part, Samsung is notoriously slow in release updates. Secondly, this might well be the last update A9 Pro might receive, yes Android Pie is not guaranteed for this device, so you better like since you are going to be stick with it for a while.

Getting back to update, update is roughly 1.3GB in the OTA mode. Get a wifi and make some space on your devices guys.






I heard some reviews of updates going wrong and users loosing all there data, gladly nothing of this sort happened on my device and update for largely smooth. Just ensure you have enough juice(battery), stable wifi and sufficient space in phone.

From the early reviews

1. First and foremost I finally do not need external call recorders. While the experience is still tad shady in comparison to other OS like MI, but still a relief from using external call recorders. You can access from settings in Phone application.

2. Camera UI has changed. I noticed some distortion in still images, not sure if its the update though. Video quality has for sure got better.

3. RAM management is bit unpredictable, guess the ease and nimbleness of switching apps has been traded for better battery management.

4. Secure folders app is now available to store all those important personal documents.

5. Other features like Samsung Pay etc are available out of box, not sure if they are functional in Indian stores thought.

6. Google Assistant has improved by notches and really works. Be sure to customize it to your voice samples.

After the update your phone would be Android 8.0 and Samsung User Experience version 9.0


Thursday, May 10, 2018

The Next Wave of AI : Google Duplex

Recently demo'ed at Google annual event is the new product named Google Duplex. Duplex takes the digital assistance a level ahead, by not using APIs or application flows to do day to day jobs but by actually making phone calls.



Whats more interesting is how close attention was given to human interaction, the ahan and hmms are just some of the stop gap's and linguistic fillers it uses to fool the humans on other side in believing they are speaking to real humans.


Here is the link to full demo




Full geeky points on Tech front, but what about ethics ? Is it fair for AI to fool humans in an interaction ?



Some of the things to worry about how easily this technology can be used to spam people with voice calls and unlike spam of emails this one would not be easier to catch. Funnily Google invested more in making in harder to catch duplex rather than voice interaction itself.

Start preparing you list of trick questions :)

Merging and Splitting PDF files

We all use and rely on PDF's. There are occasions though when you want to edit certain portions of a pdf and merge the edited version ba...