Friday, June 26, 2015

How easy is it to create a IFTTT Recipe?

It is very easy and only takes a couple of mouse clicks.

Since you have asked the question, I assume you know about IFTTT.
If you are reading this and do not know what IFTTT is, read this recent post.

IFTTT makes it easy to trigger something based on your desire to do something else you want done. There are two 'somethings' here.  The something to set up the trigger and a something will go into action. The nice thing is there are a lot of sources to create trigger and there are a lot of sources where your action is executed.

Let us take a concrete example, when the stock ticker symbol MSFT goes above $50.00 you want an email sent to your, let us say gmail account. IFTTT uses Yahoo Finance to create the stock related trigger.

First of all you need to sign up for an IFTTT account.
Once you have an account you can sign-in to it to access MyRecipes as shown:

Click on Create a Recipe.

Click on the highlighted word 'this'
You will get to this web page. The Choose Trigger Channel page. The stock symbol is further down and you need to scroll.
When you choose the stock channel you will be guided to this page.
There are predefined triggers that you can create. I chose the trigger for 'Price rises above'.
This guides me to the 3rd step as shown.
Fill in your trigger detail and click Create Trigger. This takes you to the next page as shown.
The inadequacy of this recipe is that you can only create trigger for on symbol at a time for one chosen option.
Now click on the highlighted word, 'that'.
You will be guided the following.
Now click on the Action Channel related to GMAIL.
Here there is only one possible action. Click on Send an email to get to the following:
You only need to insert the email addresses. You are almost done as you have arrived at the last step.
Just click on Create a Recipe and you are done! The recipe you created goes into your My Recipes container.


Thursday, June 25, 2015

Can you use a Here-Strings query to retrieve data using PowerShell?

Yes you can.
You need to understand a few items. Let me go over them.

What is meant by here-strings?

Using a variable in a here-strings:

How to query a SQL Server with SQLCMD?

How do you query a database using PowerShell?
If you review the above articles then you can put together all the information in running a query as shown where the query to the database is in here-strings.

That is all folks!

Here-strings come in very handy when the query contains single quote, double quotes and other such ugly characters which a mere string representation cannot handle.

Monday, June 22, 2015

Can you run queries on multiple SQL Server Instances at the same time?

It is possible to query multiple SQL Servers using the SQLCMD mode in SQL Server Management Studio. You start getting connected to atleast on instance.

In the following example, there are two instances of SQL Server:
1. SQL Server 2012 with named instance 'RegencyPark'
2. SQL Server 2016 CTP2 with named instance 'May2015'

I start with SSMS 2012 and run the following statements after enabling SQLCMD Mode in SSMS 2012.
You will get connected to the two named instances when you query them as shown here (in a query window in SSMS 2012):

:Connect .\May2015
Select @@version
Select * from dbo.msdb_version

:Connect .\RegencyPark
Select @@version
Use AdventureWorks2012
Select * from Person.person

You get the following response from the server.


Wednesday, June 17, 2015

What is SQLite?

It is a serverless SQL Database that does not require a separate server process. You do not need a configuration (Zero configuration) and it does not need any administration. The whole database is stored in a single cross-platorm disk (or on your mobile device). It is very popular and widely used with mobile applications as the database is stored in the device and can be used without network connection. No external dependencies.

SQLite as opposed to client/server relational database engines is serverless and it's use is indicated where efficency, reliability, independence and simplicity are required and it does not look for a shared repository. SQLite trasactions are fully ACID-compliant. SQLite supports most query languages that are SQL92 compliant and it is written in ANSI-C which provides simple APIs.
SQLite is available on Linux, Mac OS-x, Android, iOS and Windows 32, WinCE and WinRT platforms.

SQLite download from here:
Read more here:

Friday, June 12, 2015

How do I fill an excel worksheet with data using PowerShell?

It is quite easy, if you really want to.

The following code brings up an Excel workbook on your desktop
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True

This line adds a worksheet to the workbook with default name, Sheet1
$Excel = $Excel.Workbooks.Add()

Name the worksheet you created with the following:
$Excel.WorkSheets.Item(1).Name = "Contacts"
The default is changed from "Sheet1" to "Contacts"

The worksheet has cells with (columnNum, RowNum) reference
Fill up the sheet with the data using:
$Sheet.Cells.Item(1,1) = “First Name”
$Sheet.Cells.Item(1,2) = “Last Name”
$Sheet.Cells.Item(1,3) = “Phone”
$Sheet.Cells.Item(1,4) = “Email”
This displays the Excel Book1 as shown here:

The full code is here:

Whenever possible look for intellisense help!
p.s: Tom Hoskins is an imaginary name

Wednesday, June 10, 2015

How to read potentiometer output from Arduino using Visual Basic?

Let us assume you want to read the voltage from a potentiometer which is connected to the Arduino UNO. Let us further assume that it is analog voltage that you need to read.

If you are new to Arduino and Visual Studio read the following:

Arduino has a 'sketch' for this specific case shown next:
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is in the public domain.

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  delay(1000);        // delay in between reads for stability

You should first set up the circuit required for this sketch which requires the two ends of potentiometer tied to 0 and 5V of the Arduino and the center leg (has the variable voltage) depending on the potentiometer setting tied to the terminal A0 on the Arduino Uno board.

The Arduino must be connected to the USB port of your laptop/desktop which has Visual Studio appropriate for working with arduino Uno.(ref).

Once this is set up, run the sketch on Visual Studio and verify that you can monitor the potentiometer reading converted to digits (this is done by the sketch).

Now create a new Visual Basic Windows Form project and place controls on the form as shown here. It is essential that you add a SerialPort control as well from the Toolbox.

Here is the project folder:

Here is the Form1 of this project:

Here is the code for the button click event:

Here is the reading of the potentiometer:

If you see this message just ignore it:
The thread 0x2f14 has exited with code 259 (0x103).
The thread 0x1d2c has exited with code 259 (0x103).
The thread 0x30ec has exited with code 259 (0x103).
The thread 0x3ab4 has exited with code 259 (0x103).


How do you convert a string to integer in Powershell?

It is easy to convert a number represented as a string into an Integer.

Here is a string declaration:

Declare the string in the command window is as shown:
PS C:\Users\Jayaram> $str1="123"  

The displayed value in the command window is as shown:
PS C:\Users\Jayaram> $str1

You can get to find the data type by running the following:
PS C:\Users\Jayaram> $str1.GetType().FullName

Now we convert this to an integer

The following line converts the string to an Integer
PS C:\Users\Jayaram> $foo=[INT]$str1

This is the value in the $foo variable
PS C:\Users\Jayaram> $foo

Now we get the type of data in $foo
PS C:\Users\Jayaram> $foo.GetType().FullName

Difference between GetType().FullName and just GetType()

PowerShell has intellisense support and you should make use of it in your coding as shown here:
After typing $foo insert a . and wait for the pop-up menu with various possible items as shown.

A string such as "555-5555-1212" is a string but will return an error as the variable is not in the correct format.
PS C:\Users\Jayaram> $str2="555-5555-1212"

PS C:\Users\Jayaram> $boo=[INT]$str2
Cannot convert value "555-5555-1212" to type "System.Int32". Error: "Input
string was not in a correct format."
At line:1 char:1
+ $boo=[INT]$str2
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

Monday, June 8, 2015

What is Windows Essentials?

It was formerly known as Windows Live Essentials, Windows program suite consisting of freeware applications from Microsoft. It is essentially a bundle of programs consisting of:

The latest one available is Windows Essentials 2012 which you can download and install on your computer.
The 2011 version is available here:

The 2012 version details are here including download link:

Sunday, June 7, 2015

How to remove red eye from an image in Windows 8.1?

The removal of red eye is quite easy but you need to download and install Windows Photo Gallery from Microsoft site here:

Let us first install Photo Gallery.

Download this file

The system requirements for Windows Essentials 2012 which has Photo Gallery and other programs.

Select how you want to install.

Select items you want to install.

Sign the license agreement.

In Photo Gallery import the picture. This was imported from a Nokia Icon camera and there is a menu item to fix the red eye. Just follow the procedure(shown inside rectangle in the image below).

 That's as simple as that. The red color just vanishes.





Can you have a variable in PowerShell here-strings?


Review this link before you begin.

You can have a variable in Here-strings but you need to define the variable in the same session. Here is how you do it:

Declare $hello as follows:

Hello $x

In order that the variable is expanded run the following:

(This is not case sensitive, you can as well run, &$hello)
and you will get the response:
Hello Jay

(hello or Hello: not case sensitive)
Variable declaration can be in the beginning also as shown:

PS C:\Windows\system32> $Hello={$x="Jay"
Hello $x
PS C:\Windows\system32> &$hello
Hello Jay

PS C:\Windows\system32>

Note that defining the variable in single quotes will not alter the response.

Saturday, June 6, 2015

What is here-string in Windows PowerShell and how do you use it?

Here-string is a generic way of denoting a file literal or an input stream. It is used to treat a part of the source code file as a separate file. Here-string finds its origin in UNIX Shell

Like other shell programs Here-strings is also a feature of PowerShell.

Probably you be able to comprehend it better by looking at how it is used.
First of all how do you create a string from a block of text?
Let us take the Hello World example.
The Here-string variable $hello is to be declared as shown:
Hello World

It has to be declared exactly as shown.
For example if you declare it as,
$hello=@"Hello World"@

then immediately when you try to run this script you get the following error:
At line:1 char:10
$hello=@"Hello World"@
+          ~
No characters are allowed after a here-string header but before the end of the line.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedCharactersAfterHereStringHeader

Of course you will notice that the following declaration also produces an error:
Hello World"@

The error if you run this is:
The string is missing the terminator: "@.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Now that it is correctly declared if you run the script you get the response as

Hello World
See the response in Windows PowerShell as shown:

The point to remember is the declaration starts with @" and whatever else start on the next line
and Ends with "@ on a new line. In between you can have strings, variables, formatted text etc.


Thursday, June 4, 2015

What is Polybase?

It is a Microsoft Data tool. It simplifies management of relational and non-relational data with the ability to query both.

You want to query non-relational data. Do you modify it and bring it into SQL Server which is relational and then query it? Or do you buy another product to query non-relational data (like data in Hadoop, blobs and files)?

Well Polybase provides the capability to query non-relational data in-situ using the SQL Server using T-SQL. You need not move the data over to SQL Server although SQL Server gives the option to store in SQL Server if you want to do so. Polybase is supported out of the box in SQL Server 2016 CTP2 which means it will be available in SQL Server 2016.

Polybase was not supported out of the box in earlier version. Of course Polybase can process the queries whether it is on the premises or in the cloud.

Here is a rough schematic of what it is about.


Tuesday, June 2, 2015

What is Microsoft Solver Foundation?

It is a set of tools to work on mathematical simulation, optimization and modelling. It uses the managed execution and common language runtime (CLR). This means you can use any of the CLR languages including VB, Visual C++, Visual C#, Visual F#, and IronPython.
Of course you can also use ASP.NET and Silverlight in your mathematical operations.

Mathematical Solver Foundation APIs
  • Can run remotely as a service within IIS and ASP.NET
  • Can run in Excel as an add-in
  • Integrate with other .NET Framework apps
  • Embed as DSL within CLR languages
  • Embed as a CLR compliant module.
Review this link for more: