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,854 other subscribers

Archive for 2013

C#/.NET/LINQ: DotNetStat: netstat.exe with TCP ports grouped by host

Posted by jpluimers on 2013/06/18

A lot of people have written .NET equivalents of netstat code. Basically there are two starting points:

I adapted the first, made the output very much like the built-in Windows netstat, and added some LINQ code to demonstrate grouping and ordering.

Now you get grouped output like this:

Distinct Remote Address:Port pairs by Remote Address:
107.20.249.140   443
107.20.249.78    443
127.0.0.1        6421, 19872
192.168.1.81     17500, 61678
199.47.218.159   443
199.47.219.148   80
199.47.219.160   443
23.21.220.140    443
23.23.127.94     443

The code below is part of the DotNetStat example.

It demonstrates a few important LINQ aspects beyond the LINQ Query Expressions (C# Programming Guide) intro and 101 LINQ Samples in C#.:

Read the rest of this entry »

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, Development, Jon Skeet, Software Development | Leave a Comment »

Google Chrome – how to quickly get Google search information about a term on a page: drag & drop

Posted by jpluimers on 2013/06/17

Great tip:

While reading online, have you ever seen a word or phrase that you wanted to learn more about? Next time, just highlight the term(s) and then drag it to your tabstrip to the right or left of your current tab — a new tab will open with search results for the highlighted text.

You can find other tab tricks like this here: http://goo.gl/lSilD #chrometip

–jeroen

via: Google Chrome – Google+.

Posted in Chrome, Google, Power User | Leave a Comment »

Retina MacBook Pro: extending battery life by disabling the discrete NVIDIA GeForce GT 650M graphics

Posted by jpluimers on 2013/06/14

One of the big differences between my old 13-inch MacBook Air and (fairly new) 15-inch Retina MacBook Pro was the predictability of battery usage.

The MacBook Air lasts between 4-5 hours. The Retina MacBook anywhere between 3-5 hours.

I finally found out the cause: Chrome, Remote Desktop and VMware Fusion will often (VMware fusion immediately) switch to the  discrete NVIDIA GeForce GT 650M graphics. Which uses a lot more battery (but less memory) than the integrated Intel HD 4000. Though both can drive the retina display at 2800×1600 (see Retina MacBook Pro Pushes the Limits of its Graphics Capabilities – Mac Rumors) the latter is better suited for the road warrior.

But still having the need for Chrome, Remote Desktop and VMware Fusion, I wanted a way to block switching to discrete graphics.

Luckily, quite a few sites describe how to do that:

The all come down to installing gfxCardStatus by cody krieger.

Steps to force integrated graphics: Read the rest of this entry »

Posted in Apple, Mac, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, Power User | 3 Comments »

AAC – DivX encoder information

Posted by jpluimers on 2013/06/14

There are a lot of encoders around that encode audio into AAC and often support many of the possible AAC feature extensions.

One of those encoders is the DivX AAC encoder called DivXAACEnc.

It’s not only interesting because it is free, but also because they provide some very readable information on what kind of parameters it accepts, and what they do on the DivX AAC Encoder (Beta) | DivX Labs page.

So they talk about:

  • input types (WAV, RAW PCM, bits per sample)
  • rate control (CBR/VBR) and magnitude
  • modes (LC, HE1, HE2) and what they do
  • ADTS protection
  • Low-pass filter
  • Audio processing tips

Highly recommended information!

One big drawback: it is file based only, so it does not support streams.

Note: this is Windows only. Sorry.

–jeroen

via:

Posted in Media Streaming, Power User | Leave a Comment »

Thinstuff Remote Application – NLDelphi

Posted by jpluimers on 2013/06/13

Interesting thread: Thinstuff Remote Application – NLDelphi.

Allows remote application access from Windows 7 / Vista / XP and Windows SBS, and it looks like you don’t need special CAL for it.

–jeroen

Posted in Power User, Windows, Windows 7, Windows Vista, Windows XP | Leave a Comment »

Reminder to self: 3 months ago “all mine!: openSUSE 12.3 is out!”

Posted by jpluimers on 2013/06/13

Time to try out the 3 months old release and see how much got fixed in the mean time.

–jeroen

via: all mine!: openSUSE 12.3 is out!.

Posted in *nix, Linux, openSuSE, Power User, SuSE Linux | Leave a Comment »

.NET/C# – CreateTemporaryRandomDirectory (via: Stack Overflow)

Posted by jpluimers on 2013/06/13

A while ago I needed unique temporary directories. This appears not to be standard functionality in the .NET System.IO.Path or System.IO.Directory class.

Josh Kelley asked a question about it before, and I adapted the example by Scott-Dorman based on GetTempPath and GetRandomFileName  and comments by Chris into a more robust CreateTemporaryRandomDirectory one that works in .NET 2.0 and higher:

using System.IO;

namespace BeSharp.IO
{
    public class DirectoryHelper
    {
        public static string GetTemporaryDirectory()
        {
            do
            {
                try
                {
                    string tempPath = Path.GetTempPath();
                    string randomFileName = Path.GetRandomFileName();
                    string tempDirectory = Path.Combine(tempPath, randomFileName);
                    Directory.CreateDirectory(tempDirectory);
                    return tempDirectory;
                }
                catch (IOException /* ex */)
                {
                    // continue
                }
            } while (true);
        }
    }
}

You can call it like this: Read the rest of this entry »

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | 2 Comments »

Delphi XE4 Update 1 is out (via: Installing the Platform Assistant on a Mac – RAD Studio)

Posted by jpluimers on 2013/06/12

Over the last couple of days, I was asking myself

“wow, the docwiki has been updated for the Delphi XE4 update 1 version of the Mac edition of the Platform Assistant, how long until the official update is out?”

These URLs from Installing the Platform Assistant on a Mac – RAD Studio didn’t work for a couple of days:

Now they do!

The reason is that yesterday Embarcadero released 29446 Update 1 for Delphi, C++Builder and RAD Studio XE4 that fixes lots of stuff: Fix list for Update 1 for RAD Studio XE4, Delphi XE4 and C++Builder XE4.

Note it is not referring to Readme – Help Update 1 for Delphi and C++Builder XE4 – RAD Studio which got released last week as 29436 Help Update 1 for Delphi, C++Builder and RAD Studio XE4. It is the real Delphi XE4 Update 1.

The cool thing: finally it is a binary patch. Not fast about as fast as a full uninstall/reinstall), but at 336 megabytes a much smaller download than the 3.7 gigabytes of 29451 Delphi XE4 and C++Builder XE4 ISO (including Update 1).

Patched update versus full uninstall/install is a trade off:

  • Patch can take a couple of hours, and is CPU bound (too bad most of it is bound to a single CPU core)
  • Uninstall/reinstall is disk-speed and disk-size bound (make sure you have 15+ gigabytes free; an SSD improves this process a lot)

altd, ftpd, keeping off-line downloads Read the rest of this entry »

Posted in Delphi, Delphi XE4, Development, Software Development | Tagged: , | 2 Comments »

Delphi XE4: installer batch file for “experimental GExperts + code formatter for Delphi XE4”

Posted by jpluimers on 2013/06/12

Slightly more than a month ago, Thomas Müller release the experimental GExperts + code formatter for Delphi XE4.

Since there is no official GExperts for Delphi XE4 build yet, his installation instructions include this:

Use the ExpertManager tool to register GExperts to Delphi XE4.

The thing is: ExpertManager is part of GExperts, so this introduces a “chichen-and-egg” situation.

So I wrote a small batch file and a bit of documentation to install it.

Just in case you cannot download that SVN changeset easily, here are the documentation and batch-file:

Documentation

Steps to install:
0- Quit Delphi XE4
1- Download the GExperts XE4 experimental from http://blog.dummzeuch.de/2013/04/28/experimental-gexperts-code-formatter-for-delphi-xe4/
2- Recursively unpack that download
3- Copy the batch file Install-GExperts-XE4-experimental–run-as-administrator-from-ExpertManager.exe-directory.bat into that directory
4- From that directory, run the copied Install-GExperts-XE4-experimental–run-as-administrator-from-ExpertManager.exe-directory.bat
5- Run Delphi XE4
6- Check if GExperts is installed

Batch file

:: check if user is administrator

  "C:\Windows\system32\cacls.exe" "C:\Windows\system32\config\system" 1>nul 2>&1  && (goto :isAdmin)
:isNoAdmin
  echo you need to be Administrator, and (when under Vista or higher) run this using using UAC
  goto :exit

:isAdmin

:: Gets the right link for x86 (32-bit) program files
IF /I %PROCESSOR_ARCHITECTURE% == amd64 goto :x64
IF /I %PROCESSOR_ARCHITEW6432% == amd64 goto :x64
goto :x86
:x64
   :: OS is 64bit
   set ProgramFilesX86=%ProgramFiles(x86)%
  goto :continue
:x86
   :: OS is 32bit
  set ProgramFilesX86=%ProgramFiles%
  goto :continue

:continue

:: create the right directory and copy the files

  setlocal

  set TargetDirectory=%ProgramFilesX86%\GExperts for RAD Studio XE4

  mkdir "%TargetDirectory%"
::  set FilesToCopy=DbugIntf.pas ExpertManager.exe GExperts.chm GExpertsDebugWindow.exe GExpertsGrep.exe regularexpert\GExpertsRSXE4.dll Readme.txt preview.pas
  set FilesToCopy=ExpertManager.exe GExperts.chm regularexpert\GExpertsRSXE4.dll preview.pas

  for %%f in (%FilesToCopy%) do copy /y %%f "%TargetDirectory%\"
  set RegFile="%TargetDirectory%\ExpertsXE4.reg"
::  explorer /select,"%TargetDirectory%\GExpertsRSXE4.dll"

:: expand backslash into double backslash for .REG file
  set ExpertTarget="%TargetDirectory%\GExpertsRSXE4.dll"
  set ExpertTarget=%ExpertTarget:\=\\%

::Windows Registry Editor Version 5.00
::
::[HKEY_CURRENT_USER\Software\Embarcadero\BDS\11.0\Experts]
::"GExperts"="C:\\Program Files (x86)\\GExperts for RAD Studio XE4\\GExpertsRSXE4.dll"
::
  echo Windows Registry Editor Version 5.00 >%RegFile%
  echo. >>%RegFile%
  echo [HKEY_CURRENT_USER\Software\Embarcadero\BDS\11.0\Experts] >>%RegFile%
  echo "GExperts"=%ExpertTarget% >>%RegFile%
  echo. >>%RegFile%
::  explorer /select,%RegFile%
  regedit /S %RegFile%

  endlocal

  goto :exit

:exit

–jeroen

via: experimental GExperts + code formatter for Delphi XE4 « twm’s blog.

Posted in Batch-Files, Delphi, Delphi XE4, Development, Scripting, Software Development | 2 Comments »

Crap: the outsourcing party of the client wrote C-code like this in 2005, and nobody scrutinized it

Posted by jpluimers on 2013/06/12

I was involved in a big project migrating a complex stack from Windows XP to Windows 7 x86, and got scared this !@#$ out of me.

The stack communicated to WebSphere MQ on AS/400 from Windows, and on the Windows side of things consisted of a UI developed in in Cool:Gen, a C interface to a Delphi DLL, which takes care of the communication to WebSphere MQ.

Digression:

This all was histerically grown. In the beginning (early to mid 90s last century) it was a big Borland Pascal/Turbo Pascal application – running on DOS, Windows 3.1x, Windows 95 and OS/2 2.x/3.0 – that talked over a propriatary layer over SNA to AS/400.
The vendor of that layer didn’t respond to a request for Windows NT 4.x compatibility, and meanwhile some client applications were about to be developed in Delphi.

So in 1997/1998 – together with a great AS/400 software developer – I wrote a SNA based APPC/CPI-C communication layer in Delphi 3 that could be accessed from both Turbo Pascal (using a file based interface) and Delphi (using an object interface).
The DOS interface was an executable around the Delphi interface, which was a set of classes.

Delphi part

The Delphi part of the DOS interface was centered around FindFirstChangeNotification/CreateProcess combined with MsgWaitForMultipleObjects/WaitForSingleObject to make the waiting as efficient as possible.

DOS part

DOS part

The DOS part of the Delphi interface was centered around this piece to make waiting efficient:

asm
  int $28
  mov ax, $1000
  int $15 { DESQview/TopView give up time slice }
  mov ax, $1680
  int $2F
end;

Thanks to the RBIL: Ralf Brown’s Interrupt List (there are now multiple HTML versions of it), it makes use of these tricks so DOS applications can efficiently wait : Read the rest of this entry »

Posted in C, CVS, Delphi, Delphi 2006, Delphi 3, Delphi 5, Delphi XE2, Development, Dimensions CM by Serena, MKS Integrity, Software Development, Source Code Management | 3 Comments »