Using the PostgreSQL array type with Dapper

PostgreSQL has some fancy types like the array type. But its not obvious how to return e.g. an int[] or an uuid[] in a single row from Dapper. In fact the first hit on StackOverflow said it was impossible. Not so… with a little insight, luck and duct tape you can do anything. It’s actually quite easy. If you use Dapper and NpgSql “out of the box” you will get an error “Invalid type owner for DynamicMethod” if you go for an array in your select like this:

Using VS Code to develop Phaser 3 games in TypeScript on WSL2

Phaser 3 is a great javascript game engine for developing browser games. As far as I understand the new versions follow the general trend and is generally developed in typescript. However it does not automatically follow that its easy for game developers to setup their own environments to develop their Phaser games in typescript. For historical reasons (I guess) there is not a lot of guidance to be found online.

QuickVault released

I just released 3 small libraries for configuring secrets in a .NET Core or Full framework app. Its a simple key/value store with encrypted values and it supports .NET Configuration (both Core and Full Framework) Its called QuickVault and consists of a .NET standard base library installed with: Install-Package QuickVault A library for .NET Core configuration: Install-Package QuickVault.Configuration.Core And a library for .NET full framework configuration: Install-Package QuickVault.

Netlify Minify

if you use the service Netlify for a static site you get the option of doing automatic minification of your javascript when the site is deployed. Its as easy as setting a checkbox. I recently used on a site, and to my surprise it did not work (since Netlify usually works like a charm) After doing some back and forth with Netlifys support and trying the advice in this post it still did not work unfortunately.

Stick Figures

Just for fun and to have a little special something for the blog I decided to do some animated GIFs of Stick Figures. So I created a little tool called “StickFigure” (Windows only sorry) designed for making animated Match stick men and other drawings like that. The tool works like this: Plan your animation Draw the key frames Generate in between frames. Generate PNGs Generate JPGs Generate the GIF For a more detailed description see the Readme

Spam in 2018

When I published my blog with the shiny new format this morning, SPAM started flowing in IMMEDIATELY. Less than 10 minutes after I published, the first “Viagra” message was added as a comment. And then it flowed in, in a steady pour, approximately one spam message every 45 minutes. My old blog used Akismet to filter out the worst spam. Unfortunately Akismet does not work well with Staticman yet, instead I decided to try ReCaptcha.

Reviving a blog

It has been 4 years since my last post, and 7 years since I posted regularly. Phew… time flies. The reason has not been a lack of subjects but more that other things were more fun, like making all sorts of games for iPhone, Apple TV, XBox and PC. I could have shared some of the experiences but I was too lazy to update the blogging tech. from the old DasBlog engine to something contemporary.

old
How to use Synology DS213j as a server for Git Repositories

I must admit that I prefer SVN over GIT due to the (in 2014 only slightly inferior) tooling and due to the illogical naming and structuring of commands and parameters. But still GIT has a lot going for it, and I needed the GIT submodule command for a private project of mine i.e. something that I want to sell and therefore not place on github. So away with SVN. On my trusted Synology I have the SVN server installed which was basicly just plug and play.

ancient
Solzip 1.3 for VS2010 released

I finally got around to upgrading and releasing Solzip for VS2010. Solzip is a tool for zipping Visual Studio C# solutions from a right click menu in the solution explorer. You can also Zip individual projects. You can install it from http://solzip.codeplex.com or from the Extension Manager in Visual Studio. You can choose to install a command line version or the Visual Studio version either one that requires MME or a single file install which includes MME.

ancient
Mogade.com an amazing free Leaderboard Service

When making the WP7 game Photo Challenge we quickly agreed that we needed leaderboards. The problem is that is time consuming to build a scalable high quality leaderboard service tailor made for our game and secondly we would have to pay for server storage for a game that statistically won’t make a dime anyway. This meant that we searched for a ready to use leaderboard service. It wasn’t easy to find.

ancient
Photo Challenge Released

I and a team of 1 graphic artist and 1 sound engineer just finished our first game for Windows Phone 7 called “Photo Challenge” a few weeks ago. We planned this pretty simple game to get experience before going for the big hit. The concept has been seen before. A Puzzle Slider where you have to solve a square puzzle with 2x2, 3x3, 4x4, 5x5 or 6x6 squares with one square missing.

ancient
How to maintain more than one WMAppManifest.xml files for different versions of your Windows Phone App

When we were to publish a free version of our new Windows Phone Game Photo Challenge I wanted to maintain both the free and paid version in the same Repository. I wanted the solution file and project file for the new free app to use the same source files as the paid app. This gave some headaches because there needs to be a physical WMAppManifest.xml file for each App. I googled various approaches but I finally made up an entirely different approach which I thought fitted our project best.

ancient
Cannot set google as default Search provider IE9

I like the new look and feel of IE9 but it is not without startup problems though. If you want to use Google as your favorite search provider what do you do ? Well lots of places on the web tells you to go to “Internet options” –> Change Search Defaults (Settings) and then press the lower left link “Find more search providers…”. I did this but was perplexed. Google was not listed !

ancient
Guidance Automation 2010 Bug

Guidance Automation 2010 Bug: The imported project “C:\Microsoft.Practices.RecipeFramework.Build.targets” was not found The new Guidance Automation Framework GAX 2010 and GAT 2010 which is installed through the Extension Manager in Visual Studio 2010, provides a nicer usability experience compared to the Visual Studio 2008 predecessor. It is installed using the new vsix installer. A vsix install is much nicer than the old msi install since it integrates into Visual Studio. You can uninstall using the Extension Manager and if a new version comes out it should appear on the Updates tab of the extension manager.

ancient
Right Click menus for Visual Studio 2010

Imagine that you want to make an extension for Visual Studio 2010 that creates new custom right click menus for the Solution Explorer. Imagine that you could do it by just implementing a good old .NET interface like this: public class MenuManager : IMenuManager { public IEnumerable<IMenuItem> GetMenus(ContextLevels menuForLevel) { var menuItems = new List<IMenuItem>(); var menuItem1 = new MenuItem("My Menu1"); menuItems.Add(menuItem1); var menuItem2 = new MenuItem("My Menu2"); menuItems.Add(menuItem2); return menuItems; } public string MainMenu() { return "My Main Menu"; } } Well it turns out you can.

ancient
Click and double click in XNA Games

Click and double click in XNA Games Windows developers who are used to click events in WinForms, WPF or Silverlight might miss click and double click events, but because of the game loop where everything is drawn and updated every few milliseconds an event based approach is probably not a good idea in most cases. Not so much because of the performance of an event based approach, but more because the complexity is overwhelming.

ancient
Fast bulk updates and inserts in Microsoft CRM 4.0

In Microsoft CRM you have no choice when doing updates to the database. You have to use the CRM Web Service. Microsoft does not support direct SQL updates of the underlying SQL Server tables, because of the behind the scenes CRM magic. The Web Service is OK for small amounts of data. But recently I had a case where I had to code an import of a spreadsheet with up to 100.

ancient
API for Sticky Notes in Windows 7

In the Day View project I needed to open a Windows 7 Sticky Note programmatically and write to it. Unfortunately I found out that there is not an API for the Sticky Notes application. At least not a managed one. So I had to fake it and make my own API. I have made a small class that basicly uses Process.Start to open the program, and SendKeys to write to the Note.

ancient
Retro XNA Game Klimakonflikt under development

I am currently developing the game Klimakonflikt with 5 other guys. It is a Retro arcade game, Pac-man style, with nice 2D Graphics and music. Here is a screenshot from the game: The current release, documentation and source code can be downloaded from here http://klimakonflikt.codeplex.com The game is inherently for 2 players but we are working on the single player edition. The AI in the current release is pretty daft, but in the next release it will be much improved.

ancient
Windows 7 Contest finished

Last friday (the 9th) just one day before the deadline I finished my application for the Windows 7 Contest. “DayView” here is the description I made for the contest: “DayView provides an overview of the appointments in all your calendars by a clever use of the Windows 7 Task bar. It shows your appointments, and you can scroll through them with toolbar buttons, and create Sticky Notes for the most important appointments.

ancient
Extremely fast Sudokus of any size programmed in silverlight 3

I must admit that I have never understood why it was fun to solve Sudoku’s. But as a programmer I was fascinated with the idea of making the perfect Sudoku puzzle generator algorithm from the very first time I heard of Sudoku. Of course I wanted to make it so general that it could not only make the boring old 9x9 sudoku. But sodukus of any size 4x4, 9x9, 16x16, 25x25 and so on…

ancient
Version 1.2 of SolZip released

Just released version 1.2 of SolZip my convenient tool for Zipping Visual Studio 2008 solutions The major improvement is a single install for SolZipMME, so you won’t have to install ManagedMenuExtensions beforehand. The release notes are here: Bug Fix: when multiple projects where referering to the same file it was added to the archive multiple times. SolZipMME uses SaveFileDialog instead of FolderBrowserDialog for Zip files. A single file installer for SolZipMME.

ancient
Version 1.1 of SolZip released

I just released version 1.1 of SolZip which can be downloaded from the download page at the SolZip site. The new action packed version contains one major improvement, one bug fix, and a few name changes: Now Source Control bindings for TFS and SCC can be removed from sln and csproj files. The default for all 3 UI’s is that the bindings are removed, but you can optionally choose not to remove them.

ancient
Best practice Dispose Pattern C#

Here is my take on the Best practice Dispose pattern for most situations. It is heavily influenced by Juval Löwy from IDesigns book “Programming .NET Components”, and some other sources which I no longer remember, since I made it a few years ago and have stuck to it ever since. Here it is: public class Class1 : IDisposable { private bool m_IsDisposed; ~Class1() { Dispose(false); }[MethodImpl(MethodImplOptions.Synchronized)] public void Dispose() { Dispose(true); GC.

ancient
Compression of Visual Studio Solutions and Projects made easy

I just released a new codeplex project SolutionZipper which makes it a breeze to zip compress your visual studio solutions and projects. “What’s wrong with WinZip you might Ask”. Well WinZip has no knowledge of Visual Studio Solutions, which means it will compress everything in the folder, including bin / obj folders and other random debris. I accomplish the compression by using the following algorithm: Iterate over all items and projects in the sln file and zip each of these.

ancient
How to get EnvDTE.Project information when the project is contained in a Solution Folder in Visual Studio

I was using my codeplex project ManagedMenuExtensions recently when I realized that it threw an Exception, when clicking on a menu attached to a C# project under a solution folder. The reason was that the object which normally contained an EnvDTE.Project when a project was clicked contained null, when this project was contained in a solution folder. I normally use this code to get at the selected project (m_VSStudio is the DTE object of the current solution):

ancient
How to repair GreatNews database

My favourite RSS reader is GreatNews. First of all it is a standalone application, and secondly it is portable, which means I can install it on a USB key or better yet in my Dropbox which is what I do. Well to be fair it is not portable in the purist way because it caches some stuff on the computers harddrive, but that is only for performance, so functionally GreatNews IS portable.

ancient
Execute method for Linq

If you want to Execute something on each element of the result of a Linq expression. You can either loop over the result using foreach(…) or turn the result into a List using .ToList(), and then use .Foreach(…) on the resulting list. Like this: (from excep in ErrorList where excep is ArgumentException select excep) .ToList().ForEach(e => Console.WriteLine(e.Message)); This is ugly, and I prefer to make my own Extension method for IEnumerable<T> called Execute(.

ancient
Best practice use of the var keyword in C#

I recently was in a company where I created the coding standard. Mostly by referring to the great standard from IDesign but with a twist of company specific things. When C#3.0 came out I couldn’t find any coding standard material on the new stuff out there on the web. So I was forced to think… My thoughts on the var keyword, is that it should be used extensively. But I place a restriction on it.

ancient
The Missing Linq / What is Linq really ?

What is Linq ? You probably think you know the answer, Linq is after all already quite dated. Well in my experience chances are you only know part of the story. Most of the people I have met have a slight misconception of Linq which limits their use of this great technology. Let me explain. Linq of course means “Language Integrated Query”, we all knew that. This basically refers to the syntactic sugar that Microsoft has poured over the C#3.

ancient
Windows Explorer, WebDav and Sysinternals

Any windows user is familiar with Windows Explorer but were you aware that one can access an ftp site or WebDAV enabled site using the Windows Explorer ? I myself haven’t really been looking in to this, since I have been using Filezilla to upload files to my website, but why not use Windows Explorer ? It is always at hand with the Windows+E keystroke. As an example I will show you have to access the http://live.

ancient
Debugging huge legacy systems

Currently I am looking into taking over a huge enterprise legacy system written mostly in C#, but also some C++. The numbers are staggering several million lines of code, 1200 GUI screen, mostly WinForms, about 750 C# projects, 150 solution files, just to mention a few. In all about 4 times larger than the largest enterprise system I have previously been working on. Just building and deploying the system is a pretty big task since due to events beyond my control I basicly only have the sourcecode and nothing else.

ancient
Syntax highlighting in this blog

When I post code blocks in this blog. It would be nice if they look like, well, code. So I looked at what Scott Hanselman had done, he is after all one of the creators of the blogengine I use: “Dasblog” In this post Scott explains how to do it. He explains how to add Javascript from a project called SyntaxHighlighter and use a plugin called precode for Windows Live Writer.

ancient
The Purpose of this Blog

This is the first post of my new blog. Hope you will like it. My plan is to blog about my favourite topic - .NET and other more or less related technologies. I hope to post regularly but I will keep my ambitions low and plan only to post once every month ! Perhaps with a larger more in-depth blog post every second month. This is not for lack of subjects, but because I know myself.