Python: Getting started with Python

Intention

Since JAVA has been overtaken by Oracle, it can’t be mistaken to get skilled with the basic concepts of Python. So this is my short Getting Started tutorial with my personal conclusion.

Instead of getting annoyed about the glorification of Python, it would be better to spend some time to have a short look at this programming framework.

In the most cases a language itself is not the crucial point, but it’s what it’s framework is providing for the developer.

So the most popular thing we hear about is the capabiliy that Python is good for…

  • Data Science
  • Arteficial Intelligence (especially the library Tensor flow)

Installation

To install Python, you have to go to https://www.python.org/downloads/ and download and install Python. The website is clearly arranged and you don’t have to spend much time to search for the correct runtime according to your needs.

After you have downloaded Python, a installation wizard guides you through the installation process in two steps. It catches to my eye that there are not so much options to choose except for the folder where you want to install it.

Getting started

So what do we need now… a development environment? Hmm… well because I have installed a Visual Studio 2013, i want to test the free „Python support for Visual Studio 2013), which can be found for different Visual Studio versions here:

https://github.com/Microsoft/PTVS/releases/v2.2.2

Python Tools for Visual Studio 2013 can be downloaded from GitHub

After the installation, there is a new Project Type available, when choosing

Visual Studio 2013 menu: File –> New Project

A new Python menu appears on the left side and we can choose to create a console application

After that you can immediatly start to code Python and press the Start-Button. Here is the „Hello World!“-Program:

A „Hello World!“-Program just consists one command.

What is a little bit weird is, that it doesn’t seems to matter if you use the following Syntax instead of the function-based print:

# This Python comment is like a UNIX Shellscript comment
print "Hello world!" # Is it possible to append a comment to the end?

# Is this really clean code if it doesn't matter how you write it?
print ("Hello world!") 

# How do you write multi line?
print ("Hello "
"world!") # this works without line break

print "Hello "
"world!" #this not

print """Hello 
 world!""" #this works but shows the line break

# without declarion of a variable
print "Number 1:";
x = input(); # My first Input 
print "Number 2:";
y = input("Here you can enter the input prompt:"); # My next Input 
print """

The result is:
==============
"""

print "The result is " + str(x + y) # working
# Python is not converting 
#automatically like C# when concatenating an Int to a String

print x #works
print y #works
print "A string for x: " + str(x) +"" #working 
print "A string for y: " + y +"" #not working 
#because he thinks that y is an Integer

In console applications it is possible to work simply with input and print. By experimenting a while you can find out what is working and what is not…
An input like „2“ will be automatically converted as an integer type (when it only contains an integer). It is possible to print the integers using the function (or command) „print“, but it is not possible to print an integer concatenated to a string.

My first conclusion

„Wenn Sie Python sehen wollen, dann gehen sie doch ins Dschungelcamp!“

Nico Gerbig in WhatsApp

For non programmers it seems to be really easy to write small console programs, but the language itself allows much syntax variants that i don’t would expect as clear readable code (especially in Python 2.7 what i have been used ).

But as shown in the following Screenshot newer python versions are a little bit more strict concerning procedure-based-programming.

In newer Python versions the BASIC-like command syntax is replaced by a real procedure syntax.

As you can see above, there is a small onboard IDE shipping with python that has a console in which it is possible to execute python code directly. Additionally it allows you to write programs in whole Python files by selecting the „File->New File“ in the menu.

The IDE can be found in the Start menu after installing a
Python package

One thing that makes me muse about the language concept is the missing option for variable declaration. Learing tutorials and guides are always promoting the omission of type-safe variable declaration as innovative concept and benefit in comparison to other common programming languages. I think it would be eligable to ask the question: „Why do non type-safe languages like JavaScript need a type-safe extension like TypeScript?“. Languages like Visual Basic (for applications) have introducted the „option explicit“ command to force the developer to do this … why? 🙂

Next steps

In further steps i want to find out how to point my Visual Studio to the newer Python framework. Python 3.8 is already installed but i do not have the choice to change it in Visual Studio. So i guess there must be a seperate configuration for this.

I am looking forward to evaluate the Tensorflow AI library and what benefit i can get from it.

Veröffentlicht unter Python | Schreib einen Kommentar

