Start

We bouwen en vliegen met de hele familie.

Mijn vader is een “poosje” 🙂 geleden (begin 80-er jaren) begonnen met balsa vliegtuigen bij een bouw- en vliegclub (BVL) ergens tussen Oud-Gastel en Moerstraten. De club is daarna verhuisd naar een plekje in de polder bij Kruisland.

Ik en mijn broer gingen ook regelmatig mee. Wij waren toen nog te jong om zelf te mogen en kunnen vliegen.

Later hebben we met zijn drieën het vliegen opnieuw opgepakt en zijn we lid geworden van een vliegclub in Rilland Bath (Alouette). Dit laatste vliegveld was een heel eind bij ons uit de buurt. Hierdoor was dat op de lange duur niet praktisch.

Sinds 2015 zijn we overgestapt op elektrische motorvliegtuigmodellen. Mijn neefje heeft ook de smaak te pakken gekregen en vliegt nu met ons mee.

How to select duplicate values in a SQL table

First make a selection of duplicate values using count:
SELECT
col1, COUNT(col1) AS CountOf
FROM test
GROUP BY col1
HAVING COUNT(col1)>1

Then join this selection with the table on table keys:

select [key],a.col1 from
test a
inner join (SELECT
col1, COUNT(col1) AS CountOf
FROM test
GROUP BY col1
HAVING COUNT(col1)>1) b on a.col1 = b.col1

Samsung account problemen na wijzigen wachtwoord

Foutmelding ‘VERWERKEN MISLUKT’ op mijn Samsung telefoon:

Omdat ik meerdere malen contact met Samsung support moest zoeken en uiteindelijk naar een servicepunt voor herstel werd gestuurd TERWIJL DIT NIET NODIG IS, schrijf ik dit artikel zodat hiermee hopelijk andere mensen geholpen zijn.

ALLEEN UITSCHAKELEN WIFI was al voldoende.

Vanaf het begin: Het hele verhaal begon bij het wijzigen van het wachtwoord van mijn Samsung account welke ik gebruik op mijn telefoon.

Mijn Samsung telefoon gaf bij het invoeren van het gewijzigde wachtwoord alleen de melding ‘VERWERKEN MISLUKT’. Dit had ik gegoogeld en hier kwamen allerlei verontrustende resultaten naar voren dat de telefoon naar fabrieksinstellingen gereset zou moeten worden.

Ik vond dit nogal zot dus daarom heb ik maar de support lijn gebeld van Samsung. Eerst een 088 nummer gebeld, daar het probleem uitgelegd. De medewerkster zei meteen dat de telefoon naar fabrieksinstellingen teruggezet gaat moeten worden. Ik nogmaals gezegd dat mijn telefoon verder wel bruikbaar was maar dat alleen geen verbinding met Samsung services mogelijk was vanaf mijn telefoon. Via de browser lukte het mijn wel om in te loggen.

Na nogmaals protest gaf de vriendelijke mevrouw mij het nummer van account services van Samsung. Het nummer van account services gebeld en hier nogmaals uitgelegd wat er scheelde. Ze zouden mij een link via email sturen om mijn wachtwoord te resetten. Dit zou volgens de medewerker kunnen helpen, maar het kon enkele minuten duren voor de mail was aangekomen. In de mail zou ook staan hoe verder te handelen indien de reset van het wachtwoord niet zou helpen.

Na een kwartier wachten had ik nog geen mail ontvangen. Hierna nogmaals gebeld om te vragen om hulp. Terwijl ik nog aan de telefoon was werd de mail wel verstuurd maar mocht het resetten niet helpen. De mevrouw vertelde dat het enige dat nu overbleef als oplossing om bij een servicepunt van Samsung langs te gaan of om zelf een logbestand te laten bouwen door de telefoon en dit op te sturen. Ik vroeg waar een servicepunt was maar toen vertelde ze me dat ik voor deze informatie het 088 nummer weer moest bellen. Bedankt voor de service en zelf nog even aan het zoeken gegaan…

Conclusie: Het netwerk waarmee ik probeerde in te loggen zorgde voor de fout. Ik heb WIFI uitgeschakeld en alle problemen waren opgelost.

Where does Windows save Lock screen images

If you are using Windows 10 you might want to save the lock screen images as a background or just because you like them.

The images can be found in this folder:
C:\Users\%userprofile%\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets

Select all and copy these files to a new folder where you want to keep / edit them.

The files in this new folder have to be renamed to .jpg to use them with a image viewer / editor. You can do this by starting a command line window and make the folder you created as the current directory. Then execute “ren *.* *.jpg” from this command line window.

Git merge branche Development into master

Today the standard source control with Visual Studio is GIT. This source control has a lot of powerful features and options.

For me it took some investigation, testing and searching the internet on how to best merge a development branch (or a bugfix branch, etc.) into the main (master) branch.

git checkout master
git merge –squash Development
git commit OR git commit -m “This is a merge from branch to branch at moment x”

What these commands will do is compact all commits to the development branch and add them to the master in one separate commit.

ATTENTION: When you check the source tree you will also notice that there is NO “merge branch” line.

Next I have added an extra branch, commit a change. Last action was to merge the branch using “git merge HotfixOnMaster”:

After merging a complete branch without squashing. Every commit remains in the master history:

Alternative found on makandracards.com:
Squash several Git commits into a single commit
This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as one pretty commit.

git checkout master # Switch to the master branch and make sure you are up to date.
 git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
 git pull
 git merge feature_branch # Merge the feature branch into the master branch.
 git reset origin/master # Reset the master branch to origin's state. Git now considers all changes as unstaged changes. We can add these changes as one commit. Adding, will also add untracked files.
 git add --all
 git commit

Note that this is not touching the feature branch at all. If you would merge the feature branch into the master again at a later stage all of its commits would reappear in the log.
https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit

Report progress in a task in C sharp

One of my first questions starting programming in Visual Studio WPF was how to run processes without freezing the GUI.

After learning the basic concepts of backgroundworkers and tasks in c sharp programming I wanted to know how to report task progress while the task was not yet finished.

I found all kind of solutions to update a progress bar. I also found solutions to use the result for a specific task.

Think still missing for me was to get a screen to show task progress, with detailed logging while the task was still running. In the end this article helped me finding a solution: https://social.technet.microsoft.com/wiki/contents/articles/19020.progress-of-a-task-in-c.aspx

To implement this logic in a solution I started with a form on which I added a button and a listbox.

The button got the following implementation:

private async void ButtonAsyncFileProcessing_Click(object sender, RoutedEventArgs e)
{
    var progressIndicator = new Progress<MyTaskProgress>(ReportProgress);
    await MyMethodAsync(progressIndicator);
}

For the progress indicator I added the following class:

public class MyTaskProgress
{
    //current progress
    public int CurrentProgressAmount { get; set; }
    //total progress
    public int TotalProgressAmount { get; set; }
    //some message to pass to the UI of current progress
    public List<string> CurrentProgressLogging { get; set; }
}

The async method I used for testing was this:

async Task MyMethodAsync(IProgress<MyTaskProgress> progress)
{
    int sleepTime = 1000;
    int totalAmount = 10000;
    List<string> log = new List<string>();

    for (int i = 0; i <= totalAmount;)
    {
        await Task.Delay(sleepTime);
        log.Add(string.Format("On {0} Message", i));
        progress.Report(new MyTaskProgress
            {
                CurrentProgressAmount = i, TotalProgressAmount = totalAmount, CurrentProgressLogging = log });
        i = i + sleepTime;
    }
}

The ReportProgress method used in the button click progressIndicator:

private void ReportProgress(MyTaskProgress progress)
{
UpdateScreen(progress.CurrentProgressLogging,
string.Format("{0} out of {1}",
progress.CurrentProgressAmount,
progress.TotalProgressAmount));
}

And this last method calls a UpdateScreen method:

private void UpdateScreen(List<string> info, string status)
{
    lbOutput.Items.Clear();
    foreach (string s in info)
    {
        lbOutput.Items.Add(s);
    }
    buttonAsyncFileProcessing.Content = "AsyncFileProcessing" +
    "\n" + status;
}

The article that helped me understanding Tasks and backgroundworkers is: https://blog.stephencleary.com/2013/05/taskrun-vs-backgroundworker-intro.html

Change settings for eventlog in Service installer

I was developing a Windows service. Everything went smooth until I was asked to add logging for the service into a separate log file in the event viewer. I want to share my journey with you so it may help finding a solution for similar or the same issue.

After I had learned to install a service using a service installer, I ran into some troubles configuring the event viewer. My service had three logging options. First is to a text file on disk, second is to the Windows Event Viewer and I added an extra option to send a message to a messaging app. All service issues where logging fine. As a last option I was asked to log to a separate log in the event viewer like this:

First I tried adding all kind of options to my logging library to check, add and change the logging destination. That didn’t work and I found that the log needed to be set during initial installation of the service. Reason that previous attempts failed was that when changing these settings, the application needs admin privileges and changing logging options afterwards needed the machine to be rebooted etc.

I searched the internet for a solution and after a couple o hours I stumbled upon this article: https://stackoverflow.com/questions/115488/what-is-the-most-reliable-way-to-create-a-custom-event-log-and-event-source-duri

The post of Simon Mattes in this article helped me out. I altered the code a bit for my own use:

public ProjectInstaller()
{
InitializeComponent();
//Skip through all ServiceInstallers.
foreach (ServiceInstaller ThisInstaller in Installers.OfType())
{
//Find the first default EventLogInstaller.
EventLogInstaller ThisLogInstaller = ThisInstaller.Installers.OfType().FirstOrDefault();
if (ThisLogInstaller != null)
{
//Modify the used log from "Application" to the same name as the source name.
//This creates a source in the "Applications and Services log" which separates your service logs from the default application log.
ThisLogInstaller.Log = "TestApplication"; //ThisLogInstaller.Log = ThisLogInstaller.Source;
ThisLogInstaller.Source = "TestSource";
}
}
}

Check out this post on adding an installer to your application: http://kannekens.nl/registering-installing-a-windows-service-part-2/


Registering / installing a Windows service part 2

In this article I want to describe an easy way to add an easy installer to a Windows Service project.

Steps are: – Add the installer for the service
– Configure the service parameters
– Add parameters to start up of the program


Add the installer for the service can be done when you open the service.cs. This will show a gray screen with two links:

Right click this screen and select Add installer in the pop up menu. This will add a ProjectInstaller.cs file with a ProjectInstaller class inside.

Open the Projectinstaller file. This will show two components.

Change settings for the two components according to your needs.

Last step is to add the installer to the program start up. For this we need to change the Program.cs.

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main(string[] args)
    {
        if (args.Length > 0)
        {
            //Install service
            if (args[0].Trim().ToLower() == "/i")
            {
                System.Configuration.Install.ManagedInstallerClass.InstallHelper(
        new string[] { "/i", Assembly.GetExecutingAssembly().Location });
            }

            //Uninstall service                 
            else if (args[0].Trim().ToLower() == "/u")
            {
                System.Configuration.Install.ManagedInstallerClass.InstallHelper(
        new string[] { "/u", Assembly.GetExecutingAssembly().Location });
            }
        }
        else
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
            new ServiceMonitor()
            };
            ServiceBase.Run(ServicesToRun);
        }
    }
}