Click here to Skip to main content
15,905,967 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
JokeRe: RLIOTD Pin
Super Lloyd5-May-21 15:07
Super Lloyd5-May-21 15:07 
GeneralRe: RLIOTD Pin
Gerry Schmitz5-May-21 16:49
mveGerry Schmitz5-May-21 16:49 
GeneralRe: RLIOTD Pin
jsc425-May-21 22:11
professionaljsc425-May-21 22:11 
GeneralRe: RLIOTD Pin
11917640 Member 7-Jun-21 20:15
11917640 Member 7-Jun-21 20:15 
JokeRe: RLIOTD Pin
Bernhard Hiller6-May-21 21:41
Bernhard Hiller6-May-21 21:41 
GeneralRe: RLIOTD Pin
Gary Wheeler7-May-21 2:29
Gary Wheeler7-May-21 2:29 
GeneralRe: RLIOTD Pin
jsc427-May-21 2:49
professionaljsc427-May-21 2:49 
GeneralRe: RLIOTD Pin
Gary Wheeler7-May-21 2:56
Gary Wheeler7-May-21 2:56 
JokeRe: RLIOTD Pin
Greg Utas7-May-21 3:41
professionalGreg Utas7-May-21 3:41 
GeneralRe: RLIOTD Pin
Gary Wheeler7-May-21 3:46
Gary Wheeler7-May-21 3:46 
GeneralRe: RLIOTD Pin
jsc427-May-21 6:01
professionaljsc427-May-21 6:01 
GeneralUhhh... Pin
Brisingr Aerowing20-Apr-21 12:50
professionalBrisingr Aerowing20-Apr-21 12:50 
GeneralRe: Uhhh... Pin
Jon McKee20-Apr-21 13:23
professionalJon McKee20-Apr-21 13:23 
GeneralRe: Uhhh... Pin
MarkTJohnson21-Apr-21 5:00
professionalMarkTJohnson21-Apr-21 5:00 
GeneralRe: Uhhh... Pin
Gary Wheeler5-May-21 10:51
Gary Wheeler5-May-21 10:51 
GeneralRe: Uhhh... Pin
Brisingr Aerowing7-May-21 13:37
professionalBrisingr Aerowing7-May-21 13:37 
GeneralRe: Uhhh... Pin
Gary Wheeler7-May-21 13:47
Gary Wheeler7-May-21 13:47 
GeneralRe: Uhhh... Pin
Greg Utas7-May-21 14:41
professionalGreg Utas7-May-21 14:41 
GeneralRe: Uhhh... Pin
Gary Wheeler7-May-21 15:01
Gary Wheeler7-May-21 15:01 
GeneralThere are times when I really wonder exactly what I was thinking ... Pin
OriginalGriff29-Mar-21 23:26
mveOriginalGriff29-Mar-21 23:26 
I'm changing ISP's in a week or so, so I resurrected an old app I wrote to monitor my ISP and tell me when it changed.

And it didn't work any more, because the IP Geolocation service I was using has changed and needs an API signup instead of presenting the data as CSV.

So, I thought I'd re-write it using HtmlAgilityPack.
But it was odd that I got no error message in the original code ... until I spotted this:
C#
private void FillInDetails(string host)
    {
    Timestamp = DateTime.Now;
    IPAddress addr = IPAddress.None;
    try
        {
        using (WebClient wc = new WebClient())
            {
            if (string.IsNullOrWhiteSpace(host))
                {
                host = "http://freegeoip.net/csv";
                }
            else
                {
                host = string.Format("http://freegeoip.net/csv{0}{1}", "/", host);
                }
            string data = wc.DownloadString(host);
            string[] sections = BreakCSVLine(data);
            if (sections.Length != freegeoipDataSectionsCount) throw new ArgumentException("Data returned from FreeGeoIP has changed format!");
            addr = IPAddress.Parse(sections[freegeoipDataAddress]);
            CountryCode = sections[freegeoipDataCountryCode];
            Country = sections[freegeoipDataCountry];
            RegionCode = sections[freegeoipDataRegionCode];
            Region = sections[freegeoipDataRegion];
            City = sections[freegeoipDataCity];
            Zipcode = sections[freegeoipDataZipcode];
            TimeZone = sections[freegeoipDataTimeZone];
            Area = sections[freegeoipDataArea];
            float lat = float.Parse(sections[freegeoipDataLatitude]);
            float lon = float.Parse(sections[freegeoipDataLongditude]);
            LatLong = new PointF(lon, lat);
            }
        }
    catch (Exception)
        {
        // Ignore errors (it probably means the router is down...)
        }
    Address = addr;
    }


So I carefully create my own exception to tell me why it's not working ... and then explicitly ignore it.
I do wonder about past-me's thought processes sometimes ... Sigh | :sigh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: There are times when I really wonder exactly what I was thinking ... Pin
Marc Clifton6-Apr-21 14:45
mvaMarc Clifton6-Apr-21 14:45 
GeneralRe: There are times when I really wonder exactly what I was thinking ... Pin
Sander Rossel11-Apr-21 0:32
professionalSander Rossel11-Apr-21 0:32 
GeneralRe: There are times when I really wonder exactly what I was thinking ... Pin
Bernhard Hiller6-Apr-21 20:52
Bernhard Hiller6-Apr-21 20:52 
GeneralRe: There are times when I really wonder exactly what I was thinking ... Pin
Dan Neely20-Apr-21 5:39
Dan Neely20-Apr-21 5:39 
GeneralC++ & Thinking about SSD & wear level Pin
raddevus27-Mar-21 11:58
mvaraddevus27-Mar-21 11:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.