Posts

Showing posts with the label DevOps

How to containerize applications using Docker

Image
A container is a means of containing everything an application needs to run: binary files, libraries, configurations etc. Running your application within a container makes it highly portable. Deployment of updated software is often made complicated by certain infrastructure challenges such as trying to make applications behave consistently across different hosting environments. Containerization avoids this challenge by providing a standardized environment for the application to run in. A further advantage of containers is that they consume far less resource than other means of isolation, such as virtual machines (VMs). An example of how to create containerized application in Visual Studio Code. 1. Create and open a new working folder with application code Create the app folder and add the main.py file to the folder. Create a simple Flask application in the main.py file that displays some text that is displayed in your browser when you access the application. main.py...

Using Eclipse to create a model view presenter project in Java

Image
Some instructions on how to create a very simple Model View Presenter example in Java in the Eclipse development environment. A reference I found useful, from which I re-use all the code in this post: http://www.dreamincode.net/forums/topic/353210-swing-passive-model-view-presenter-in-5-minutes/ Step 1: Create a new Eclipse project In Eclipse select File > New > Java Project. Give your project a name and select the JRE execution environment. For this example I am using JRE-8: Step 2: Create the Model class Right-click the src folder in your Eclipse project. Select New > Class and name it 'Model': Model.java [code language="java"] public class Model { private String password; public Model() { password = "password"; } public void setPassword(String pass) { password = pass; } public String getPassword() { return password; } } [/code] Step 3:...

How to rename a project folder in Visual Studio

Image
Example folder name ‘PortableMedia’ that I wish to rename to ‘Renishaw.IDT.Powers.PortableMedia’: Step 1: Close the VS solution and nename the folder in source control ‘PortableMedia’ Gets changed to ‘Renishaw.IDT.Powers.PortableMedia’: Re-open the solution. Observe that the renamed project that is now marked as unavailable in the Solution Explorer: Open the Properties pane on that unavailable folder: Just select properties window – you can’t right-click and select properties anymore… Edit the folder and update the path name: (If you have problems doing this then just edit the *.sln file using notepad++ and change the ‘File Path’ property in there) Right click on that unavailable project and try to reload project. This should work now: Remove the old folder in your workspace folder: You might get the following build whinge [code language="txt"] 1>------ Build started: Project: RenishawOnDemand.TestHarness, Configuration: Debug x64 -...

Using SQLite in C# / .NET Environments

Image
A quick how-to guide on setting up and using SQLite in C# / .NET environments. Nothing complicated just instructions on installing SQLite and using its APIs for database creation and querying. Much credit must go to this splendid link on helping me understand SQLite's usage: http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/ Step 1. Create a Visual Studio console application Step 2: Download the SQLite code For programs running in .NET in Visual Studio install as a NuGet package: Select Tools > NuGet Package Manager > Package Manager Console: Enter install-package System.Data.SQLite at the PM prompt: Otherwise all the other SQLite downloads (Windows, Linux etc) are available here: https://www.sqlite.org/download.html Step 3: Implement the SQL APIs for database creation, querying etc Some common SQLite C# commands Create a database file: [code language="csharp"] SQLiteConnection.CreateFile(DatabaseFile...

Getting started with Java in Eclipse

Image
1. Download Eclipse Obtain the installer from the following site: https://eclipse.org/downloads/ and complete the installation: 2. Create a new Eclipse project Open Eclipse and select File > New > Java Project. Give the project a name ('HelloWorld'): Click Next. And then click Finish. 3. Add your Java class Select File > New > Class: Set the Name field to 'HelloWorld' and check the box labelled 'public static void main(String[] args)': Click Finish. So that your project looks like this: 4. Write your code In this example, the proverbial "Hello World" example: [code language="java"] public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } [/code] 5. Build and run your Java project: Select the down arrow next to the Run icon and select Run As > Java Application: Giving the desired "Hello World" console output: ...

Using POSIX threads in Microsoft Visual Studio

Image
Threads can be used to implement parallelism. For UNIX-based systems, a standardized C language threads programming interface has been specified by the IEEE POSIX 1003.1c standard. Implementations that adhere to this standard are referred to as POSIX threads, or Pthreads. Windows does not support pthreads directly, instead the Pthreads-w32 project seeks to provide a portable and open-source wrapper implementation. The first step is to obtain the pthread project from the following ftp site: ftp://sourceware.org/pub/pthreads-win32/ And extract it to a location of your choice: This will be the location of where your project dependencies and additional library files will be located. To demonstrate an example pthreads usage in a Microsoft Visual Studio environment, first create a new Empty Project: Add the main.cpp source file to your empty project and use the following code sample: [code language="cpp"] #include <pthread.h> #include <stdio.h>...

Using OpenGL in Microsoft Visual Studio

Image
Getting started with using OpenGL / freeglut in a Microsoft Visual Studio environment for 32 bit versions. 1. Obtain freeglut Go to the freeglut site to obtain the MSVC package: http://www.transmissionzero.co.uk/software/freeglut-devel/ At the time of writing this demonstration we obtain version 3.0.0 in zip file format: http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MSVC.zip 2. Obtain glew http://sourceforge.net/projects/glew/files/glew/ At the time of writing this demonstration we obtain version 1.13.10 in zip file format: http://sourceforge.net/projects/glew/files/latest/download?source=files 3. Place freeglut and glew in the location of your choice: 4. Create a new empty project in Visual Studio Add your main.cpp source code file. Don't have to put anything in it for the time being: 5. Set the Additional Include Directories Select project properties > C/C++ > General tab > Additional Include Directories. Do thi...