@bobnoordam

Month: January 2020

Sorting and selection with the streams API

The common question: How do i make a selection from an arraylist in a simple way. Answer: use the streams api that has been around since forever. Assume the very simple data class B And let’s put some very simple data in it: Selecting with an arraylist as target Or, using a generic List<> to keep your options more open: Let’s do some simple sorting on a property while at it And reversed for good […]

Recursion revisited: Let’s call it self-calling-code

In the days of Z80 and 6502 programming in low memory systems self modifying code was quite common. Not only was it extremely efficient space and speed wise, it often was the only real way to get things done in systems with nothing but a few kb of memory. Explaining the concept of self modifying code is quite simple, and basically everyone can grasp it in a minute. Enter the dreaded word recursion. When recursion […]

Testing the Ajax Control Toolkit Tab control with WatiN

The Ajax Control Toolkit offers a large amount op ASP.NET Ajax control, and can be found on codeplex. WatiN is a popular test framework for UI testing ASP.NET web applications. Both can be obtained from the linked site, or can easily be added in Visual Studio with nuget. The objective of this writeup is to use WatiN to start an IE session, fire up a local website with the tab control on it, and proceed […]

Establishing display and game window size

Sample XNA code to establish a fixed size windowed view public Game1() { graphics = new GraphicsDeviceManager(this); // Determine the resolution of the screen int maxwidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; int maxheight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; // Set the game window to 90% of the avaiable resolution _windowWidth = (int) (0.9*maxwidth); _windowHeight = (int) (0.9*maxheight); graphics.PreferredBackBufferWidth = _windowWidth; graphics.PreferredBackBufferHeight = _windowHeight; // Block window size Window.AllowUserResizing = false; Content.RootDirectory = “Content”; } Alternatively, you can allow user resizing and […]

Backup and restore a MySQL Database from the command line

Creating a backup from the command line on the source server mysqldump -h localhost -u username -p database_name > backup_db.sql Restoring this backup to an existing, empty database on the target server mysql -u username -p database_name < backup_db.sql When scheduling your backup with a batchfile you can use a simple trick to include a day stamp, something like below will producte a different backup file for erach day the script is run: md \dbbackup\mysql […]

Change network type for VPN Connections (Windows)

So you just created a brand new VPN connection to let’s say work, and Windows decided that it is a completely untrusted network connection, setting it to a public network. Here is how you can quickly and immediately change the network type using powershell. Start an elevated powershell prompt Use the following command to list the known networks:Get-NetConnectionProfile This will net you something like below. Note that the VPN in this example is named “IPSEC”, […]

Upgrade debian jessie to stretch

Check if you are using obsolete packages aptitude search ‘~o’If this gives you output you will have to take into account that these packages are no longer in a standard repo since they were removed. Perform a full backup – does that realy need stating ? warningUpgrading debian from 8 to 9 will replace mysql with mariadb, which will also automatically upgrade your databases. If you get stuck somewhere in the upgrade process you cannot […]

Writing a context menu outlook addin

There is a sizable amount of documentation around about writing outlook addins, but few complete samples that cover the basics, and only the basic. Documentation snippets are great to get started, full blown applications are good if you dig around in addins daily. This snippet covers the middle ground: It is (the) complete framework you need to add an item to the context menu in outlook and start a processing action on it after perfoming […]

Configuring VPN Access with Server 2012

This document demonstrates how to configure PPTP remote VPN Access on server 2012 using the routing and remote access component. If you have a router or other hardware supplying firewall services and the server that will provide the VPN access is not directly attached to the internet (a good thing) – you will need to configure it to pass port 1723 TCP and 47GRE to the remote access server. Some routers will automatically do “the […]

Next Page »