Net 5 is finally here! Official announcement.

Let’s test it out by writing the famous Hello word console app.

Getting started

  • Download Visual studio 16.8
  • Create a new .Net core application
  • Open your project settings file and change the target framework to .Net 5 as illustrated below:
Image for post
.Net 5 Console app example
  • Add this code to Program.cs
C#9 Hello world app
  • Now go ahead and run this masterpiece!
  • You can read more about .Net 5 and C#9 here

Easy way to manage python virtual environments.

Pre-requisites

  • Python 3.x or Python 2.7.x
  • pip (Python package installer)

1. Installation

  • Use pip to install pipenv
$ python -m pip install --upgrade pipenv$ pipenv --version  # Verify installation

2. Create a new pipenv project

  • There are multiple ways to create projects using pipenv. Examples:
# i. Creates new project using the latest version of python 2x or 3x$ pipenv --two
$ pipenv --three

# ii. Using a specific python version
$ pipenv --python 3.6.5

# iii. Specify a path where python is installed
$ pipenv --python /path/to/python

3. Manage project dependencies

  • The project dependencies are stored inside the Pipfile
  • Example:
$ pipenv install requests
  • It’s also possible to install dependencies that will be used in the development environment only.
  • Example:
$ pipenv install --dev pytest
Image for post
Example Pipfile

References


A brief comparison of networking modes in Oracle Virtualbox.

NAT

  • NAT(Network Address Translation) mode is the default mode when you spin up a new virtual machine(vm) on virtual box.
  • This mode allows the vm to communicate with the ‘internet’ by using the host machine as a proxy
Image for post
Figure 1: Virtualbox default networking mode
  • Communication to the vm can be made by configuring port forwarding through the vritualbox GUI or a CLI tool such as Vagrant.
# Example (using vagrant):config.vm.network "forwarded_port", guest: 22, host: 2222
  • This means all traffic to port 2222 on the host will be forwarded to port 22 of the vm.

NAT Network

  • Instead of creating a virtual NAT engine for each vm, Virtualbox creates one NAT engine is used for all vms as illustrated…

Example: Say you have an authentication API, that receives a JSON request to register a new user.

How would you log events that occur in the end-to-end new user registration process? Here’s how I would do it:

Image for post
  • The arrows represent the setting on your logger instance
  • For example, if you set the level to DEBUG, you will see all the logs in your logs.
  • If you set it to warn, you will only see warning, error and fatal logs. Assuming you are using a single logging instance(i.e. All logs go to a single log file)

Using multiple loggers

  • If you use multiple logging instances, you can set each logger to have different levels. …

Image for post

Reference: pyinstaller home

Question: How do you go from python myscript.py -verbose to just myscrpt -verbose? Follow along to find out!

Before we begin

  1. Install the required packages
$ pip install --upgrade pyinstaller

2. Add the python scripts folder to the system path if you have not done so already

The basics

  1. Basic usage
$ pyinstaller <your-script>.py# output(s):
# <your-script>.spec - Default settings used to generate exe
# build/ - Build artifacts e.g. build logs
# dist/ - contains <your-script>.exe + python dependencies

2. Useful options

  • — name | Specify the name of the generated executable
  • — onefile | Bundle all binary artifacts into one executable…


This simple guide will show you how you can use pyinstaller and argparse to create a simple console application with python.

Required tools

$ pip install --upgrade psutil
$ pip install --upgrade pyinstaller

Lets try this out by creating a simple console app that will list processes or applications that are currently running on your PC.

  1. Create a python script named proclist.py
proclist.py from github.gist
  • We use psutil.process_iter([‘pid’, ‘name’]) to get a list of all processes running on a machine
  • The argparse ibrary allows the user of our script to specify a limit on the number of processes with print to the console. …


Useful commands you will need when using vagrant

Before we begin: Make sure vagrant is installed in your machine and added to the path. To verify, run vagrant -v and make sure you get a version number of the vagrant version installed on your machine.

Reference: Vagrant Official Docs

TOP 10

  1. vagrant init
  • Initialize a new vagrant environment by creating a new Vagrantfile if it does not already exist.
# Syntax: vagrant init [name [url]]
# name = name of the box to create i.e. config.vm.box
# url = url to download the box from
# Example:
$ vagrant init my-company-box https://boxes/example.box

2. vagrant up

# Syntax: vagrant up [name|id]# name = Name of the box/machine defined in the Vagrantfile
# id = Unique identifier for any known machine found by running vagrant…

WPF DataGrid Control — Provides flexible a way to display collection of data in rows and columns

  • In simple terms a DataGrid is a customizable grid used to display data collections
  • The DataGrid control also provides some useful built in functionalities for data display, i.e.

# Sorting # Grouping # Filtering etc.

This article assumes you have some exposure to WPF and common data display controls such as ListBoxes,ListViews etc.

1. Basic DataGrid — Auto-generated Columns

  • If you only want to display you data collection, the code below is sufficient to get you started. Full source code.
Basic DataGrid from Observable collection
  • By default the DataGrid control will create an appropriate column for each entry in your…

The term control is generally used to refer to any visual element in a WPF application. Technically this can imply that the element inherits the Control class.

  • A WPF application can be defined loosely as a nested grouping of control elements inside layout panels encapsulated by a single root element, i.e. Window or Page
Image for post
A simplified model of a WPF application

Layout Panels

  • As mentioned above, UI elements or controls are arranged inside layout panels which inherit form the Panel class.
  • The most common panels in WPF are:

Grid: Child controls are positioned using rows and columns.

StackPanel: Child controls are stacked along a single axis( x or y).

Canvas: Uses absolute positioning to layout child controls. …


Disclaimer: This is article only covers the C# concepts that are prominent when developing WPF applications. If you are looking for a full C# course, please visit the official Microsoft docs.

This article continues from this article.

2. C#

  • C# is an object oriented based language developed by Microsoft.
  • The main concepts that you need to understand to effectively use WPF are:

2.1. Events & Delegates

  • Delegate — “A reference type that can be used to encapsulate(or point to) a method”
// This delegate can point to any function with a return type of //void and one string argumentpublic delegate void TestDelegate(string arg);// We can instantiate this delegate by assigning it a function with
// the same…

About

Ndamulelo Nemakhavhani

Former Glorified Electrician(aka Electrical Engineer). Now a Software Developer working on complex Enterprise Software. Lets connect on twitter @NdamuleloNemakh

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store