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

Archive for August, 2015

anoymyous type trick: Check if KeyValuePair exists with LINQ’s FirstOrDefault – via Stack Overflow

Posted by jpluimers on 2015/08/27

When you have a Dictionary<TKey, TValue>, then LINQ results will get you a enumerables of KeyValuePair<TKey, TValue>.

Since KeyValuePair is a struct, selecting FirstOrDefault will not get you a null, but a default(KeyValuePair<TKey, TValue>) which is a lot harder to handle than null.

Sometimes, being able to get a null out of FirstOrDefault is very useful, so a bit thank you to Marc Gravell for answering this very neat trick:

If you just care about existence, you could use ContainsValue(0) or Any(p => p.Value == 0) instead? Searching by value is unusual for a Dictionary<,>; if you were searching by key, you could use TryGetValue.

One other approach:

       var record = data.Where(p => p.Value == 1)
            .Select(p => new { Key = p.Key, Value = p.Value })

This returns a class – so will be null if not found.

The trick is this portion:

p => new { Key = p.Key, Value = p.Value }

It introduces an anonymous type with two fields: Key and Value. (Note you can introduce any anonymous type here). Since these are classes, FirstOrDefault will return null if nothing was found.



Posted in .NET, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development | Leave a Comment »

for %n = 1 to 100 step 1 do: windows – Batch script loop – Stack Overflow

Posted by jpluimers on 2015/08/26

Thanks Jon for answering this:

for /l is your friend:

for /l %x in (1, 1, 100) do echo %x

Starts at 1, steps by one, and finishes at 100.

Use two %s if it’s in a batch file

for /l %%x in (1, 1, 100) do echo %%x


via: windows – Batch script loop – Stack Overflow.

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

Cool: Vysor screen sharing by Koush

Posted by jpluimers on 2015/08/25

Esc: Back button; F1: Menu button; Home: Home button.

Esc: Back button; F1: Menu button; Home: Home button.

Really really cool!

Vysor (by Koushik Dutta aka Koush) lets you not only share and control your Android device screen from your local Chrome browser, but also remotely to others having a Chrome browser with Vysor installed. And Vysor gives you full ADB access to your Android device.

Some links to get started:

To get started:

  1. Enable ADB on your Android phone.
  2. Connect your Android phone over USB to your computer.
  3. Start Vysor.
  4. Connect.
  5. Enjoy.

After connecting over ADB, Vysor sideloads the Android code to share both screen and input. So besides viewing your screen, you can then control it.

Of course your mouse works, including scrolling. And the keyboard for entering text.

There are also some special keys:

  • Esc: Back button;
  • F1: Menu button;
  • Home: Home button.

Read the rest of this entry »

Posted in Android Devices, Chrome, Google, Power User | 1 Comment »

Programmers’ hardest tasks

Posted by jpluimers on 2015/08/25

It took me a while to find the original illustration (especially as it was copied so often in low quality), but below it is.

Martin Wienold made a great joke based on it last year:

There are only two hard problems

  1. naming things
  2. cache invalidation
  3. off-by-one errors


via: G+; Programmers’ hardest tasks.

Original (October 2013): Don’t go into programming if you don’t have a good thesaurus | ITworld.

Programmer's Hardest Tasks

Programmer’s Hardest Tasks


Posted in Development, Software Development | Leave a Comment » trick for Opening UI of the FRITZ!WLAN Repeater 1750E – via: AVM International

Posted by jpluimers on 2015/08/24

Because points to my Fritz!BOX router, it cannot be used to get to my Fritz!WLAN Repeater. I just learned about the trick does.

Which saves me from remembering the repeater IP-address or name.


via: Opening the FRITZ!Box user interface | FRITZ!WLAN Repeater 1750E | AVM International.

Posted in Fritz!, Fritz!Box, Fritz!WLAN, Internet, Power User, Routers | Leave a Comment »

%d bloggers like this: