Wednesday, February 22, 2017

Environment variables settings made better in Windows 10

 This was long overdue and finally it is done.

Editing Path was one that was often used whenever direct access to application from the console was desired and that involved three windows, each of which had such a spatially constrained UI design that you needed to scroll horizontally to make a change.

In previous versions of Windows including some earlier Windows 10, editing environmental variables using the built-in interface was not a easy task.

  

 

 
 The windows had fixed dimensions and you can see how cramped it was.

 The user interface is discussed here (http://hodentekhelp.blogspot.com/2010/08/compiling-java-in-windows-7.html) for those who want to know how it was done.

But recently it has changed. The present version is 1607.

Windows 10 does it better as you will see presently. You can get to the Environmental Variables window by typing in Path in the search box.

You get two environmental variables the User's as well as the Systems' as shown.




Open the Systems' (blue) and you get the System properties window  as shown no different from the old one.


envNew_01.png

Click on Environmental Variables... to open the Environmental Variables window as shown. It is bigger and better.


envNew_02.PNG

In System variables (bottom) pane scroll down to Path and double click the text Path. The edit window for environmental variables opens up as shown and you can modify any sub-path in its own window.

 envNew_03.PNG

You can also move up/move down as well as edit the text. Just finish off with a click on OK and you are done.

Don't you think Microsoft did this better!




How do you fix this RStudio error?

You some times see this error in your RStudio console:

ERROR: [on_request_read] connection reset by peer

What is described is not a complete fix but a possible explanation of what is happening. It is most probably related to RStudio using the Microsoft Edge in Windows 10 operating system.

There are three modes that you can run to display in a viewer. This are shown in this image here:


ShinyError_000.png

Run in Window mode:

Run in Window opens a window ~ -Shiny as shown and runs the highlighted code to display the result.


ShinyError_00.PNG

Notice that the tab that is open is http://127.0.01:6170. Now if you change over the tab to 'Open in Browser', Microsoft Edge opens displaying the same URL. Now if you close the browser you see the error messages as shown. I am not sure why it repeats so many times.


ShinyError_02.PNG

However, if you copy the URL (http://127.0.0.1:6170) and paste it into a Firefox browser you will see 'Hello World' displayed again. But if you close this browser, no error is reported in RStudio console.

Hence in Run in Windows mode you can get away without producing error and stopping by pasting the code in Mozilla Firefox (assuming you want to see it in a browser).

Run External:

In this mode the Run result is displayed in the external browser which happens to be Microsoft Edge and you cannot avoid the error. Of course the code runs and displays the result but when you close the browser the error crops up in the console.

Run in Viewer Pane:

Viewer pane is one of the panes of RStudio. When you run the code in this mode the result will be displayed as shown.

The error crops up immediately as shown.


ShinyError_04.PNG

You need to click the Stop button to return to console prompt.

You can avoid this problem by choosing Mozilla Firefox as your default browser.


ShinyError_05.PNG

Tuesday, February 21, 2017

How do I download R Studio to run / learn R programming?

If you are looking for the free version you need to download the RStudio Desktop which comes under Open Source License. Go here to see other versions which are not free ).

In the above link choose the free edition which has Integrated Tools for R and click Download.

You get the following page. If your operating system is in this list, you download from the related link. Note that depending on whether or not you have R 2.11.1+ version. If you do not have you need to download that one first (http://cran.rstudio.com/).


RStudidowwnloads.png

Click on the one you need. For Windows 10 Desktop, the relevant installer is RStudio 1.0.136 -Windows Vista/7/8/10.

You save the file to your Downloads folder.

Double click the executable and it begins installing following the wizard steps.

The installation folder by default is C:\Program Files\RStudio but you can change. You can also add shortcuts.

The installation is quick and you will find the rstudio.exe in the RStudio\bin folder. Double click to launch the program. The shiny package is already in it as shown.


RStudio_01

When you just run library(shiny) in RStudio you get the following response. You also get color coding and code guidance very much like intellisense as shown.


RStudio_02

Monday, February 20, 2017

What is Shiny?

You started learning the Statistics/Analysis focused language R and you want to do more. You want to build apps with it and host them on the Internet. All this is possible using Shiny.

It is an enterprise-grade web application framework targeted for those who want to develop with R using the familiar HTML5, CSS and JavaScript. Using R you can turn terrific analytic solutions you have developed/developing into interactive web applications.

Go to this site (https://shiny.rstudio.com/) directly and learn more.

 
Rshiny-00

If you have R Studio you have Shiny because Shiny is a package that you can download.

In this first part we only talk about the very basics.

I assume you have read my previous hands-on R examples in my blogs.

http://hodentekhelp.blogspot.com/2015/09/what-is-good-way-to-learn-r-language.html
http://hodentekhelp.blogspot.com/search?q=R+language

Here I just show a very basic (aka Hello World) example of creating content for a web page using R GUI. More will come later in my blogs.

Launch R Gui as shown and provide reference to the shiny "library" as shown by typing in the three lines of code (The four lines of code in red).


 HelloWorld_00

<-fluidpage br="" ello="" world=""><-function br="" input="" output="">When you hit Enter after the third line where you define the shiny app, a browser window will open as shown displaying the apps output as shown at a port of the local host.
 


<-fluidpage br="" ello="" world=""><-function br="" input="" output="">HelloWorld_01

You also get a response (the last line) in the R GUI as shown.
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">
HelloWorld_02
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">That is all there is to create a content.
<-fluidpage br="" ello="" world=""><-function br="" input="" output="">
The ui summarizes your user interface, the server is something like a web serve rand shinyApp is your web response. No fuss, very simple.

Saturday, February 18, 2017

What are mutable and immutable variables in F#?

If I assign a value to a variable and then later in the program I assign another value to the same varible the program does not care if it is a mutable variable. However if it is immutable, the program does not accept it. Hence immutable variable is one which is solidly bound to its value.

Let me take you to the .NET Fiddle site so that you can run it yourself and see the result.

First of all assignment to a variable in F# has the following syntax:

let x=25
 
The above statement assigns a value 25 to the variable x. I can print it to the screen using the second statement (printfn "x: %i" x) because x is an integer.






Next I assign a value of 45. You can see the error in this statement immediately. Hence value of x is immutable.


Now how can I assign a mutable value?

Well, F# uses the keyword mutable as shown here:

let mutable x=15

Now x has a value which can be changed later as shown in the next image. The first statement sets a value 15 for the variable x and the second statement prints it.

The third statement assigns a new value to it, namely 20 and the fourth line prints it. Observe carefully the new value assignment, a backward going arrow.





What is Windows Hello and how to enable it?

Windows 10 uses bio-metric signature of an individual as a security feature of a Windows 10 device, be it a Windows Phone or a Windows tablet/PC. Windows Hello makes this possible in Lumia 950 with an iris scanner. It can also be of two other types and some devices may have more than one type. As an alternative the device should also have the option of other non-bio-metric of authentication such as a pin or a username/password pair.

Lumia 950, the Windows 10 phone has an iris scanner built-in to the camera that compares an individual's iris image to the one that it stored during the initial set up and the phone is unlocked when there is match. if not, the phone asks for the pin number to be punched in to unlock.

The other Windows Hello options are finger print recognition and facial recognition.

In what follows I show some of the screen shots for setting this up on a Lumia 950 Phone. Not all types of Windows Phone has this feature.

First of all this is a high resolution photograph of a human iris from an UK site here.
It is easy to believe the iris signature is far superior to finger print if the camera is good.


Setting up Iris Recognition:

Yous start with Settings on your Lumia Phone after setting up a pin to login. In Settings look for Personalization.


Lumia950_00.png

Go down the list and click Lock Screen to open the Lock Screen Page as shown.



Lumia950_01.png

 At the very bottom you find Sign-in options. Click this link. The Sign-in options page opens as shown.

Lumia950_02.png

There is link if you want to know more about Windows Hello. But there is a Iris(Beta) Set up button. Click the button.
You get a Welcome to Windows Hello page. You can not only unlock your phone without complex passwords but you can buy stuff from Windows Store.

Lumia950_03.png

Click on Get Started. The Camera becomes active and you will be asked to move closer or farther (as the case may be) so that the camera can take its standard image of your eye as shown here.

Lumia950_04.png

You will be asked to hold your phone in front of your eyes (I did open my eyes a little more than wider to make sure he camera got it all) as shown.


Lumia950_05.png

Click Next while you are holding the camera and looking into it.

Your setting up has been successful. You may do it even with your glasses on so that with or without glasses you can unlock your phone.


Lumia950_06.png

It did work quite well. There were a few times it did not and then I had to use my pin. But this is much better.






Friday, February 17, 2017

Can I use Windows Power Shell to look at Printers?

Almost anything on the Windows can be accessed from Power Shell and that includes Printers. I have a Canon MX430 printer which is a multi-function printer.

There are two ways to find about printers (that I know of):

You can find all printers using this comndlet to run:
------------
PS C:\WINDOWS\system32> (New-Object -ComObject WScript.Network).EnumPrinterConnections()

LPT1:
Canon MX430 series Printer
nul:
Send To OneNote 2016
PORTPROMPT:
Microsoft XPS Document Writer
PORTPROMPT:
Microsoft Print to PDF
Journal Note Writer Port:
Journal Note Writer
SHRFAX:
Fax
CNBJNPFAX_888717BBF935
Canon MX430 series FAX

---
Or, you can also use this:
-----------------------
PS C:\WINDOWS\system32> Get-WmiObject -Class Win32_Printer


Location      :
Name          : Canon MX430 series Printer
PrinterState  : 0
PrinterStatus : 3
ShareName     : Jays MX430 series Printer
SystemName    : HODENTEK8

Location      :
Name          : Send To OneNote 2016
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

Location      :
Name          : Microsoft XPS Document Writer
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

Location      :
Name          : Microsoft Print to PDF
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

Location      :
Name          : Journal Note Writer
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

Location      :
Name          : Fax
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

Location      :
Name          : Canon MX430 series FAX
PrinterState  : 0
PrinterStatus : 3
ShareName     :
SystemName    : HODENTEK8

What is fsi.exe?

Fsi.exe is an interactive console application for programming with F#.  Fsi.exe executable opens up a window console when you double click this file after download or otherwise.


F#_00

F# is not only for Windows OS, you can use it on Mac and Linux operating systems as well.

On Windows platform it is recommended to use Visual Studio to code in F# as Visual Studio is extremely well integrated with F#.



There are a couple of ways to work with F#:

1). If you have Visual Studio 2010/13/15 Professional are higher F# is already included.


2) .Using Visual F# Power Tools can provide additional features such as :
Source Code Formatting
Auto-generating XML Docs
Highlighting
Find
Rename refactoring
Depth Colorizing
Implementing Interfaces
and
many more.

3). You can also Install Visual Studio Code which is both open source and cross-platform. F# is supported by the Ionide  Project.

4). Install free F# compiler and tools alone

For this you need Windows SDK:

On Windows 10 use the Windows 10 and .NET 4.6 SDK from Microsoft
On Windows 8.1 use the Windows 8.1 and .NET 4.5.1 SDK from Microsoft
On Windows 8 or Windows 2012 Server use the Windows 8 and .NET 4.5 SDK from Microsoft
On Windows 7 or Windows 2008 Server use the Windows 7 and .NET 4.0 SDK from Microsoft
Requires Microsoft Build Tools 2015

5). Another easy way to work which does not need any download is to access this URL:

You have the choice of three languages here: C#,VB.NET or F#.




Enjoy!

Sunday, February 12, 2017

How do one access data on a OData Data service?

If you are looking for URL data access you are in the right place.

This is often a easy way to find database data by sending queries to the service site.
There are two formats of resource representations:

OData:Atom
OData:JSON


The document OData:Operations describes the actions that can be performed on the URLs. Although most sites follow the conventions defined by specification not all of them do.

The following is a picture of the URL Components from the the OData site that is relevant to our discussion.


URLData_00.png

As an example let us take the Northwind OData service at this site here:


http://services.odata.org/northwind/northwind.svc

The http: is the HOST
http://Services.odata.org/northwind/northwind.svc: is the SERVICE ROOT

The SERVICE ROOT is required to find all the resources provided by the OData service.

Simply put, if you access the Service Root you would see the following in Microsoft
Edge (Microsoft Edge 39.14965.1001.0)




URLData_01.PNG

This is essentially the same as what you see in Mozilla Firefox


URLData_01b.PNG Mozilla (Firefox 51.0.1 (32-bit))

The collection in either of these you see are the tables in the Northwind database exposed as a service.

Accessing the table:

Now how do we access one of these tables. Let us say the Products table. All you have to do is to append Products to the Service Root as in the following:
http://services.odata.org/V4/Northwind/Northwind.svc/Products

The Firefox browser would display this:
Only part of the browser display is in this image.



URLData_02.png

However in Microsoft Edge you would get a response asking you whether or not you want to save.


URLData_02b.png

I have found this is does not always happen and displays the same information as the Firefox.

You may query the browser to format it in JSON with the following instruction:
http://services.odata.org/V4/Northwind/Northwind.svc/Products?$FORMAT=json



Filtering the table:
After getting to the Products table, let us say you want to get only the first Product which has ProductID=1, then you change the URL to


URLData_03.png(FF)
In ME you get the same results above.

You can further filter the table.  For example you can find all the Orders placed by the Customer whose CustomerID="ALFKI".
 http://services.odata.org/Northwind/Northwind.svc/Customers(%27ALFKI%27)/$links/Orders


