The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘Conferences’ Category

InitialKeyboardIndicators registry setting to fix NumLock in a certain state.

Posted by jpluimers on 2016/09/30

There are odd things with the InitialKeyboardIndicators registry setting. Technet only documents bitflag value 2.

According to the docs it should be a bitflag, but sometimes you encounter InitialKeyboardIndicators value 2147483648 (0x80000000) especially as part of the .DEFAULT profile at HKEY_USERS\.DEFAULT\Control Panel\Keyboard.

The problem I had was having these symptoms:

  1. while logging in locally, I manually turned of the NumLock (as I have a 46W6740 UltraNav keyboard without a numeric keypad)
  2. after logging in locally, it magically turned itself on even with InitialKeyboardIndicators=0 in my local profile at HKEY_CURRENT_USER\Control Panel\Keyboard.
  3. after logging in locally and turning it off, future local logons would keep it off
  4. after logging in remotely, it would magically turn itself on while logged in
  5. after having logged in remotely, the local logon console would have it turned on again

After reading Num Lock problem: Strange number in InitialKeyboardIndicators in Registry, I set both values to 0.

Now that it is 0 in both at HKEY_USERS\.DEFAULT\Control Panel\Keyboard and HKEY_CURRENT_USER\Control Panel\Keyboard, symptoms 4-5 still hold. Strange.

It is not the same problem as Num Lock state not retained after resume from Hybrid Shutdown in Windows 8 and Windows Server 2012.

If it persist, I might just put a script in: [Partially Solved: re-wired keyboard lol] Registry key “InitialKeyboardIndicators” NEVER keeps NumLock ON + ScrollLock ON (6) at startup and reverts back to NumLock ON (2).

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Event, Keyboards and Keyboard Shortcuts, KVM keyboard/video/mouse, Power User, ThinkPad, UltraNav keyboards, Windows | Leave a Comment »

Happy “Day of the Programmer”

Posted by jpluimers on 2016/09/12

Happy debugging, suckers

Happy debugging, suckers

Or maybe not…

(yes, this year it’s not on the 13th of September, but the 12th, guess why…)

--jeroen

via: Day of the Programmer – Wikipedia, the free encyclopedia

PS: The oldest reference I could find for define true (rand() > 10) was this one from 20121014:

// Happy debugging, suckers
# define true (rand() > 10)

Source: codecrap.com – snippet #6

It reminds me of a 1990s prank I once put in central consts unit of a Turbo Pascal project somewhere way beyond the right margin in a search directory outside of version control:

                                                                                     const True = False; False = not True;

A lot more pranks are at Happy debugging, suckers : ProgrammerHumor – reddit

Posted in Conference Topics, Conferences, Development, Event, Fun, Prank, Software Development | Leave a Comment »

C#, XSD.exe, xsd2code and generating nullable fields+properties from an XSD with and without Specified fields/properties

Posted by jpluimers on 2016/07/27

It comes down to these cases for XML elements having maxOccurs="1" (which the default for maxOccurs):

  1. adding nillable="true" will convert from a regular type to a nullable type.
  2. adding minOccurs="0" will add boolean …Specified properties in the generated C# for each element.
  3. you can have both nillable="true" and minOccurs="0" in an element which gets you a nullable type and a …Specified property.

Note I’m not considering fixed or default here, nor attributes (that have use instead of minOccurs/maxOccurs, but do not allow for nillable) nor larger values of maxOccurs (which both xsd.exe and xsd2code regard as unbounded).

From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:

  1. an explicit nil in the XML element
  2. the XML element being absent
  3. the XML element being empty.

Hopefully later more text and examples to show how to actually work with this.

Delphi related to minOccurs:

Note that xsd2code.codeplex.com (unlike XmlGen#) has at least two forks at github:

From the specs:

–jeroen

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Conference Topics, Conferences, Development, Event, Software Development, XML, XML/XSD, XSD | Leave a Comment »

Delphi packages I have disabled by prefixing their description with an underscore (and why)

Posted by jpluimers on 2016/07/19

There is a little trick to disable “Known IDE Packages”: you can stop Delphi from loading one by either making “Value data” of the registry blank, or prepending it with an underscore:

packages that might have been disabled, by checking any string entries where the data has been pre-pended with an underscore OR is blank

[WayBackAccess violation at address 00000000 read of address 00000000, when starting the IDE or opening a project after installing the updates

I’ve pre-pended underscores to some packages in the registry key [HKEY_CURRENT_USER\Software\Borland|Codegear|Embarcadero\BDS|Delphi\#.0\Known IDE Packages] and intend to keep the list below updated over time.

Note that you have to prepend the description with an underscore: it is not sufficient to add these to [HKEY_CURRENT_USER\Software\Borland|Codegear|Embarcadero\BDS\#.0\Disabled Packages].

Empirically, the Disabled Packages seem to work only for packages starting with dcl in their filename.

Read the rest of this entry »

Posted in Castalia, Conference Topics, Conferences, Delphi, Delphi XE8, Development, Event, Keyboards and Keyboard Shortcuts, Power User, Software Development | 5 Comments »

Delphi XE8 does not adhere the `$(PROJECTNAME)` in a “Unit Output Directory”, but does recognise `$(SanitizedProjectName)`…

Posted by jpluimers on 2016/05/24

The background here was a quick project at a client where many .dproj files were in the same directory, but they suffered from conditional define differences. Which meant that even if they were all using the  DEBUG configuration, some defines in the .dproj directories were different therefore poisoning shared .DCU files (as Delphi does not automatically rebuild them when the sources have not changed even though the IDE switched to a new project).

There was no quick possibility to reorganise the project structure (a combination of a version system history being problematic and potentially lots of relative path references in the .dproj and .dpr files could still be broken) so I wanted different “Unit Output Directories” for each project preferably using non-hardcoded project name.

So I tried putting $(PROJECTNAME) in a “Unit Output Directory”. But unlike build-events – where that one has a value – in the Directory it hadn’t.

To cut things short, Uwe Raabe did some spelunking in the .dproj file and found that $(SanitizedProjectName) was recognised so I switched to .\$(Platform)\$(Config)\$(SanitizedProjectName).

Putting it in the OutputDirectory (where your .EXE gets emited) fails for most part. Yes, the .EXE gets put in the right directory. No, the debugger cannot find it as it thinks it needs to use %SanitizedProjectName%. No for TestInsight: it cannot find the EXE either because of the % expansion.

Based on SanitizedProjectName, I did some more spelunking coming with the below list. Remember though:

Only tested for Win32 applications for Delphi XE8

I assembled the list by doing a quick sed on a Delphi XE8 Win32 .dproj file transforming all XML element names to $() form then running it through a uniq like script. After that I added each of them in a “Unit Output Directory” prepended with .\_\ (well I cheated a bit, I did them in groups separated by a back-slash and went back to single items in case of failures. A kind of ‘binary search’).

Ensure the ones you use, are defined before you use them. For example: the definition of SanitizedProjectName need to be in the .dproj file before actually using SanitizedProjectName.

These expand to empty strings:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Delphi XE8, Development, Event, Software Development | 2 Comments »

RubyMania has reached Delphi – Times helper method implementation for integers – from Asbjørn Heid

Posted by jpluimers on 2016/04/21

The below fragment is one of the favourite kinds of examples in the Ruby world:

5.times { |i| print i, " " }

It uses the times method on Integer and prints:

0 1 2 3 4

There are many implementations of this in other languages, for instance Ruby’s ‘times()’ function in C# | Of Code and Me (which the WordPress.com editor fucked up as it replaced Action<int> with Action which is a totally different thing, so the gist with code is below.

public static class IntExtensions
{
    public static void Times(this int i, Action func)
    {
        for(int j = 0; j < i; j++)
        {
            func(j);
        }
    }
}

Which you use as

5.Times(i => Console.Write(i));

It’s slightly off as it prints:

01234

I know; nitpicking, but this code works (did I ever tell I love .NET fiddle?):

5.Times(i => Console.Write("{0} ", i));

Well, Mason Wheeler encouraged Asbjørn Heid for the below Ruby Mania in Delphi; just read the comments at In C# nearly everything is an object, so when writing a unit test for a string…

Since the WordPress.com editor fucks up TProc<Integer> into TProc and TProc behaves differently from TProc<Integer>, I’ve included a gist link with the actual code below.

program RubyManiaConsoleProject;

uses
  System.SysUtils;

type
  TRubyMania = record helper for ShortInt
    procedure times(const IterBody: TProc);
  end;

procedure TRubyMania.times(const IterBody: TProc);
var
  i: Integer;
begin
  for i := 0 to Self-1 do
    IterBody(i);
end;

begin
  5.times(
    procedure(i: Integer)
    begin
      Write(i, ' ');
    end
  );
end.

It also shows why I hardly use anonymous methods in Delphi: they’re way too verbose.

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Event, Software Development | 1 Comment »

Computer Color is broken: averaging and blurring colors – via Kristian Köhntopp – Google+

Posted by jpluimers on 2016/01/20

When everybody uses (a+b)/2 but should use sqrt((a*a+b*b)/2) or even [Wayback/Archive.is] weigh the RGB parts.

–jeroen

via: Kristian Köhntopp – Google+.

Read the rest of this entry »

Posted in Algorithms, Color (software development), Conference Topics, Conferences, Development, Event, Software Development | Leave a Comment »

Delphi: rolling your own code or (dis)trusting the libraries that ship with Delphi?

Posted by jpluimers on 2015/09/09

Over the two decades I’ve come across a lot of Delphi projects.

All of them have one thing in common: even for functionality available in the Delphi libraries, much of that code was self-written.

You even see this in big libraries that have shipped with Delphi bit not originate from the Delphi team. Take Indy: lots of “roll your own” in it.

I’ve made some thoughts about that, and see these main causes with the points below.

What’s your thought on this?

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Event, QC, Software Development | 1 Comment »

Jon Skeet’s speech “Back to basics” is really a good watch – via Jørn Einar Angeltveit G+

Posted by jpluimers on 2015/07/15

Thanks [Wayback] Jørn Einar Angeltveit for sharing this a while ago:

A session by Jon Skeet and Tony the Pony (which has strong teeth) presented during the Polish DevDay 2013 in Kraków, Poland.

[Wayback] +Jon Skeet’s speech [Wayback] “Back to basics” is really a good watch.

In a funny way, he explains why the simplest fundamentals of computer software text, dates and numbers can cause some real headache for the programmer…

In case you didn’t know: Jon Skeet is “Chuck Norris” on [Wayback] stackoverflow.com:

The subtitle is “the mess we’ve made of our fundamental data types”.

Some of the topics covered:

Read the rest of this entry »

Posted in .NET, C#, Conference Topics, Conferences, Delphi, Development, Encoding, Event, internatiolanization (i18n) and localization (l10), Java, Java Platform, Jon Skeet, Pascal, Scripting, Software Development, Unicode | 2 Comments »

Some links to Delphi Unit Testing history

Posted by jpluimers on 2015/01/29

Unit testing has been here for a long time, and so has Unit Testing in Delphi. Below a summary of historic links together with some notes on how the state of affairs changed over the years.

Charlie Calvert

I’ll start with one of the first large Delphi Unit Testing articles was a paper by Charlie Calvert summarizing the state of the art on Delphi Unit Testing in 2004. It is present in the wayback machine as DUnit Talk and on his elvenware.com site.

Note that the elvenwere.com site is sometimes slow or hard to reach. Since his evangelist days at Borland/CodeGear, Charlie has moved through a few evangelist jobs at Falafel and Microsoft and finally went back to his old profession: being a great teacher – this time at Bellevue Collegeoften using script based languages and cloud computing, with less focus on his web-presence.

Many of his IT books (during his writing period, he wrote both as Charles Calvert and Charlie Calvert) are still relevant though.

DUnit; Juanco Añez Read the rest of this entry »

Posted in Agile, Conference Topics, Conferences, Delphi, Dependency Injection, Design Patterns, Development, Event, FreePascal, History, Inversion of Control / IoC, Pascal, Software Development | 3 Comments »