C# .NET : Create standard Unit Test Project and run a MsTest Unit Test Project with Standard Visual Studio Integration using Microsoft.VisualStudio.QualityTools.UnitTestFramework

Intention

Testing makes me happy 🙂 …

There are 4 common Unit Test Frameworks available as NuGet-Packages:

  • MsTest (Standard when creating a normal test project under VS2013)
  • MsTest v2
  • NUnit
  • xUnit

This short instruction shows how to set up the integrated standard Unit Test Framework without installing packages.

Approach

  • Right-click solution explorer and choose Add -> New Project
  • Under Visual C# choose Test -> Unit Test Project, change your name and click „ok“ on the lower right
  • Write Assert.isTrue(true); to have a passing test for test 🙂
  • In the Visual Studio 2013 main menu choose „Test -> Window -> Test explorer“ (this is the part i was searching for a while -> How to start the tests)
  • After adding the Test-Explorer choose „Run All“ to run the Unit Test.

Please Note: If you want to test another project with the test project, you have to Add a reference to it by right-clicking references -> Add…

Solution

Testing makes you happy 🙂

Veröffentlicht unter Allgemein | Schreib einen Kommentar

C# .NET: Run C# code in your browser

Problem

C# code shall be executed in the wordpress.

Aproach

https://dotnetfiddle.net can be used to run C# Code.

Solution

Veröffentlicht unter Allgemein | Schreib einen Kommentar

IBM Doors DXL: Call REST Services / REST-Services aufrufen

Problem

Von Doors aus sollen REST Services aufgerufen werden.

REST Services shall be called within a DXL Script in IBM Doors

Approach – Ansatz

Usage of OLE Automization

Solution – Lösung

pragma runLim,0
OleAutoArgs args = create
OleAutoArgs args2 = create
OleAutoObj http = oleCreateAutoObject("WinHttp.WinHttpRequest.5.1")
void sendResult(string commandId, string result) {
	clear(args)
	clear(args2)
	put(args, "POST")
	put(args, "https://my.url.de/commands/" commandId "/result")
	OleAutoArgs args2 = create
	put(args2, result)
	oleMethod(http, "open", args)
	string res = oleMethod(http, "send", args2)
	if(!null(res)){
				print "\n" stringOf(dateAndTime(today)) ": Sending data data Failed"
				print "\n" res
	}
}
Regexp lines = regexp ".*"
bool connected = true
while(connected) {
	clear(args)
	put(args, "GET")
	put(args, "https://my.url.de/nextCommand")
	oleMethod(http, "open", args)
	oleMethod(http, "send")
	int status
	oleGet(http, "status", status)
	connected = status == 200
	string response
	oleGet(http, "responseText", response)
	print "RESPONSE:" response "\n"
	lines response
	string commandId = response[0:end 0]
	string resultUrl = "https://my.urld.de/rest/connections/107030b3-0a046c8d-7c2b9836-edaa752e/commands/" commandId "/result"
	string command = "pragma runLim,0\nstring resultUrl = \"" resultUrl "\"\n" response[end 0+2:]
	sendResult(commandId, eval_(command))
}
Veröffentlicht unter DXL, IBM DOORS | Verschlagwortet mit , , , , , , , | Schreib einen Kommentar

Steinberg Cubase 10 Pro: Akkustisches Feedback bei VariAudio funktioniert nicht

Problem

Das akkustische Feebback bei VariAudio scheint nicht mehr zu funktionieren. Trotz mehrfachem Ein- und Ausschaltens der Monitor/Abhörfunktion oder der Aufnahmefunktion kann kein Feedback wahrgenommen werden.

Ursache

Während des normale Workflow zum Bearbeiten von Projektinhalten wurde versehentlich der Control-Room eingeschaltet. Wenn der Control-Room eingeschaltet wurde kann er auch nicht über den Reiter „Control Room“ in der rechten Leiste deaktiviert werden.

Lösung

Die VST-Verbindungen müssen mit F4 aufgerufen werden und der Reiter „Control Room“ ausgewählt werden. Anschließend wir der Button „Control Room“ deaktiviert. Danach funktioniert das akkustische Feedback von VariAudio wieder.

Veröffentlicht unter Aufnahmetechnik, Musik, Musikproduktion | Verschlagwortet mit , , , , | Schreib einen Kommentar

3 ways to create javascript popup boxes

Problem

Sometimes it is eligible to have a way to easily create a browser prompt / confirm dialog / Textinput without defining a Popup DIV and catch those inputs.

Premise

The code thread will be interrupted and a modal browser window dialog will be shown

Solution

Veröffentlicht unter HTML/CSS, Javascript, Programmierung | Schreib einen Kommentar

IBM Doors DXL: Send email via Doors Client

Problem

Emails should be send via DXL script.

Prerequirements

The Doors Client should have access to a SMTP Server on it’s configured port (normally 25)

Right-click the doors database icon in the database explorer and make the following setttings:

Solution

string smtpServer = getDatabaseMailServer();
string smtpFrom = "Superman";
string smtpFrom2 = getDatabaseMailServerAccount();
string smtpTo = "bjoern.karpenstein@test.com";
string smtpSubject = "test";
string smtpMessage = "this is a test";

print "Mail Server Name: " smtpServer "\n";
print "Mail from account: " smtpFrom2 "\n\n";
bool b = sendEMailNotification(smtpFrom, smtpTo, smtpSubject, smtpMessage);

if (b) {
   print "Message sent\n";
} else {
   print "Could not send message.\n";
}
Veröffentlicht unter DXL, IBM DOORS | Verschlagwortet mit , , , | Schreib einen Kommentar

Microsoft Internet Information Server 7 / IIS 7: File Sharing on the website folder only for authorized people but allow / grant the IIS User / IIS worker process to execute ASP.NET

Problem

The SMB Mount / File Share for the web folders directory should be accessible for the admins but not for unauthorized people 

After setting the File Sharing permissions to that, the web applications shows HTTP error code 500 what means that the Microsoft IIS worker process does not have enough privileges.

Approach

To ensure, that the Microsoft IIS Server worker process has enough privileges to execute ASP.NET in the Directory and to prevent unauthorized access to the SMB Mount of the web application,the following settings should be applied

  • Add the user „Network share“ with Read/Write permissions to the folders directory
  • Configure the Application Pools identity to „Network Service“

Solution

Setting up the IIS web site folder to allow the user „NETWORK SERVICE“ to execute the IIS worker process
  • Connect to the web server via Remote Desktop Connection (RDP)
  • Right-click the folder
  • Select the tab sharing and click on the button „Share“
  • Search for user „Network Service“ and press the add button
  • Set the Permission Level „Read/Write“ to the user „Network Service“
  • Hit the apply button

Set up the application pools identity
  • Open the Microsoft IIS Server Manager
  • Select „Application Pools“ from the left side bar
  • Select the appropriate application / pool entry
  • Select „Set Application Pool Defaults“ from the right side bar
  • Search the Entry „Identity“ and press the „…“ Selector Button on the right side
  • Set the Identity to „Network Service“ to allow that user to execute ASP.NET as default user
Veröffentlicht unter Microsoft IIS Server | Verschlagwortet mit , , , , , | Schreib einen Kommentar

Javascript Implementierung der 2D Color Graphs von Savyon

Hier ist eine Javascript-Implementierung der 2D Color Graphs von Timo Krotzky.

http://www.savyon.de/?cid=codeblog

Veröffentlicht unter HTML/CSS, Javascript | Schreib einen Kommentar

Aufbau und Betrieb eines Informationssicherheitsmanagementsystems (ISMS) für KRITIS-Betreiber

Problem

Alle KRITIS-Betreiber müssen seit 30.6.2019 laut IT-Sicherheitsgesetz alle 2 Jahren dem „Bundesamt für Sicherheit in der Informationstechnik“ die Unbedenklichkeit Ihrer IT Infrastruktur nachweisen. Im Zuge dessen können diese eine prüfende Stelle (interne Revision / externe Beratungsgesellschaft) beauftragen, welche die Maßnahmen des bspw. ISMS auditiert.

Ansatz

Um den Aufbau eines ISMS zu erleichtern bietet sich die folgende Vorgehensweise an:

Veröffentlicht unter Allgemein | Schreib einen Kommentar