URLData_04 FF

But in ME you would get the following:

URLData_04b.PNG

Looking at the Northwind database, this result is the same as the query.



URLData_05.PNG

These are the columns in the Orders table.



URLData_06.PNG

Friday, February 10, 2017

How do you print from an iPhone?

I have an iPhone6 and I wanted to print to my Canon MX340. I tried the following. It would work if I had at least Canon MX341 or later.

The first thing to check before you try to print with the method suggested here is to make sure you have Windows OS 7 or 8. This may not work with Windows 10.

At first download the following app (Air Photo WiFi Printing) from Apple Store to your phone.


IphonePrint_0

After downloading you launch the app and it opens the following:

IphonePrint_1

Now you go to the computer to which you have connected the printer by a USB connector (this may work even if it is not connected as this app configures Wi-Fi and your printer is recognized by the Bonjour Service) and double click the downloaded file with extension .msi.

This installs the service and follows it up by installing Bonjour Service to discover your phone.
Now choose a photo from your phone.

MelkoteKarnataka.PNG

Click Select Printer.

If your Printer is one of those AirPrint printers then you are in luck otherwise you get a message like this:

 iPhonePrint_02

Well which of the printer is an AirPrint printer. There are whole lot of printers in the market and some of them are AirPrint type.

Get a list of all those printers here:

How do you enable JavaScript in Microsoft Edge?


Enabling JavaScript in Microsoft Edge is a two step process.

In Microsoft Edge do this:

Click on ... (ellipsis) button at the right extreme to display the drop-down menu as shown.



EnableJavascriptEdge_0.png

Click Open with Internal Explorer to open the IE Browser.

In the opened IE Browser do this:
Go to Menu at the top, click and open the Internet Options (at the very bottom) to open the Internet Options window.
Click Security tab to open.


EnableJavascriptEdge_1.png

Click Custom level...  under Security level for this zone to open the Security Settings -Internet Zone as shown above.

Scroll down and enable Active Scripting as shown.


EnableJavascriptEdge_2.png

Thursday, February 9, 2017

How do you import a text file into appery.io?

Appery.io supports importing data files in CSV or JSON formats. In this post you will learn the procedure to import a CSV text file.

The file we are going to import is FFD.CSV (file FFD.txt saved as CSV file type) saved on the files/folders of the local computer which has been imported recently into other data sources such as MS Access 2016 here and here; SAP SQL Anywhere 17; and Power BI. The data file is created by exporting the data from a Query on SQL Server 2012 using the Export/Import Wizard.

Log in to Appery.io and Click on Databases tab.

ApperyIO4_0.PNG

There are already two databases under my account. Click Create new database.

Create new database window appears. Insert name, herein it is Jan8_2017.


ApperyIO4_1.PNG

Click Create and the database is created as shown. The database is empty and has no collection.


ApperyIO4_2.PNG

Importing a collection: A Collection in Appery.io is like a table in a relational database.
Now we can either create a collection or import one.

Since we are importing the data we click on the link, import a collection.

The Import data screen is displayed as shown. Provide a name for this collection - SQLServerData. Click on Browse... and locate the file FFD.CSV on your computer.


ApperyIO4_4.PNG


Click Import.
Data in the FFD.CSV file is now in the appery.io collection in the database Jan8_2017


ApperyIO4_5.PNG

Note that some of the letters in the ProductName came with a ? mark as these are not characters in the English language set.

Here is a sample of the data in the FFD.CSV file


ApperyIO4_6.PNG







http://hodentekmsss.blogspot.com/2017/02/importing-csv-text-file-into-ms-
access.html
http://hodentekmsss.blogspot.com/2017/02/importing-text-file-into-ms-access.html
http://hodentekmsss.blogspot.com/2017/01/importing-csv-file-into-sapss-sql.html
http://hodentekmsss.blogspot.com/2016/12/report-based-on-text-file-using-power-bi.html