Click here to Skip to main content
13,867,201 members

Articles by Luc Pattyn (Articles: 8, Tip/Tricks: 13)

Articles: 8, Tip/Tricks: 13

RSS Feed

Average article rating: 4.88

Files and Folders
Posted: 27 Aug 2009   Updated: 31 Aug 2009   Views: 64,661   Rating: 4.89/5    Votes: 39   Popularity: 7.77
Licence: The Code Project Open License (CPOL)      Bookmarked: 63   Downloaded: 841
My entry to the lean-and-mean programming competition.
Applications & Tools
CodeProject Tools
Posted: 4 Jan 2010   Updated: 24 Feb 2010   Views: 37,482   Rating: 4.97/5    Votes: 31   Popularity: 7.42
Licence: The Code Project Open License (CPOL)      Bookmarked: 31   Downloaded: 231
From automatic code recognition to fully automated code snippet pasting; no more missing PRE tags!
Delegates and Events
Posted: 24 Jul 2007   Updated: 24 Jul 2007   Views: 77,192   Rating: 4.76/5    Votes: 45   Popularity: 7.87
Licence: The Code Project Open License (CPOL)      Bookmarked: 64   Downloaded: 602
Delegates: how to add them to an event, how they get removed and when that is necessary
Posted: 2 Feb 2007   Updated: 2 Feb 2007   Views: 164,144   Rating: 4.82/5    Votes: 73   Popularity: 8.99
Licence: The Code Project Open License (CPOL)      Bookmarked: 97   Downloaded: 2,999
A simple app demonstrates unexpected behavior of .NET timers and Thread.Sleep(); native multimedia timers come to the rescue.
Posted: 16 Jul 2007   Updated: 21 Dec 2014   Views: 75,261   Rating: 4.90/5    Votes: 23   Popularity: 6.65
Licence: The Code Project Open License (CPOL)      Bookmarked: 38   Downloaded: 3,489
A utility that removes phantom icons from the Icon Tray
.NET Framework
Posted: 22 Mar 2010   Updated: 8 Jun 2011   Views: 146,147   Rating: 4.93/5    Votes: 80   Popularity: 9.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 67   Downloaded: 1,650
A viewer for CodeProject's recently introduced reputation information; futile, but fun
Bugs & Workarounds
Posted: 30 Jul 2007   Updated: 30 Jul 2007   Views: 33,970   Rating: 4.90/5    Votes: 16   Popularity: 5.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 29   Downloaded: 267
ow to copy code snippets with Internet Explorer while preserving newlines and indentation
Game Development
Posted: 16 Jan 2007   Updated: 16 Jan 2007   Views: 47,111   Rating: 4.88/5    Votes: 14   Popularity: 5.59
Licence: The Code Project Open License (CPOL)      Bookmarked: 18   Downloaded: 1,453
A simple Sokoban implementation in C# with some extras
No blogs have been submitted.

Average tips rating: 4.96

.NET Framework
Posted: 10 Jan 2012   Updated: 10 Jan 2012   Views: 6,870   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
You shouldn't be working with huge strings at all.If this represents a file's content, read it using File.ReadAllLines() and take the array's Length.Otherwise, count the lines while you collect the data, not afterwards.Dealing with a huge string isn't doing the caches any favors.And if...
Algorithms & Recipes
Posted: 11 May 2011   Updated: 11 May 2011   Views: 3,460   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
This alternative probably is less expensive than Andrew's alternate 1; rather than calculating the maximum value the enum can have, it checks each individual bit that is set in the input value, one by one. There is a hack involved, for any non-zero value the expression value & (-value) yields a...
Date and Time
Posted: 7 Mar 2010   Updated: 7 Mar 2010   Views: 15,801   Rating: 5.00/5    Votes: 15   Popularity: 5.88
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   Downloaded: 0
The code snippet below returns the first Thursday of a given year without iterating anything.DateTime FirstThursday(int year) { DateTime dt=new DateTime(year, 1, 1); return dt.AddDays((11-(int)dt.DayOfWeek)%7);}The formula used may seem a bit bizarre, it computes the distance...
Posted: 9 Oct 2011   Updated: 9 Oct 2011   Views: 3,160   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
I don't mind multiple exits in such a simple method, hence I'd write:public static bool Equals(this DateTime now, DateTime then, DatePartFlags flags) { if ((flags & DatePartFlags.Ticks) != 0 && now.Ticks != then.Ticks) return false; ... if ((flags & DatePartFlags.Month) != 0...
Programming Tips
Posted: 13 May 2010   Updated: 13 May 2010   Views: 20,240   Rating: 4.98/5    Votes: 31   Popularity: 7.43
Licence: The Code Project Open License (CPOL)      Bookmarked: 7   Downloaded: 0
Less magic, more readable, would be:DateTime dt1;DateTime dt2;if (DateTime.TryParseExact(str1, "dd-MMM-yyyy", null, DateTimeStyles.None, out dt1) && DateTime.TryParseExact(str2, "dd-MMM-yyyy", null, DateTimeStyles.None, out dt2)) { // do something with those datetimes}
Posted: 10 Jun 2010   Updated: 11 Jun 2010   Views: 21,300   Rating: 5.00/5    Votes: 7   Popularity: 4.23
Licence: The Code Project Open License (CPOL)      Bookmarked: 3   Downloaded: 0
Showing an image in a WinForm WebBrowser without using files
Posted: 25 Jul 2010   Updated: 25 Jul 2010   Views: 5,082   Rating: 4.93/5    Votes: 7   Popularity: 4.10
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
It may not be very fashionable, but when I need to know the inheritance chain while creating some code, I read the MSDN documentation page on the class of interest, and all is there, near the bottom, under Inheritance Hierarchy. And while I'm there, I typically read the entire page, there is...
Posted: 31 Aug 2011   Updated: 6 Sep 2011   Views: 16,070   Rating: 4.94/5    Votes: 7   Popularity: 4.23
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
Assuming the range of numbers is small, and all of them are required in the result (those are the assumptions implied by your code), and with a small change in the API definition, a much more compact and faster implementation would be this:public IList randomPermutation(int min, int max)...
Posted: 13 Jan 2012   Updated: 13 Jan 2012   Views: 7,010   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
I'm afraid there are better ways doing this, based on the power of the framework; in this case ColorMatrix is the tool to use. See e.g. here[^] (warning: make sure to use correct matrix elements, corresponding to the coefficients mentioned in the tip/trick).:)
String handling
Posted: 1 Jan 2011   Updated: 1 Jan 2011   Views: 7,921   Rating: 4.83/5    Votes: 5   Popularity: 3.15
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
Less code, and much faster, would be:public static string ReverseSB(string text) { int len = text.Length; if (len>1) { StringBuilder sb=new StringBuilder(text); int pivotPos=len/2; len--; for (int i = 0; i < pivotPos; i++) { int...
Posted: 1 Jan 2011   Updated: 1 Jan 2011   Views: 11,620   Rating: 4.88/5    Votes: 9   Popularity: 4.77
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
And even simpler, faster and better would be this:public static string ReverseCA(string s) { char[] chars=s.ToCharArray(); Array.Reverse(chars); return new string(chars);}Whatever the string's length, only three objects get created; and all characters get copied three...
Posted: 7 Jun 2011   Updated: 13 Jun 2011   Views: 10,300   Rating: 5.00/5    Votes: 8   Popularity: 4.52
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
Way too much code. Using arrays of characters, your switch constructs can be reduced to just a few lines of code, like so:switch (c) { case 'a': sb.Append("4"); break; case 'e': sb.Append("3"); break; case 'i': sb.Append("1"); break; ...
Author Resources
Posted: 3 Sep 2009   Updated: 16 Mar 2011   Views: 126,197   Rating: 4.93/5    Votes: 66   Popularity: 8.98
Licence: The Code Project Open License (CPOL)      Bookmarked: 41   Downloaded: 0
How to use PRE tags to preserve formatting, and improve readability of code snippets or tabular data in posts.
No reference articles have been posted.
No projects have been posted.

Luc Pattyn
Software Developer (Senior) Perceler
Belgium Belgium
I am an engineer with a background in electronics, software and mathematics.

I develop technical software, both for embedded systems and for desktop equipment. This includes operating systems, communication software, local networks, image processing, machine control, automation, etc.

I have been using all kinds of microcontrollers and microprocessors (Intel 4004/8080/8051/80386/Pentium, Motorola 680x/680x0/ColdFire/PowerPC, Microchip PIC, Altera NIOS, and many more), lots of programming languages (all relevant assemblers, Fortran, Basic, C, Java, C#, and many more), and different operating systems (both proprietary and commercial).

For desktop applications and general development tools I have been using both UNIX systems and Mac/MacOS for many years, but I have switched to x86-based PCs with Windows, Visual Studio and the .NET Framework several years ago.

I specialize in:
- cross-platform development (making software that runs on diverse hardware/OS combinations)
- instruction set simulation
- improving software performance, i.e. making sure the software runs the job at hand in as short a time as possible on the given hardware. This entails algorithm selection, implementation design, accurate measurements, code optimisation, and sometimes implementing virtual machines, applying SIMD technology (such as MMX/SSE), and more.

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190214.1 | Last Updated 21 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid