23 July, 2014

Brushing up on PowerShell

Over the last couple of days, I have been working with PowerShell on a project. My usage of PowerShell in the past has been mostly for one off tasks or for a tasks that I need to get done really quickly so I can move on to the next. My current project caused me to think about PowerShell as a tool for creating re-usable scripts.

To load additional modules and snap-ins use the commands:
 Import-Module  
and
 Add-PSSnapIn  
.
If you try to load the same snap-in more in the same session an error occurs. One way around is to ignore the error.
 Add-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue  

Great care must be taken when using variables. A simple typo can lead to a lot of confusion. It is also worthwhile to read up on variable scope.
 help about_scope  

PowerShell allows you to create methods or functions within a script. The basic syntax is
 function  { script block }  

A quick example of creating a function to add two numbers together and calling the function.
 function Add ([int] $x, [int] $y) {   
   $results = $x + $y;  
   Write-Host "Results $results";  
 }  
 Add 3 4  

In the above example, I am doing a few small things that are more personal preference than anything else. There are multiple ways to create parameters. I like to create parameters on the same line as the function name. I also like to add the datatypes. This just gives a me a bit of clue as to what the function would like to have for data. I am also using semi-colons at the end of each line. This comes from my history of working with C, C++, Java, JavaScript, and C#.

You will notice in calling the function, "Add 3 4", parameter are separated by spaces.

Single line comments start with the # sign.
 #A simple one line comment  

Block comments are encased in <# #>
 <#  
 This is a multiple line comment  
 or block comment  
 #>  

Accessing the help system within PowerShell is straight-forward. There are multiple key words that can be used.
 Get-Help  
,
 Help  
, or
 Man  

Calling the help system on the cmdlet Get-Content.
 man Get-Content  

The help system also comes with a set of switches for showing the full listing.
 man Get-Content -full  




18 July, 2014

C++ header file location

This morning I was working a tutorial on openFrameworks. The tutorial called for the creation of a new class. I was a bit careless in the creation of the files. The files were created outside of the src folder. I used Visual Studio 2012 (VS) to move the files to correct location. When I went to use the new class in the code, VS could not find the files. VS did not move the file on the hard drive. I had to manually move the files myself.

Today's lesson is that I must be careful when creating new class files (.h and .cpp) to make sure there are created in the correct location. The other lesson is when moving source files around it is worth checking to make sure the files are moved on the hard drive.


17 July, 2014

openFrameworks - Notes on Getting Started

The other day, I learned of the existence of openFrameworks. According to the openFrameworks website, openFramework is a "toolkit designed to assist the creative process by providing a simple and intuitive framework for experimentation." openFrameworks runs on multiple platforms (Windows, Mac OS X, Linux, iOS, and Android).

I am learning and work with openFrameworks for a few reasons. I would like to increase my knowledge of C++. I am hoping that the libraries that are included with openFrameworks will take some of the pain out of learning C++. My next reason for learning openFrameworks is gain experience outside of business programming. I make my living by writing code for businesses.

Steps

1.) Download the framework (v0.8.3) - http://openframeworks.cc/download/.
2.) Unzip the files. I choose to put the files at c:\openFrameworks.
3.) Create the first solution.
3a.) Run projectGenerator.exe
3b.) Change the value of Name field
3c.) Accept the default path. Older versions of the openFramework relied on relative paths to find libraries. I choose not to risk change the location for my first project.
3d.) Leave the Addon alone for now. I am looking forward to playing and experimenting in the near future.
3e.) Click 'Generate Project'. Watch the screen carefully. The process runs very quickly and it is easy to miss the done message.
4.) Open the project with Visual Studio 2012. I learned this the hard way. I was unsuccessful with building the project in VS2013. Additional research is needed to figure out why.
5.) Run the project. The first build takes a while to compile all the parts. Once it is done, you should see a gray window.

The next step is now to start working my way through the tutorials.

Challenging myself to learn something new

I have recently set a big challenge for myself. I want to know about Machine Learning . To add to the challenge, I am trying out usin...