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 August, 2011

.NET SecureString – storing/retreiving passwords and other sensitive data

Posted by jpluimers on 2011/08/31

Let me start that you should store as little sensitive information as possible. But if you do, you should store it in a secure way. That’s why the .NET 2.0 introduced the SecureString class.

I won’t go into detail here, as the links below and the demo source do that much better than I can:

One warning: be very cautious when you convert a SecureString in a regular unsecure array of characters, string, or compare the unsecured content. To quote Fabio Pintos, everytime you do, a little village bursts on fire. When you access it in an insecure way, make sure it is pinned, clear and release the insecure memory as soon as possible.

The problem with a garbage collected environment like .NET is that strings live on the heap, and you can’t deterministically eliminate a string from memory like you could in deterministic environment like Delphi or C/C++.

Have fun with it!

–jeroen

Posted in .NET, C#, Development, Software Development | 2 Comments »

Batch file to get parent directory (not the directory of the batch file, but the parent of that directory)

Posted by jpluimers on 2011/08/30

The problem solved here is two-fold:

  1. The ~dp syntax for getting the directory/path part only works for parameters and loop indexes, not on variables.
    You can work around this by having a 1-iteration for-loop.
  2. The :~ syntax for getting the substring works only for variables, not for parameters and loop indexes.
    You can work around this by assigning to a temporary variable.

Example:

  echo batchfile=%0
  echo full=%~f0
setlocal
::http://stackoverflow.com/questions/636381/what-is-the-best-way-to-do-a-substring-in-a-batch-file
  set Directory=%~dp0
echo Directory=%Directory%
:: strip trailing backslash
  set Directory=%Directory:~0,-1%
echo %Directory%
::  ~dp does not work for regular environment variables:
::  set ParentDirectory=%Directory:~dp%  set ParentDirectory=%Directory:~dp%
::  ~dp only works for batch file parameters and loop indexes
  for %%d in (%Directory%) do set ParentDirectory=%%~dpd
  echo ParentDirectory=%ParentDirectory%
endlocal

This will show:

  1. The directory of the batch file
  2. The directory but without the trailing backslash
  3. The parent directory of the batch file

Hope you can give this some use.

–jeroen

Posted in Batch-Files, Development, Power User, Scripting, Software Development | Leave a Comment »

RDP issue solved itself; research list to see what might be involved

Posted by jpluimers on 2011/08/29

Recently, I got the below message when trying to MSTSC into a RDP targeting a Windows 7 machine having multiple NICs.

—————————
Remote Desktop Connection
—————————
Your computer could not connect to another console session on the remote computer because you already have a console session in progress.
—————————
OK Help
—————————

I was connecting from a WAN. The Windows 7 machine is connected on two different subnets through port forwarding.

The above message was only on one on one WAN connection. When I tried the other, I could connect immediately. After that, I could connect through the other WAN connection as well.

I’m not sure what caused it, but I suspect the port forwarding, though that has worked in the past and now works without any change.

Still a couple of links, just in case it happens again:

Posted in Power User | Leave a Comment »

xs4all ONLY issues with ADSL sync and Fritz!Box 7340

Posted by jpluimers on 2011/08/26

Recently, I had big problems with my Fritz!Box 7340 losing ADSL sync on my xs4all ONLY connection.

The odd thing is: the problems started after it worked well for quite a while.

I had multiple dozens of these reconnects per day, sometimes as few as once every fre hours, but often as many as half a dozen per hour:

11.07.11 05:14:08 IPv6 Internet connection established successfully. Prefix: 12ab:34cd:56ef::/48
11.07.11 05:14:08 IPv6 Internet connection established successfully. IP address: 12ab:34cd:56ef::fe01dc23:ba45:9867
11.07.11 05:14:07 Internet connection established successfully. IP address: 172.31.120.210, DNS server: 194.109.6.66 and
194.109.9.99, Gateway: 194.109.5.205
11.07.11 05:14:01 DSL is available (DSL synchronization exists with 10007/1029 kbit/s).
11.07.11 05:13:47 DSL synchronization starting (training).
11.07.11 05:13:32 Internet connection cleared.
11.07.11 05:13:32 IPv6 Internet connection was cleared; prefix no longer valid.
11.07.11 05:13:32 Internet connection cleared.
11.07.11 05:13:31 DSL not responding (no DSL synchronization).

The xs4all helpdesk didn’t respond on my emails, and Google searches didn’t reveal much.

This is what I tried:

  1. I tried getting the FRITZ.Box_Fon_WLAN_7340.en-de-es-it-fr.99.05.04-19769.image firmware, mentioned in this thread, but could not download it any more.
  2. I also tried to set the DSL settings to “maximum stability” without any improvement, resetting to factory settings, etc.
  3. The router is already very close to the ISRA point (where DSL enters the house), and I tried both with/without splitter with no improvement whatsoever.
  4. Read the steps in this sat4all thread, but found nothing unusual in my hardware and software config.

I didn’t expect any improvement as nothing on my side has changed, and before xs4all ONLY, I ran DSL for more than 10 years with different modems and no problems whatsoever.

Finally, I downgraded to Firmware-Version 99.04.88 from Firmware-Version 99.04.90.

When downgrading, keep this in mind:

  • Fritz! does not keep old firmware versions on-line; you must regularly get the Fritz!Box 7340 part of their ftp site and keep an archive yourself
  • It will reset your router to factory state and not remember any settings
  • It cannot restore your settings if you saved them with a higher firmware version, not even when you save them with a password as the web-interface seems to suggest

Luckily, one of the things that xs4all did well, is keep an archive of firmware versions for the Fritz!Box 7340, including a Firmware-Version 99.04.88.

Perform these steps when downgrading: Read the rest of this entry »

Posted in Fritz!, Fritz!Box, Network-and-equipment, Power User | 1 Comment »

A world without iWords?

Posted by jpluimers on 2011/08/25

With Steve Jobs just having resigned as Apple CEO, will the world soon be without iWords?

Just Pods, Pads, Macs, Books, etc?

I don’t think so.

Though often stylized as hues of grey, Steve Jobs brought a lot of colour to Apple. Not only by himself, but by collecting a circle of really great people around him. His excellent successor already has shown a good track record, and Apple has many talented people to fill the void he leaves.

Steve will be dearly missed, so I wish him all the best (knowing from direct experience how badly sickness can affect your health).

–jeroen

Posted in Opinions | Leave a Comment »

Excel XML Spreadsheet: Styles and formatting

Posted by jpluimers on 2011/08/25

I found some time to continue my series that started with Excel XML Spreadsheet: Date.Type is mandatory :)

This time, it is about Styles and using the styles to format. I’ll limit myself to formatting Columns, but you can equally apply this to individual Cells, Rows, and Tables.

Note that in the below XML listings, I have replaced the angle brackets with { and }, because the WordPress editor will otherwise delete the XML from the sourcecode portions.

First, let’s look at some ss:Styles:

 {Styles}
  {Style ss:ID="Default" ss:Name="Normal"}
   {Alignment ss:Vertical="Bottom"/}
  {/Style}
  {Style ss:ID="s21"}
   {NumberFormat ss:Format="yyyy/mm/dd"/}
  {/Style}
  {Style ss:ID="s22"}
   {NumberFormat ss:Format="yyyy/mm/dd\ h:mm:ss"/}
  {/Style}
  {Style ss:ID="s31"}
   {NumberFormat ss:Format="[ENG][$-409]ddd"/}
  {/Style}
  {Style ss:ID="s32"}
   {NumberFormat ss:Format="[$-F800]dddd\,\ mmmm\ dd\,\ yyyy"/}
  {/Style}
 {/Styles}

Then the usage of the styles in Columns:

   {Column ss:StyleID="s21" ss:Width="53.25"/}
   {Column ss:Index="4" ss:StyleID="s31" ss:Width="89.25"/}
   {Column ss:StyleID="s22" ss:Width="95.25"/}
   {Column ss:StyleID="s32" ss:Width="95.25"/}

First a few remarks about the ss:Styles:

  1. Styles have IDs, which don’t need to be in the form s##, you can use any unique ID for them. Excel uses s## because that’s how the formatting pick-list works.
  2. You specify the formatting as a ss:NumberFormat using the components from the Creating international number formats documentation.
  3. You can add an Excel specific LCID (locale identifier) to a format. Without it, it will use the user’s locale settings.
  4. You can ommit the language hint (like [ENG]) from the formatting.
  5. The Excel LCID is very similar to the LCID Structure using hexadecimal values from the (old now defunct Locale ID Chart and replaced by the new) Microsoft Locale ID Values,  Language Identifier Constants and Strings table or list of Locale IDs Assigned by Microsoft, but with a few twists.
  6. There is a lot of confusion about [$-F800] and [$-F400] which actually behaves as LANG_SYSTEM_DEFAULT (0x0800 in the latter table), where [$-F800] displays the long date and [$-F400] displays the time (as correctly identified in this Openoffice Bugzilla bug report – or the Google cache of it).
  7. Three digit language [$-409] should be extended to 4-digit LCID 0x0409. It will format the cell using that specific language (in this case: English 3-letter weekday abbreviation).

A few remarks about the ss:Columns:

  1. These columns define formatting for column A, D, E and F.
  2. You don’t need to have a definition for every column in your Worksheet.Table, just for the ones that need formatting.
  3. The Column definition is smart: it can be sparse! After each gap, define a column having an ss:Index attribute, then continue defining subsequent columns until you need another gap.
  4. You can ommit the ss:Width attribute: when empty, the column will auto-size

–jeroen

PS: Rob van Gelder posted a nice formula to show nice translations using Excel formatting.

Posted in Development, internatiolanization (i18n) and localization (l10), Software Development, XML, XML/XSD, XSD | Leave a Comment »

#NS #QPark den Haag Laan van NOI begint een #fail te worden

Posted by jpluimers on 2011/08/24

Ik parkeer al een maand of wat mijn auto op de NS Q-Park bij station Den Haag Laan van NOI om van daar met de trein verder te reizen.

Helaas begint het parkeren nu zo langzamerhand een #fail te worden omdat de kaartlezers bij de uitgang en ingang steeds meer en vaker kuren vertonen.

Al sinds een week of 3 doet de kaartlezer bij de uitrit vaak nogal vreemd: meldingen als “alleen contactloos” of “draai uw kaart” (ook na 4 mislukte pogingen met verschillende kaart oriëntaties) zijn aan de orde van de dag, en de medewerkers achter de “help” knop zijn helaas van sterk wisselende kwaliteit.

Wat er bij problemen het uitrijden meestal gebeurt is dit:

  • Ze geven aan dat ze geen betalingen of kortingen kunnen verwerken
  • Ze geven aan dat je het 0900 nummer moet bellen om de zaak met betaling en kortingen te corrigeren
    (maar vergeten aan te geven wanneer op dat 0900 nummer geen afwezigheidsmelding: van 0800 tot 1800, iets wat ook ontbreekt op de kortingskaart)
  • Ze openen de  poort

Betalingen en kortingen kunnen ze echter wel ter plekke verwerken (de customer desk kan dit ook, maar alleen op dezelfde dag, dus alleen als je dezelfde dag binnen de openingstijden belt).

Wat de help medewerkers behoren te doen is het volgende:

  • Vragen naar (NS of andere) kortingskaart
  • Gegevens betalingskaart vragen en opzoeken (bijvoorbeeld laatste 4 cijfers creditcard)
  • Betaling verwerken
  • Poort openen

Inmiddels (ik heb al een aantal medewerkers achter het 0900 nummer gesproken) weet ik dit en kan ik de medewerker achter de help knop correct instrueren.

Gisteren stond er – na 3 weken modderen! – zelfs een medewerker om te checken wat er nu allemaal mis ging.

Dat modderen kost helaas veel tijd: uitrijden levert vaak een wachtrij op van soms wel 20 minuten, en vandaag bij het inrijden ook 10 minuten langer gedaan (en 2 treinen gemist).

Dus: NS en Q-Park: dit kan beter!

–jeroen

PS: Even de Q-Park contactgegevens op een rijtje:

Q-Park

T.a.v. Q-Park Customer Desk
Antwoordnummer 1125
6200 VB Maastricht
telefoon: 0900 – 44 66 880

(op werkdagen tussen 08.00 uur en 18.00 uur, € 0,45 per gesprek)

Posted in Opinions, Power User | Leave a Comment »

Batch file to get TCP/IP info from local LAN

Posted by jpluimers on 2011/08/24

I needed an automated way of inspecting the local LAN.

The batch files below will on IPv4 networks, with thanks to articles from Windows IT Pro and Rob van der Woude for some ideas:

  • find the TCP/IP gateways/netmasks
  • enumerate all the IP addresses on each subnet (assuming the netmask is 255.255.255.0)
  • ping each IP address and get ARP info, and dump that to the console

There are other tools that can do this too (like Angry IP Scanner), and more but the ones I tried could not copy the output to the clipboard.

find local subnets: Read the rest of this entry »

Posted in Batch-Files, CommandLine, Development, Power User, Scripting, Software Development | 4 Comments »

delphi has TTransparentCustomControl in the Controls unit

Posted by jpluimers on 2011/08/23

Wow, I never noticed that Delphi 2006 introduced the TTransparentCustomControl.

I spotted it a while ago from the delphi – Transparent TCustomControl? answer on StackOverflow.

It is not used in the Delphi VCL itself, but a google search reveals that a few people have actually used it, and Steve Trefethen (former member of the VCL team) mentioned it too.

Note that it contains a [WayBack] mouse interception bug that is still open.

–jeroen

Posted in Delphi, Development, QC, Software Development | Leave a Comment »

Foto’s 14e editie van de Katwijkbinse Truckrun – Oranjevereniging Katwijk a/d Rijn

Posted by jpluimers on 2011/08/22

Afgelopen zaterdag was alweer de 14e editie van de Katwijkbinse Truckrun.

Dit geweldige evenement laat mensen met een verstandelijke beperking meerijden in één van de 100 trucks en 3 touring cars door de bollenstreek.

Ook dit jaar mocht ik mijn broer wegbrengen en ophalen, en heb meteen de kans schoon gezien ‘s ochtends en ‘s middags wat foto’s te schieten van de trucks op het voormalige Marinevliegkamp Valkenburg.

  • Foto’s ochtend (foto’s op volgorde van binnenkomst, het blauwe formulier achter elk raam bevat het trucknummer)
  • Foto’s middag (foto’s op volgorde van Trucknummer)

Dit jaar was de eerste keer dat de vrachtwagen van Adest Musica mee mocht rijden.

Met nieuwe bestickering van al onze sponsors luidt dit twee belangrijke dingen in:

  1. De Adest Night of Music op 8 oktober die de Rotary Sassenheim samen organiseert, en waar – samen met de diverse afdelingen van Adest Musica – de bekende trombonist Ben van Dijk, saxofonist Wouter Kiers en partyband Ain’t no Secret zullen optreden.
    De opbrengst komt ten gunste van de Jeugdband van Adest Musica, en natuurlijk geven zij die avond ook een mooi optreden!
  2. De aanloop naar het Wereld Muziek Concours 2013 (de tijd gaat snel: over 2 jaar dat alweer achter de rug!) waar de Drum- en Showband Adest Musica weer een puik product gaat neerzetten.

Ben je trucker of deelnemer, en wil je graag originele foto’s, laat het dan even weten via het contactformulier: vul in ieder geval het nummer van je Truck in.

Ben je benieuwd naar Adest Musica? Schrijf je in voor de nieuwsbrief van Adest’ Night of Music!

Volgend jaar is de 15e Katwijkbinse Truckrun, tot dan!

–jeroen

via: Oranjevereniging Katwijk a/d Rijn.

Posted in About, Adest Musica, Event, Personal, Truckrun | Leave a Comment »