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,595 other followers

Archive for February 11th, 2014

Chrome does not pick up on time zone changes until the browser is restarted. (via: pellepim / jsTimezoneDetect / issues / #57 – Wrong time zone using Chrome on Mac — Bitbucket)

Posted by jpluimers on 2014/02/11

Just got bitten by Wrong time zone using Chrome on Mac:

Chrome does not pick up on time zone changes until a new tab is opened or the browser restarted.

Actually, it requires a browser restart, as below is the difference between a new Chrome tab and running on jsc on the console: Read the rest of this entry »

Posted in Chrome, Development, Google, JavaScript/ECMAScript, Power User, Scripting, Software Development | Leave a Comment »

Mac OS X: How do you run JavaScript script through the Terminal? (via: Stack Overflow)

Posted by jpluimers on 2014/02/11

Now I have these aliases in my ~/.bash_profile:

alias jsc='/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc'
alias JavaScript='/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc'

Now I can use the WebKit jsc from the console.

Thanks User microspino – Stack Overflow for this answer: Read the rest of this entry »

Posted in Apple, Development, JavaScript/ECMAScript, 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, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User, Scripting, Software Development | 1 Comment »

Need to research: Yahoo Pipes (via: Chris Benard — How to Fix the Dilbert.com RSS Feed)

Posted by jpluimers on 2014/02/11

I’m not sure how to categorize this yet, so it is both under Power User and Development/Software Development.

A long while ago (somewhere mid 2013), the official Dilbert RSS feeds got disabled.

More precisely: initially they pointed each entry in the RSS feed to an antey specific landing page that made you click through the Dilbert.com site to browse for the comic strip. Which is understandable as they want to show you more ads than the RSS feed would.

Later they screwed up those landing pages page so you could not get to the Dilbert site any more, nor see those ads. You get to see only this:

Dilbert will be back soon! We are updating the site for you and will be back shortly. In the meantime, how about laughing at a comic or two on our sister site?

Which makes it a no-loss for Dilbert to re-create an RSS feed, as that will make you see the comics, enhancing at least the Dilbert brand value.

Of course you can go through http://www.dilbert.com/fast manually, but that is outside my feed aggregator realm. Read the rest of this entry »

Posted in Development, Power User, Software Development | Tagged: | 1 Comment »

Google Cast bug tracker (via: google-cast-sdk – Google Cast SDK – Google Project Hosting)

Posted by jpluimers on 2014/02/11

The bug tracker for Chromecast / Google Cast is at Issues – google-cast-sdk – Google Cast SDK – Google Project Hosting.

–jeroen

via: google-cast-sdk – Google Cast SDK – Google Project Hosting.

Posted in Chromecast, Development, Google, Power User, Software Development | Leave a Comment »

.NET/C#: DBNull explained

Posted by jpluimers on 2014/02/11

The DBNull type is a very special type in .NET. It represents null values in databases, which are slightly different than null values in .NET.

The biggest confusion that people have with it is that it won’t convert to anything. Which means that you see a lot of questions like “System.InvalidCastException: Conversion from type ‘DBNull’ to type” “is not valid”.

You’d think the full name would be System.Data.DBNull, it is actually named System.DBNull. The reason is that various other functionality of the System namespace depend on it, for instance the System.Convert class.

DBNull was already present in .NET 1.x, so it predates nullable types that were introduced in C# 2 / .NET 2.

A null value on the database side will result in a DBNull instance.

If you want to explicitly pass a null value to a database, you use a DBNull.Value, which is a singleton.

Why DBNull

There is a very interestin question/answer series on StackOverflow about this: via .net – What is the point of DBNull? – Stack Overflow.

There are a few good arguments both for and against DBNull.

But the baseline is that DBNull predates the introduction in the .NET framework of genuine nullable types. Both their behaviour is slightly different, so DBNull had to stay.

Which means you have to deal with it every now and then.

Invalid casts

A bit more background on the invalid casts.

It is thrown like this:

            throw new InvalidCastException(Environment.GetResourceString("InvalidCast_DBNull"));

from

Convert.DefaultToType();

which is called from the DBNull method

    object IConvertible.ToType(Type type, IFormatProvider provider);

All other IConvertible methods are implementated like

bool IConvertible.ToBoolean(IFormatProvider provider)
{
    throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
}

So these all throw the same exception:

    bool IConvertible.ToBoolean(IFormatProvider provider);
    byte IConvertible.ToByte(IFormatProvider provider);
    char IConvertible.ToChar(IFormatProvider provider);
    DateTime IConvertible.ToDateTime(IFormatProvider provider);
    decimal IConvertible.ToDecimal(IFormatProvider provider);
    double IConvertible.ToDouble(IFormatProvider provider);
    short IConvertible.ToInt16(IFormatProvider provider);
    int IConvertible.ToInt32(IFormatProvider provider);
    long IConvertible.ToInt64(IFormatProvider provider);
    sbyte IConvertible.ToSByte(IFormatProvider provider);
    float IConvertible.ToSingle(IFormatProvider provider);
    ushort IConvertible.ToUInt16(IFormatProvider provider);
    uint IConvertible.ToUInt32(IFormatProvider provider);
    ulong IConvertible.ToUInt64(IFormatProvider provider);

–jeroen

via:

Posted in .NET, .NET 1.x, .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 | Leave a Comment »

 
%d bloggers like this: