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

Jeroen turns 42 today

Posted by jpluimers on 2011/04/29

is a remarkeble number, and forty-two is what Jeroen turns today.

Jeroen won’t panic, as he lives on a mostly harmless planet, and plans to live for quite a while longer.

Don’t forget your towel today!

–jeroen’s alter ego

Posted in About, Personal | Leave a Comment »

How to: Configure Express to accept remote connections – SQL Server Express WebLog – Site Home – MSDN Blogs

Posted by jpluimers on 2011/04/28

when developing embedded Windows software, SQL Express can be a good option.

However, embedded usually means you can’t install a big tool-set (like SQL Server Management Studio or SQL Server Profiler) on the target system.

So if you want to monitor or profile it, you need remote access to your SQL Express instance (usually SQLEXPRESS).

The How to: Configure Express to accept remote connections – SQL Server Express WebLog article on the SQL Server Express WebLog and the KB article How to configure SQL Server 2005 to allow remote connections explain the details.

This is a short summary:

  1. Enable TCP/IP using the SQL Server Configuration Manager
    (you can do this using the registry too)
  2. Enable the SQL Browser using the SQL Server Configuration Manager
  3. Open your firewall for the TCP ports (more difficult) or SQL Server process (easier)
  4. Enable mixed mode login authentication from the registry:
    HKLM/Software/Microsoft/MSSQLServer/MSSQLServer/LoginMode = 1 integrated security, 2 mixed.
  5. Make sure that SA can login, and give it a strong password using this in SQLCMD:
    ALTER LOGIN sa ENABLE
    ALTER LOGIN sa WITH PASSWORD=’Som3StrongP@assword’
  6. Restart the SQL Server Service
  7. Start the SQL Browser Service

Finally connect to your SQL Express server by using SQLCMD:

SQLCMD –S machinename\SQLEXPRESS –Usa –PSom3StrongP@assword

–jeroen

Posted in Database Development, Development, SQL Server | Leave a Comment »

Some notes on BASS (re)encoding and tagging audio files

Posted by jpluimers on 2011/04/27

When (re)encoding files through BASS:

  1. always make sure you either have RAW PCM format source; decode back from anything else back to RAW PCM if you have compressed sources; this BassEncoder.EncodeFile thread explains why.
  2. not all of the BASS encoder classes support tagging with artist/title; use external tools for that; this message explains which encoders (partially) support tagging.
  3. often it is not possible to find the encoder that both encodes the audio in the quality level you want, and supports the tagging you want, so you definitely need to look at the above mentioned tagging tools.
  4. if you want to play lots of files in random succession, it is wise to calculate ReplayGain and apply it: it makes your files sound equally loud: note this is not wise if you want to play full albums, but is wise for playing random tracks. This ReplayGain thread can provide you with a start.
    You can do gain correction with BASS, or opt for external gain tools on RareWares.org.

--jeroen

PS: more on Audio correctionň

Posted in BASS, BASS.NET, Development, Power User, Software Development, Un4seen BASS Audio Library | Leave a Comment »

Tortoise SVN Global Ignore Pattern for Delphi and Visual Studio

Posted by jpluimers on 2011/04/26

Since I use (among others) both Visual Studio and Delphi, I changed the Tortoise Global Ignore Pattern to be this:

Debug lib *.identcache *.local *bin *obj RECYCLER Bin *.user *.suo *.dcu __history ModelSupport_* *.rsm thumbs.db *.bak *.~* __recovery *.tvsconfig *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store

The bold portion is what I changed when compared to the original one:

*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store

Input from [WayBack] Tortoise SVN Global Ignore Pattern for Visual Studio (which also included some of the Delphi patterns), [WayBack] this Stackoverflow question (that indicated the patterns are case sensitive) and [WayBackShawn Oster | TortoiseSVN global ignore pattern for Visual Studio and Delphi.

–jeroen

PS: Added __recovery as Delphi 10.* started to use that for recovery files, which – unlike __history  is not documented, see [WayBack] What is the __recovery folder ? In C++ Seattle 10 Professional running under Win 7 I now get a folder called __recovery.

Posted in .NET, Delphi, Development, Software Development, Source Code Management, Subversion/SVN | Leave a Comment »

alias to have Unix list command ‘ls’ output numerical chmod permissions (via Stack Overflow)

Posted by jpluimers on 2011/04/25

Though I use Linux and Cygwin often, the discrepancy between permissions in chmod and ls still strikes me.

I mean: after all these years, does the *nix world still want newbies to learn the octal notation of file permissions and do the math themselves? Come on!

Bsaically, you can use the stat command to show the octal permissions next to the filename (so you can apply them with chmod), but sometimes it is handy to have both the chmod and ls versions next to each other.

For showing both, this awk script comes in handy.

I slightly modified it to use ls -al instead of ls -l, and condense it on one line:

ls -al|awk '{k=0;s=0;for(i=0;i<=8;i++){;k+=((substr($1,i+2,1)~/[rwxst]/)*2^(8-i));};j=4;for(i=4;i<=10;i+=3){;s+=((substr($1,i,1)~/[stST]/)*j);j/=2;};if(k){;printf("%0o%0o ",s,k);};print;}'

If you want to have it in your .bashrc or .bash_aliases, then you need to escape the double quotes and dollar signs:

alias "lsmod=ls -al|awk '{k=0;s=0;for(i=0;i<=8;i++){;k+=((substr(\$1,i+2,1)~/[rwxst]/)*2^(8-i));};j=4;for(i=4;i<=10;i+=3){;s+=((substr(\$1,i,1)~/[stST]/)*j);j/=2;};if(k){;printf(\"%0o%0o \",s,k);};print;}'"

It shows me a listing like this:
$ lsmod
0200 total 47
0755 drwxr-xr-x+ 1 jeroenp None 0 Apr 11 14:00 .
1777 drwxrwxrwt+ 1 jeroenp root 0 Apr 11 09:21 ..
0700 -rwx------ 1 jeroenp None 207 Apr 11 13:50 .bash_aliases
0600 -rw------- 1 jeroenp None 4869 Apr 11 14:00 .bash_history
0755 -rwxr-xr-x 1 jeroenp None 1103 Apr 11 09:08 .bash_profile
0755 -rwxr-xr-x 1 jeroenp None 5657 Apr 11 14:00 .bashrc
0755 -rwxr-xr-x 1 jeroenp None 5663 Apr 11 09:08 .bashrc~
0755 -rwxr-xr-x 1 jeroenp None 1461 Apr 11 09:08 .inputrc
0600 -rw------- 1 jeroenp None 564 Apr 11 14:00 .joe_state
0600 -rw------- 1 jeroenp None 99 Apr 11 13:58 .lesshst
0755 -rwxr-xr-x 1 jeroenp None 792 Apr 11 09:08 .profile
0700 drwx------+ 1 jeroenp None 0 Apr 11 13:07 .ssh
0755 drwxr-xr-x+ 1 jeroenp None 0 Apr 11 13:32 install

–jeroen

via: Can the Unix list command ‘ls’ output numerical chmod permissions? – Stack Overflow.

Posted in *nix, Cygwin, Power User | Leave a Comment »

Mapping of Lenovo ThinkPad W701 SATA bays to boot devices

Posted by jpluimers on 2011/04/22

The Lenovo ThinkPad W701 can have three (3!) SATA spindles, one of which is through the Serial Ultrabay Enhanced bay, the other 2 can be hard drives.

Below is the mapping between the bays and the boot devices.

The bays are numbered as in the ThinkPad W700, W700ds, W701, and W701ds Hardware Maintenance Manual.

  1. Internal SATA Port 1; ATA HDD0 or ATA CD0: 1030 Serial Ultrabay Enhanced device (page 90)
  2. Internal SATA Port 2; ATA HDD1: 1040 Hard disk drive (HDD) slot 1 (page 92)
  3. Internal SATA Port 0; ATA HDD2: 1040 Hard disk drive (HDD) slot 0 (page 92)
  4. External SATA Port 4: unknown
  5. External SATA Port 5: unknown

Note that the slot order and the boot device order is counter intuitive, espcially since the W701 ships with a HDD in slot 1 (which is ATA HDD0), and the SATA ports don’t map to the HDD numbers.

I don’t know yet which External SATA Port maps to the USB/eSATA combo connector mentioned on page 195.

Some remarks:

The Serial Ultrabay Enhanced bay is probably HDD0 because it is also CD0, and it makes sense to boot from CD first when you install a machine.

ATA CD0 is for one these optical devices:

ATA HDD0, 1 and 2 can be one of those HDD devices (for ATA HDD2 you need a Serial Ultrabay Enhanced adapter, either 9.5mm or 12.7 mm high):

  • 1.8 inch SATA SSD through adapter FRU 42W7888
  • 2.5 inch SATA SSD
  • 2.5 inch SATA HDD

The Serial Ultrabay Enhanced adapter can hold 12.5 mm drives, the other bays can only hold 9.5 mm drives.

It looks like the W701 is the last ThinkPad that ships with a 1920 x 1200 screen (all newer models have HD screens of 1920 x 1080, so you loose 10% of your screen height).

I learned that the yellow USB port is the powerd one (if it is disabled, you can enable the power in the BIOS)

–jeroen

Posted in BIOS, Boot, Power User, ThinkPad, W701 | 1 Comment »

Delphi Constraints in Generics – RAD Studio XE documentation wiki

Posted by jpluimers on 2011/04/21

Quite a few things are similar when doing Generics in both Delphi and C#.

But constraints are a bit different.

To quote the Delphi Wiki page on Constraints in Generics – RAD Studio XE:

Constraints can be associated with a type parameter of a generic. Constraints declare items that must be supported by any particular type passed to that parameter in a construction of the generic type

Constraint items include:

  • Zero, one, or multiple interface types
  • Zero or one class type
  • The reserved word “constructor“, “class“, or “record

You can specify both “constructor” and “class” for a constraint. However, “record” cannot be combined with other reserved words.
Multiple constraints act as an additive union (“AND” logic).

A few other differences are these:

  • In .NET, there is a unified typing system: everything descends from System.Object, including both value types and reference types. In Delphi this is not the case. In .NET, when you don’t specify a constraint, but use the type in a reference way, it will do automatic boxing. Delphi has no concept of automatic boxing, so you cannot use a non-constrained type as a reference
  • In both .NET and Delphi, you cannot specify a constraint on an enumeration type. In .NET you can work around this by constraining on the underlying interfaces. In Delphi you cannot do that because enumeration types are ordinal types that do not implement interfaces.
  • In Delphi you cannot constrain on ordinal types.

Note that – like the Delphi documentation – the C# constraints on type parameters documentation is not complete on those either.

Related: a great post [WayBack] Using Generics in Delphi – Phil Gilmore covering the comparison between C# and Delphi in more depth.

–jeroen

via: Constraints in Generics – RAD Studio XE.

Posted in C#, Delphi, Development, Software Development | 10 Comments »

human readable number formatting – C#: File-size format provider – Stack Overflow

Posted by jpluimers on 2011/04/20

Boy, I love stackoverflow.

Unlike a forum – which is focussed on discussion – stackoverflow is focussed on questions and answers, and they have lots of good answers.

Recently, I had to format numbers in a human readable way.

The formatting – C#: File-size format provider – Stack Overflow question had at least 3 good ways.

I chose the FileSizeFormatProvider answer, as it best fitted my goal and it is easy to extend, but the StrFormatByteSize answer works very well too if you need an ‘out of the box’ solution that works on native Windows.

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »

Convert linq query to string array/list – C# – Stack Overflow

Posted by jpluimers on 2011/04/19

Sometimes little snippets of code help you big time.

Note the below ones are not performant (they will load all the data), but can make your code a lot more readable.

Use with care!

return list.Select(x => x.ToString()).ToArray();

return list.Select(x => x.ToString()).ToList();

–jeroen

via: Convert linq query to string array – C# – Stack Overflow.

Posted in .NET, C#, C# 3.0, C# 4.0, Development, LINQ, Software Development | Leave a Comment »

InfoWorker Solutions: SharePoint ACLs: RoleDefinitions, RoleAssignments, Inheritance

Posted by jpluimers on 2011/04/18

SharePoint security can be tricky business.

Here are a few URLs that helped me going:

–jeroen

Posted in Development, SharePoint, Web Development | Leave a Comment »