Tag: code

Judge at the Nutanix Coding Challenge

Nutanix just announced the PowerShell Coding Challenge for your Nutanix environment. The challenge will be to build a script which solves a real world problem in these use cases: Provisioning/orchestration, reporting, data protection, disaster recovery and runbook automation.

Do you have what it takes to write the best script for a Nutanix environment? Find out by participating in the inaugural Total Recode challenge. This global contest gives you a platform for showcasing your best talent. May the most creative, badass coding guru win!

Want to get more familiar with the Nutanix product and test your script? Check out the Nutanix Prism APIs and our recently announced Community Edition software.

Nutanix Coding Challenge Prizes

You can win great prices:

  • Best Overall
    DJ1 Inspire 1 Drone (Valued up
    to $4000) or $4000 cash prize
  • Most Impactful
    Home Lab ($2,500 value)
    or $2,500 cash prize
  • Most Creative
    $2000 cash prize

And I am proud the be a judge in this contest with other great minds:

 

Nutanix Coding Challenge Judges

If you want to know more or join the challenge, check out the Nutantix Coding Challenge: Total Recode website.



SVN Basic

subversionA colleague made a pretty cool blog post about svn basic on his blog. Subverion is a software versioning and a revision control system. At work all our program code and scripts, every little piece of code is going in your Subversion repository. This allows you to get back to earlier revisions of the code or simply share and work on code with other employees. Even your documentation is going into the Subversion repository.

On his blog post (German) he shows the basics of subversion, doing a checkout of e repository, adding files, changing files, removing files and more.

Here is a basic list of svn commands, if you need more information you should check the Subversion Homepage or try the Blog post from tspycher.com

svn checkout  http://svn.colab.company.com # SVN checkout
svn commit -m "My Message and Changes" # SVN committing changes and new files
svn add /files/*.* # Adding Files to the SVN Repository after this you have to commit that
svn update # Update your local copy

A lot of IDE’s (Integrated Development Environment) like Visual Studio or Xcode have SVN integrated.



Simple C++ lottery program @KTSI

Here is a simple C++ lottery program done for the KTSI.

#include <iostream>
#include <cstdlib>
 
using namespace std;
 
int main (int argc, char * const argv[]) {
 
	int numberCount;
	int maxNumbers;
 
	cout << "Lottery Game" << endl << "=================================" << endl;
	cout << "How many Lottery Numbers = ";
	cin >> numberCount;
	cout << "from 1 to ? ";
	cin >> maxNumbers;
	cout << "You have chosen " << numberCount << " Lottery Numbers from 1 to " << maxNumbers << endl;
 
	int lotteryNumbers[numberCount];
	int i, j;
	bool newNumber;
 
	srand(0);
	for(i=0; i<numberCount; i++) // get numbers
	{
		do  
		{   // Check Random
			lotteryNumbers[i] = rand() % maxNumbers + 1;
			newNumber = true;
			for (j=0; j<i; j++)
			{  
				if (lotteryNumbers[j]==lotteryNumbers[i])
				{ // Check for existing numbers
					newNumber = false;
				}
			}
		} while (!newNumber);
	}
	for (i=0; i<numberCount; i++)
	{
		cout << lotteryNumbers[i] << " ";
	}
	cout << endl;
}


PowerShell

PowerShell: Count your Code lines

After Coding some lines in a lot of different files you wanna know how much lines you have coded. There are two (I am sure there are even more) ways to do that. The first one is to get the content of the files (Get-Content) and count the lines in there. With the Select-String cmdlet, you can count your code lines in a file or script using PowerShell.

The other way and the faster way is with Select-String:

(Get-ChildItem -Include *.ps1 -Recurse | Select-String -pattern .).Count

You can find more about Select-String on Microsoft Docs.

I hope this gives you an idea how you can count your lines of codes in PowerShell. Also have a look at at my blog post about how to install PowerShell 6 and PowerShell 7. If you have question, let me know in the comments.



Powershell Header

Powershell: if Statement basics

The if Statement is pretty important if you are creating PowerShell scripts. So I created this post to get some basic information here.

First, the syntax with a simple if:

if (condition) {do}

You can also use elseif and else:

if (condition) {do}
elseif (condition) {do}
else {do}

A simple if could look like this:


if ($varibale -eq "1") {
Write-Host "Yes variable is 1"
}

Comparison Operators:

  • Equal to: -eq
  • Less than: -lt
  • Greater than: -gt
  • Greater than or Eqaul to: -ge
  • Less than or equal to: -le
  • Not equal to: -ne

You can also check case-sensitive by adding a “c” to the operator. “-eq” would be “-ceq

Logical Operators:

  • Not -not
  • Not !
  • And -and
  • Or -or

So you can simply add multiple conditions:


if ($varibale -eq "1" -or $varibale -eq "2") {
Write-Host "Varibale is 1 or 2"
}