Smart Copy and Paste from StackOverflow–part 2 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Examples in this book

1. Sort a collection

Let’s suppose we have a class Person with FirstName and LastName as properties. Also we have a collection ( List<Person>) that contains multiple persons( loaded from a database[1]). We want to let the user sort this collection for FirstName or LastName at his choice.

2. Store encrypted data in a file

Let’s suppose that we have a connection string[2] ( with user and password) to connect to a database. We want to be able change this – to accommodate software for the buyer. But we do not want to let the user know the connection string – to protect lazy database administrators. A solution is to encrypt the connection string , store it and later retrieve and decrypt it.


[1]by database I understand any physical support of storing data that can be retrieved later. It does not matter if Relational or No-SQL or text file

[2]do you know http://www.connectionstrings.com/ ?

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Smart Copy and Paste from StackOverflow–part 1 from 7

I have written this mini e-book in order to remember myself how to do it .

I will put each week a part from my book here in the blog. If you want , however, buy the book, I will do appreciate !

 

Introduction

When I started programming for a living (1997+), there were no sites to learn from. The access to internet was not affordable . The search engines were bad( Altavista+ Yahoo) There were some frameworks available – but mostly for graphical components( such as buttons) , PC functions( e.g. sending TPC IP messages, DDE messaging / OLE function ) and databases ( remember ISAM ?) . But for sorting a collection of elements you must learn from a book of algorithms and then make your function ( that you will re-use after in other projects). In these days you have List<T>.Sort (https://msdn.microsoft.com/en-us/library/b0zbh7b6(v=vs.110).aspx ) and you should not bothering about Quick Sort , Merge Sort, Bubble Sort or the differences between them.

The book will feature a good programmer that has to solve a problem and like to code the solution( as opposed to download some nuget/npm package[1]) . I will give two examples in order to exemplify how to do the smart copy / paste from Stack Overflow.

All I have written here is taken from my personal experience – that I consider valuable and helped me a lot in time.If you have some ideas to improve this book, please feel free to wrote to ignatandrei@yahoo.com or via my site , http://msprogrammer.serviciipeweb.ro/

Thank you to Stefan Petrini for reviewing the book.


[1]See http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

 

 

The book link is http://www.amazon.com/Smart-Paste-Stack-Overflow-other-ebook/dp/B01EHI5RQM

Microsoft Bot SDK

I have tried Microsoft Bot SDK from https://github.com/Microsoft/BotBuilder . It is wonderful. It is rather simple and comes with examples ( the echo one is the most simple to understand) . It has integrations with Slack, Skype, WebChat and others ( see https://dev.botframework.com/ )

In order to test it, the simplest way is to download Bot Framework Emulator from http://download.botframework.com/botconnector/tools/emulator/publish.htm 

For my testing , I have made a bot that sends you exchange rates from BNR(National Bank of Romania)  or BCE( Central European Bank)

The code was fairy simple . I have read the examples from https://github.com/Microsoft/BotBuilder and my own.

If you want to see in practice , you can try it at

  1. email : ignatandrei@ignatandrei.onmicrosoft.com
  2. slack
  3. skype
  4. chat

The techonlogy ourdays is amazing – and Facebook is developing the API for his own bot (https://developers.facebook.com/docs/messenger-platform/quickstart ) Will we be surrounded by bots?

AppContext

AppContext is like Application in ASP.NET (MVC). You can see the value all over the application

AppContext.SetSwitch("OCR", true);

And we can have the result in all dll’s by

 public bool IsOCREnabled()
        {
            bool test;
            if (!AppContext.TryGetSwitch("OCR", out test))
                return false;

            return test;
        }

Video demo at https://youtu.be/GMgn4o3yPqw