Wednesday, July 1, 2015

Do you need to know the programming language Scala?

BigData is all the rage now.

The functional coding language Scala is Object Oriented, type safe and compiles to ByteCode, the format for JVM. It is therefore interoperable with Java. Apache Spark understands BigData.  For working with Apache Spark, you better learn Scala.

I would say it is essential to have a knowledge of Scala. Sure Java and Python are also the other languages you should have in your toolbox as all of these allow you to build parallel applications for a distributed environment. In addition to Java, Python, and Scala, R programming can also be used.

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).