Click here to Skip to main content

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

Articles: 8, Tip/Tricks: 13

RSS Feed

Average article rating: 4.88

Files and Folders
Files
Posted: 27 Aug 2009   Updated: 31 Aug 2009   Views: 43,517   Rating: 4.88/5    Votes: 38   Popularity: 7.71
Licence: The Code Project Open License (CPOL)      Bookmarked: 63   Downloaded: 603
My entry to the lean-and-mean programming competition.
Applications & Tools
CodeProject Tools
Posted: 4 Jan 2010   Updated: 24 Feb 2010   Views: 21,105   Rating: 4.97/5    Votes: 31   Popularity: 7.42
Licence: The Code Project Open License (CPOL)      Bookmarked: 30   Downloaded: 186
From automatic code recognition to fully automated code snippet pasting; no more missing PRE tags!
C#
Delegates and Events
Posted: 24 Jul 2007   Updated: 24 Jul 2007   Views: 56,123   Rating: 4.76/5    Votes: 43   Popularity: 7.78
Licence: The Code Project Open License (CPOL)      Bookmarked: 64   Downloaded: 499
Delegates: how to add them to an event, how they get removed and when that is necessary
General
Posted: 2 Feb 2007   Updated: 2 Feb 2007   Views: 105,342   Rating: 4.82/5    Votes: 69   Popularity: 8.85
Licence: The Code Project Open License (CPOL)      Bookmarked: 97   Downloaded: 2,046
A simple app demonstrates unexpected behavior of .NET timers and Thread.Sleep(); native multimedia timers come to the rescue.
.NET Framework
General
Posted: 22 Mar 2010   Updated: 8 Jun 2011   Views: 96,923   Rating: 4.93/5    Votes: 80   Popularity: 9.39
Licence: The Code Project Open License (CPOL)      Bookmarked: 65   Downloaded: 1,353
A viewer for CodeProject's recently introduced reputation information; futile, but fun
Bugs & Workarounds
General
Posted: 30 Jul 2007   Updated: 30 Jul 2007   Views: 22,858   Rating: 4.89/5    Votes: 16   Popularity: 5.89
Licence: The Code Project Open License (CPOL)      Bookmarked: 29   Downloaded: 235
ow to copy code snippets with Internet Explorer while preserving newlines and indentation
Game Development
Games
Posted: 16 Jan 2007   Updated: 16 Jan 2007   Views: 32,258   Rating: 4.88/5    Votes: 13   Popularity: 5.43
Licence: The Code Project Open License (CPOL)      Bookmarked: 18   Downloaded: 1,035
A simple Sokoban implementation in C# with some extras
Hardware & System
System
Posted: 16 Jul 2007   Updated: 16 Jul 2007   Views: 41,673   Rating: 4.91/5    Votes: 18   Popularity: 5.91
Licence: The Code Project Open License (CPOL)      Bookmarked: 28   Downloaded: 1,660
A utility that removes phantom icons from the Icon Tray
No blogs have been submitted.

Average tips rating: 4.96

.NET Framework
General
Posted: 10 Jan 2012   Updated: 10 Jan 2012   Views: 2,816   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
General
Posted: 11 May 2011   Updated: 11 May 2011   Views: 1,374   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
General
Posted: 7 Mar 2010   Updated: 7 Mar 2010   Views: 6,294   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: 1,220   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
General
Posted: 13 May 2010   Updated: 13 May 2010   Views: 9,810   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: 10,259   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: 2,080   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: 4,113   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: 3,243   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
General
Posted: 1 Jan 2011   Updated: 1 Jan 2011   Views: 2,724   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: 4,364   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: 3,815   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
General
Posted: 3 Sep 2009   Updated: 16 Mar 2011   Views: 72,771   Rating: 4.93/5    Votes: 66   Popularity: 8.98
Licence: The Code Project Open License (CPOL)      Bookmarked: 42   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.

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 | Mobile
Web01 | 2.8.141015.1 | Last Updated 21 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid