I always, and I mean ALWAYS forget the syntax of RowFilter expressions. So, here is a nice round-up on the topic.
Category Archives: Code Snippets
Task Parallel Library / TPL
It has been very long since my last post here – I was really busy at work. But I will try to “fix it”! :)
I don’t know where Sacha Barber finds time for all his articles and “hobby” projects, but I am glad he does! One of the latest subjects of his investigations is Task Parallel Library (or TPL in short), one of the new parts of .NET 4:
Object Mentor
Finally I am back! :) Last year or so I was really busy working on our product, but now we are basically ready, and I can spare more time for “hobbies”.
So, today I found Object Mentor and its blog. There are plenty of articles on agile, TDD, good software design principles, C++, and many-many other topics. Definitely worth following…
Today’s Sites/Blogs
- Ask the Performance Team (Thoughts from the EPS Windows Server Performance Team) – in their own words “… the Performance team covers a broad range of seemingly unrelated areas such as Core OS Performance, Printing, WMI and Terminal Services. Simply put – we’re a bit of a “catch-all” team. [...] Because we cover such a wide spectrum of technology, we see many different types of issues – some more frequently than others. So we thought we should share with the broader technical community. We’ll be sharing troubleshooting tips and technical information on areas of our specialty that we cover.”
- 45+ Excellent Code Snippet Resources and Repositories – it is what it says it is.
Styling a ScrollViewer/Scrollbar in WPF
In his Styling A ScrollViewer/Scrollbar In WPF article Sacha Barber explains how to do exactly what the article’s title claims. :)
.NET Events: Multithreading Issues
Threadsafe Events article at CodeProject explains problems one might encounter with .NET events in a multithreaded environment (not necessarily stating the absolute truth but still). Unfortunately, no-one has figured out the perfect solution, and we will have to choose “the best from all bad solutions” for some time still.
Asynchronous Callback Contexts article by the same author shows possible solution for event cancellation, particularly during object disposal: end-users do not expect components to raise events after they have been disposed or after they have unsubscribed from these events. The author refers to his Nito Asynchronous Library as a way to solve this issue.
Today’s Sites/Blogs
- Started to “bump” into the Smashing Magazine quite often nowadays. Usually it collects interesting Internet resources related to web development (notably CSS, HTML, AJAX, etc.) and design (user interfaces, fonts, new ideas, etc.), and also has some tutorial-like or how-to-like posts (e.g. about PNG optimization, common mistakes, etc.). Really nice! Webdesigner Depot, Line25 Web Design Blog, and Presidia Creative all have similar concept.
- Windows Presentation Foundation SDK by Windows Presentation Foundation SDK writers and editors. Might be more interesting, but OK nevertheless.
- Expression Blend and Design – The team blog of the Expression Blend and Design products
Best JavaScript, HTML, and CSS Practices for Beginners
Nice collections of tips:
Today’s Sites/Blogs
- TomasP.Net blog by Tomas Petricek, author of Functional Programming for the Real World: With Examples in F# and C# (have not read this book yet, so no idea how good it is), features plenty of interesting information about functional programming in general, and in F# in particular.
Security: Banned C Functions
memcpy() Is Going to Be Banned article at InfoQ talks about dangers of memcpy (and other memory/string related functions). Microsoft has more in-depth explanations as well as the list of Security Development Lifecycle (SDL) Banned Function Calls at MSDN. Also available from Microsoft is banned.h header file that, once included, will produce warnings for all the banned functions. Alternatively one can use the /W4-C4996 compiler option.
Win32/C++ Resources
A “healthy set” of Win32 and C++-related links (related stuff, anyway):
- MVP Tips, Techniques, and Goodies by Joseph M. Newcomer has a lot of C++ and Win32 topics, covering all “gray” areas like asynchronous operations, synchronization, threading, memory leaks, optimizations, various Windows APIs, device drivers, etc. For example, there is An introduction to memory damage problems that goes thoroughly through the topic, or absolutely fantastic The n Habits of Highly Defective Windows Applications that nicely enumerates ugliest “no-no’s” one should avoid in his code if he wants to sleep well :)
- C++ In Action, book by Bartosz Milewski. Cool thing is that there is a web edition of the book. Additionally, on the C++ Resources page there is Windows API Tutorial, RSWL: Free Windows Library, and some other papers and presentations, including topics on Resource Management, something called auto_vector ;) , and rather interesting Dealing with Software Complexity presentation.
- Win32 samples has a lot of samples for Net*() APIs, as well as for LSA, NTFS streams, processes, security
“Bit Twiddling”
Needed to do some “weird” things recently that involved bit operations, e.g. to create masks with certain number of bits set. During my “research” I found few interesting places:
- Bit Twiddling Hacks – lots of snippets related to bit operations, e.g. counting, reversing, swapping, interleaving, testing, etc., etc., etc.
- Creating multiple numbers with certain number of bits set – this was the answer to my need, clean and simple
- Technical Interview Questions – has a lot of interesting topics, nicely categorized, although not all-encompassing, if comparing to the first link above
Managed Windows API
Managed Windows API is a collection of C# components that wrap Windows API functionality – a nice addition to pinvoke.net.
A .NET Cryptography Primer
Found A .NET Cryptography Primer on State Street Gang blog. It is a four-part article:
Shadow Copying of .NET Applications
Shadow Copying of Applications article on CodeProject shows simple technique allowing one to run shadow copies of .NET applications (like ASP.NET is doing for long time already).
More C++ Idioms
More C++ Idioms is a Wikibook aimed toward anyone with an intermediate level of knowledge in C++ and supported language paradigms. The goal there is to first build an exhaustive catalog of modern C++ idioms, and later evolve it into an idiom language, just like a pattern language.
The thing has been started by the author of C++ Truths blog. The blog is interesting by itself, as it has really many interesting articles on advanced C++ topics.
Thread Synchronization: Wait and Pulse Demystified
Thread Synchronization: Wait and Pulse Demystified article on CodeProject describes low-level synchronization between threads in terms of Monitor class and its Wait, Pulse, and PulseAll methods. The MSDN documentation for these methods explains what they do, but not why or how to use them. This article fills this gap and demystifies them.
Introduction to D3DImage
Dr. WPF published Introduction to D3DImage on CodeProject. The release of .NET 3.5 SP1 made possible a whole new level of WPF-DirectX interop: a custom DirectX scene can now be composed with a WPF scene using the new WPF’s D3DImage feature.
Today’s Blogs
- The Old New Thing by Raymond Chen – really nice blog with a lot of in-depth info, e.g. wonderful posts about The implementation of iterators in C# and its consequences (part 1, part 2, part 3), The implementation of anonymous methods in C# and its consequences (part 1, part 2, part 3), a lot of native Win32 topics (e.g. DLLs, processes, controls, etc.), etc. Probably there is no aspect of Windows that would not be covered at that blog! :)
- jaredpar’s WebLog by Jared Parsons – blog of the author of RantPack – a library that features functional programming patterns (tuples, immutable/persistent collections), threading utils (futures, cancelable futures, active objects, various other primitives), etc. The blog is very interesting, and there are many insights into software development topics
Today’s Links
These are mostly related to systems’ programming:
- Professional System Library – a free, open-source COM library that offers a simple, generic and logical API for accessing most commonly used information about the system and the environment in which the client application is running, e.g. security, privileges, processes, threads, drivers, services, network, memory, etc. There is also Professional System Library: Introduction article at CodeProject giving brief introduction to the library.
- Authors of 32 OpenMP traps for C++ developers article did really good job. I have not use OpenMP (multi-platform shared-memory parallel programming API for C/C++ and Fortran) myself yet, but can easily imagine that this article can save many hours of painful digging into the non-working code.
- A Fiber Class (and Friends) (C++) is introducing fibers and illustrates the implementation of round-robin scheduler for fibers.
- Telling The Difference Between CD and DVD Drives (C++) – might save some time if needed eventually
- Using Raw Input from C# to handle multiple keyboards – despite the article is in C#, it is 1:1 translating to C++.
- Tracing Events Raised by Any C# Object presents the simple-but-general event hooking/tracing class.
Using RoutedCommands with a ViewModel in WPF
Well, Josh Smith is always producing good stuff: his Using RoutedCommands with a ViewModel in WPF at CodeProject is really cool!
marshal_as String Arrays
Giovanni Dicanio developed an extension (template specialization) to marshal_as<> library of Visual C++ 2008, to convert Unicode string arrays between managed (CLR) and native (STL/C++) code. The code is available at marshal_as String Arrays.
New Features in .NET/WPF 3.5 SP1
- StringFormat by Lester Lobo – allows custom string formatting in bindings
- ScrollViewer.IsDeferredScrollingEnabled; AlternationCount; IEditableCollectionView by Lester Lobo - perceived performance improvement, setting alternating properties on rows of an items control, add/remove/edit items in a collection
WPF Application Localization
WPF Runtime Localization article on CodeProject describes one way to do it. Interesting approach is to use WPF Localization Extension available freely on CodePlex. And then there is an article that goes in the same direction: WPF Localization – On-the-fly Language Selection.
Software Testing and Related Things
By accident found Google Testing Blog. Not bad.
One of the articles is called How to Write 3v1L, Untestable Code – a must-read for newbie (and not newbie too!) programmers. Not on this blog, but nevertheless related article is How To Write Unmaintainable Code by Roedy Green – very serious collection of bad things despite it is very funny to read.