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.85

Files and Folders

LPTextFileDiff: another textfile compare utility.
Posted: 27 Aug 2009   Updated: 31 Aug 2009   Views: 30,421   Rating: 4.88/5    Votes: 38   Popularity: 7.71
Licence: The Code Project Open License (CPOL)      Bookmarked: 59   Downloaded: 313
My entry to the lean-and-mean programming competition.

Applications & Tools

PRE tags galore: LPCodeRecognizer
Posted: 4 Jan 2010   Updated: 24 Feb 2010   Views: 14,360   Rating: 4.97/5    Votes: 29   Popularity: 7.26
Licence: The Code Project Open License (CPOL)      Bookmarked: 27   Downloaded: 114
From automatic code recognition to fully automated code snippet pasting; no more missing PRE tags!

C#

Facts and Fallacies of Events in C#
Posted: 24 Jul 2007   Updated: 24 Jul 2007   Views: 44,364   Rating: 4.76/5    Votes: 42   Popularity: 7.73
Licence: The Code Project Open License (CPOL)      Bookmarked: 60   Downloaded: 359
Delegates: how to add them to an event, how they get removed and when that is necessary
Timer surprises, and how to avoid them
Posted: 2 Feb 2007   Updated: 2 Feb 2007   Views: 78,122   Rating: 4.81/5    Votes: 68   Popularity: 8.81
Licence: The Code Project Open License (CPOL)      Bookmarked: 85   Downloaded: 1,099
A simple app demonstrates unexpected behavior of .NET timers and Thread.Sleep(); native multimedia timers come to the rescue.

.NET Framework

CP Vanity
Posted: 22 Mar 2010   Updated: 8 Jun 2011   Views: 59,163   Rating: 4.93/5    Votes: 77   Popularity: 9.31
Licence: The Code Project Open License (CPOL)      Bookmarked: 56   Downloaded: 786
A viewer for CodeProject's recently introduced reputation information; futile, but fun

Game Development

Tackle complex puzzles with LP Sokoban#
Posted: 16 Jan 2007   Updated: 16 Jan 2007   Views: 26,296   Rating: 4.88/5    Votes: 13   Popularity: 5.43
Licence: The Code Project Open License (CPOL)      Bookmarked: 16   Downloaded: 649
A simple Sokoban implementation in C# with some extras

Bugs & Workarounds

Code Rescue: Copying code from CodeProject to Visual Studio
Posted: 30 Jul 2007   Updated: 30 Jul 2007   Views: 18,783   Rating: 4.89/5    Votes: 15   Popularity: 5.75
Licence: The Code Project Open License (CPOL)      Bookmarked: 27   Downloaded: 175
ow to copy code snippets with Internet Explorer while preserving newlines and indentation

Hardware & System

LP#TrayIconBuster
Posted: 16 Jul 2007   Updated: 16 Jul 2007   Views: 27,631   Rating: 4.71/5    Votes: 17   Popularity: 5.80
Licence: The Code Project Open License (CPOL)      Bookmarked: 26   Downloaded: 575
A utility that removes phantom icons from the Icon Tray
No blogs have been submitted.
No video articles have been posted.

Average tips rating: 4.98

.NET Framework

Counting lines in a string [Tip/Trick]
Posted: 10 Jan 2012   Updated: 10 Jan 2012   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

See if a Flags enum is valid [Tip/Trick]
Posted: 11 May 2011   Updated: 11 May 2011   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

Week numbers according to ISO8601 [Tip/Trick]
Posted: 7 Mar 2010   Updated: 7 Mar 2010   Rating: 5.00/5    Votes: 15   Popularity: 5.88
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   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...
Partial DateTime Object Equality [Tip/Trick]
Posted: 9 Oct 2011   Updated: 9 Oct 2011   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

Validating dates in dd-MMM-yyyy format [Tip/Trick]
Posted: 13 May 2010   Updated: 13 May 2010   Rating: 4.98/5    Votes: 30   Popularity: 7.35
Licence: The Code Project Open License (CPOL)      Bookmarked: 4   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}
WebBrowser shows File-less local Image [Tip/Trick]
Posted: 10 Jun 2010   Updated: 11 Jun 2010   Rating: 5.00/5    Votes: 7   Popularity: 4.23
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
Showing an image in a WinForm WebBrowser without using files
Following object inheritance [Tip/Trick]
Posted: 25 Jul 2010   Updated: 25 Jul 2010   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...
How to generate many random various numbers? [Tip/Trick]
Posted: 31 Aug 2011   Updated: 6 Sep 2011   Rating: 5.00/5    Votes: 5   Popularity: 3.49
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)...
Convert RGB to Gray Scale without using Pointers [Tip/Trick]
Posted: 13 Jan 2012   Updated: 13 Jan 2012   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

Extension Methods to Reverse a String and StringBuilder Object [Tip/Trick]
Posted: 1 Jan 2011   Updated: 1 Jan 2011   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...
Extension Methods to Reverse a String and StringBuilder Object [Tip/Trick]
Posted: 1 Jan 2011   Updated: 1 Jan 2011   Rating: 5.00/5    Votes: 8   Popularity: 4.52
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...
L33t Tr4nsl4t0r (Leet Translator) [Tip/Trick]
Posted: 7 Jun 2011   Updated: 13 Jun 2011   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

Using PRE tags on Code Project [Tip/Trick]
Posted: 3 Sep 2009   Updated: 16 Mar 2011   Rating: 4.93/5    Votes: 64   Popularity: 8.90
Licence: The Code Project Open License (CPOL)      Bookmarked: 36   Downloaded: 0
How to use PRE tags to preserve formatting, and improve readability of code snippets or tabular data in posts.

Luc Pattyn

Software Developer (Senior)
Perceler
Belgium Belgium

Member

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.5.120517.1 | Last Updated 27 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid