The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • Pages

  • All categories

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

    Join 1,839 other subscribers

PowerShell: Do not take a shortcut while testing NULL values.

Posted by jpluimers on 2014/03/05

A while ago I found a blog post explaining how to shortcut testing NULL values with PowerShell.

Do not do that!

I agree with the quote on the blog:

One thing you may not forget is that Powershell is a lot more friendly for NULL values than C#, so don’t forget to check your objects for NULL values. In Powershell this is very clean and easy to do.

But it is also easy to get wrong:

To see if a variable is null, simply check:

If (!$Variable) {some action}

Conversely, to verify if the variable has any value:

If ($Variable) {some action}

Just a few examples. Now quess the outcome for all of them.

$a=$null;  if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=$false; if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=0;      if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a='';     if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a="";     if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}
$a=1;      if ($a) {"'$a' has VALUE"} else {"'$a' is NULL"}

Now take an educated guess on the outcome. Read the rest of this entry »

Posted in .NET, CommandLine, Development, PowerShell, Software Development | Leave a Comment »

Quick Tip: Automating your Mac’s wifi power (on off through script) via: BrettTerpstra.com

Posted by jpluimers on 2014/03/04

Interesting commands around networksetup -setairportpower en0 : power off and on your WiFi.

–jeroen

via: [Wayback/Archive] Quick Tip: Automating your Mac’s wifi power – BrettTerpstra.com.

Posted in Apple, Hardware, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, Network-and-equipment, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User, WiFi | Leave a Comment »

ViaProtect Gives A Basic Look At Where Android Apps Are Sending Your Data (via: Android Police)

Posted by jpluimers on 2014/03/04

Interesting:

viaProtect (public preview) – Android Apps on Google Play.

–jeroen

via:

Posted in Android Devices, Power User | Leave a Comment »

One of the niceses PowerShell 3.0 new features: Simpler Where Filter Syntax

Posted by jpluimers on 2014/03/04

You can check out which PowerShell you have by executing the $Host.Version or $PSVersionTable.PSVersion on a line. You can even switch versions by applying the PowerShell -version switch on the command-line and they will both change.

One of the great features of the new PowerShell 3.0 features (besides New and Improved PowerShell 3.0 Cmdlets) is a simplified Where Filter Syntax.

So: this is how I get the PowerShell version information the easy way from a command prompt:

PowerShell $PSVersionTable.PSVersion

–jeroen

via:

Posted in .NET, CommandLine, Development, PowerShell, Software Development | Leave a Comment »

How to setup and use a SQL Server alias

Posted by jpluimers on 2014/03/03

Just in case I need this ever again: How to setup and use a SQL Server alias.

Posted in Database Development, Development, SQL, SQL Server, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »

Delphi Predefined Conditionals on iOS: IOS, MACOS, MACOS32, POSIX and POSIX32 (via: Conditional compilation (Delphi) – RAD Studio)

Posted by jpluimers on 2014/03/03

Just a reminder to Self after reading Predefined Conditions in Conditional compilation (Delphi) – RAD Studio.

On iOS, these conditional symbols are defined:

  • IOS
  • MACOS
  • MACOS32
  • POSIX
  • POSIX32

For the (x86 based) iOS simulator, CPU386 and CPUX86 are defined.

For iOS physical devices, CPUARM is defined.

For OS X and the iOS Simulator, ALIGN_STACK is defined as some parameters (including Extended) require to be aligned on 16-byte boundaries. For explanation, see the Mac OS X Stack Alignment article by Eli Boling, as well as PC_MAPPED_EXCEPTIONS and UNDERSCOREIMPORTNAME (sometimes een PIC).

–jeroen

via: Predefined Conditions in Conditional compilation (Delphi) – RAD Studio.

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development | Leave a Comment »

Delphi types that cannot be used for TypeInfo

Posted by jpluimers on 2014/03/03

When writing the Spring4D unit tests for GetTypeSize to include as many TTypeKind values, I came across a few types that either did not compile, or were not supported by TypeInfo. I listed them below as I could not find them in the documentation.

I included a test named Test_EnsureAllTTypeKindsCoveredByCallsTo_Test_GetTypeSize_ that verifies that all TTypeKind values except tkUnknown are covered. So future extensions of TTypeKind will make the tests fail.

As a side issue, I really wanted to know if tkUnknown could be emitted by the compiler. It can sort of, for instance by defining discontiguous enumerations, but are incompatible with TypeInfo as well.

Types that do not compile at all: Read the rest of this entry »

Posted in Agile, Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, DUnit, Software Development, Unit Testing | 2 Comments »

osx – How to find out Mac OS X version from Terminal? (via: Super User)

Posted by jpluimers on 2014/03/03

I’m a command-line addict, so this was a great SuperUser question by Željko Filipin:

I know how to find Mac OS X version from GUI: Apple Menu (top left) > About This Mac

Is there a Terminal command that will tell me Mac OS X version?

It was answered by User delfuego:

You have a few options:

sw_vers -productVersion
system_profiler SPSoftwareDataType

These commands led me to this post: Finding OS X Version and Build Information From the Command Line | The Nubby Admin that also showed these commands:

uname -a
osascript -e 'system info'

Where uname shows only the kernal version, oascript gives a ton of information. Read the rest of this entry »

Posted in Apple, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User | 2 Comments »

Simple Solutions | The Owner-Builder Network

Posted by jpluimers on 2014/03/02

Simple Solutions | The Owner-Builder Network: Use a rubber band to unscrew stripped screws.

Dus als de kop van de schroef stuk is: elastiek gebruiken (:

–jeroen

Posted in LifeHacker, Power User | Leave a Comment »

RemObjects Hydrogene got released March 1st, 2014 (via: Get Started with iOS Development using RemObject C#)

Posted by jpluimers on 2014/03/02

The estimate was that the Hydrogene bete would become public beta on March 1st 2014.

Well, Marc Hoffman did an even better announcement yesterday:

When, you are asking, is RemObjects C# going to be out? It’s out as of right now!Visit http://www.remobjects.com/cs for details, trial download, and (of course) to purchase. Let us know what you think!

BTW: Most of my guessed URLs were right (:

–jeroen

via: Get Started with iOS Development using RemObject C# | RemObjects Software « The Wiert Corner – irregular stream of stuff.

Posted in .NET, Development, Software Development | Leave a Comment »