Owner: Bell End URL:http://doogalbellend.blogspot.com Join Date: Sat, 24 Mar 2007 17:04:06 -0500 Rating:0 Site Description: "quite amusing and drastically geeky at the same time" Site statistics:Click here
Meaningful descriptions for enums 2007-03-24 19:47:00 Getting a string representation of an enum is pretty simple, just call ToString() on the enum. However, we often want to have a more user-friendly string to display to the user, that includes spaces and the like. I guess one way of achieving this would be to override ToString on our enum class, except you can't override ToString in an enum... And how to go the other way, from the string representation to the enum? The solution set out below uses an EnumDescription attribute that can be applied to the values of an enum. Now I can't claim to have come up with the idea for this, I think I first saw it on Richard Blewett's blog, but his archive doesn't seem to go back as far as it should. Saying that, I've also made quite a few alterations so I can claim some of this code as my own. The use of generics means it will only work with .NET 2.using System;using System.Reflection;namespace Utils{ /// <summary> /// Attribute used to give textual descriptions to enums. /// Read more:Meaningful
Not liking Vista so much 2007-03-21 23:18:00 Doing a search on Google for 'liking Vista
' brings up this site as the third in the list. I'm not triyng to show off by saying this, but it perhaps shows that there's not that many people who are liking using Vista. And I'm slowly moving from the liking Vista camp to the not liking Vista so much camp. To be fair most of the problems I'm having probably aren't Microsoft's fault but they are still annoying. My major problem is the lack of sound coming out of my Dell Dimension machine. This was forgivable initially since I installed Vista before it hit the shops but even though Dell have released new drivers I still can't get anything to come out of my speakers. Vista thinks everything is OK, the only indication that something is wrong is the 'Failed to play test tone' error message when I do a test of my speakers. I've contacted Dell and talked to a tech support guy who said he'd get back to me and I've never heard anything from him since. It seems
Dude, where's my AdSense revenue? 2007-03-21 22:50:00 I was never going to become rich from my AdSense income, but I used to get a small amount of spending money from it. But over the last few months, even though I'm getting more hits to my sites, I'm getting less and less money from ads. I think it's down to the fact that I'm getting less money per click. There was a time when some clicks would earn me a dollar or more (which, to be fair, seems ridiculous) but now I'm lucky to get more than 20 cents per click. So I guess the question is whether there is a general downward trend in prices being paid for clicks or if Google is taking a bigger slice of the action. Of course it could be just me who's suffering from this and it may be something specific to my sites causing the lack of cash.
Twitter - What the ...? 2007-03-20 17:16:00 I don't get it, why would I want to use it? Why would I even want to read it, do I really care that complete strangers are on their way to work or having a dump? Even if there were people on there I knew, I wouldn't be interested. "Hmm, it's 11pm at night, what do you know, my rate Roger is off to bed, what a fecking surprise" I believe we are meant to be looking for ways to save energy these days, so if anybody has access to the power switch on the Twitter
server, just turn it off. You'll be saving us from the most pointless website ever and helping the environment at the same time.
Google, you are such a tease 2007-03-17 00:18:00 You really are. The Random Pub Finder gets an inbound link and you start indexing all our pages, we get lots of hits, then a couple of weeks later our pages start dropping out of your index again. It's a little bit frustrating.And perhaps more concerning is the power you wield. But so long as you stick to your 'Do no evil' mission statement, I'm sure there isn't a problem, right? Read more:Google
Things annoying me today 2007-01-19 18:15:00 Empty try-catch blocks - "Oh shit, this bit of code fails, I can't be bothered working out what's going on, I'll just catch the exception (and any other exceptions that are ever thrown) and ignore it. Oh and I won't bother putting a comment in the code to explain why I'm catching this particular exception, cos I don't really know why I am." Well, I guess the thought process is something like that. Pointless member variables - OK, so you know what a class is and you know what a member variable is, but that doesn't mean every single variable has to be a member variable. It doesn't make your code more object-oriented, it just makes it more complex. If it's only used in one function, then it probably only needs to be declared in that function. In a managed environment, it means the variable goes out of scope earlier and doesn't have to live for the entire life of the class instance. And your code is more maintainable. Although I'm guessing maintainability wasn't
Things annoying me today 2007-01-11 13:59:00 FOR XML RAW - Why on earth would you ever use this in a stored procedure? OK, I can think of one use, when you want to do some kind of XSLT on the stored procedure output to produce some HTML or whatever, but not just so you can treat the output from a stored procedure as an XML document. What's the point? Just traverse the record set using the provided database classes. Commented out code - If you're using a source control system (and if you're not then you're doomed), why leave commented out code lying around? It's all stored away in the file history. If I do a search for a call to a function, finding lots of commented out code is a waste of my time. Copy and paste code - It's great to fix a bug in some code, then to find it's been reproduced verbatim in 4 other places in the project...
Displaying a tick mark in HTML 2006-12-18 22:24:00 This afternoon's challenge was to get a tick mark to appear in a HTML file. Not too taxing I thought. I'd already done it, using the HTML entity ✓. But this didn't work properly in all browsers. I initially thought the problem was some kind of encoding problem but it seems that unfortunately it's one of those HTML things that works in 'modern' browsers but doesn't seem to work in IE6 (this ✓ should be a tick mark, if you're one of the lucky ones). Given that most people are still using IE6, it's not really an ideal solution. So what to do? I thought I'd search for a fairly common font that had a tick mark available. WingDings does and although it's a Windows font, I thought it would be available on enough computers to suit my needs. Unfortunately, as this page shows, FireFox doesn't display WingDings fonts at all, even when they are installed on the computer. Most odd, although it seems that this is how browsers should work... You may be asking why I didn't pl
Setting a display from: address using CDONTS 2006-12-14 16:02:00 Since it took me so long to find the answer to this problem I thought I'd post it here (and also so I don't need to look it up again). Not sure if this applicable to other ways of programmatically sending email but I guess it probably is. To show a friendly display name when setting the From: address of an email using CDONTS just use the following syntax - (Test address)<test@test.com> Read more:Setting
Build it and they will come 2006-11-02 15:01:00 After five years, the Random Pub Finder has finally become an overnight success. Google seems to have started re-indexing pages, although there's still a random nature to its indexing. We were up to 300 pages indexed, now we're back down to about 150. But the main reason for the sudden surge in traffic has been appearing at Programmable Web. Thanks to that, we've been covered on a couple of other sites. We've never had so many hits. Now I'm actually getting traffic here as well, thanks to this post. Seems I'm one of the top results on Google if you search for directmailchat. Clearly I'm not the only one suffering from this spam. Read more:Build
Exciting new website 2006-10-18 23:04:00 In their ongoing attempts at SEO, BetterDeal have got a new site (New Car Showroom) and they want some inbound links. Where better to get them than from here, with my huge number of visitors and massive PageRank? Read more:website
Hello World for ZX Spectrum lovers 2006-10-09 23:01:00 When I was a young lad, there was nothing I liked more than going down to my local Dixons after school and typing my very own HelloWorld
application into the nearest ZX Spectrum
. But the Hello World apps I see today just don't match up to the beauty and elegance of that original version, so I've written one for C# using System;namespace HelloWorld{ class App { [STAThread] static void Main(string[] args) { line10: Console.WriteLine("Doogal is cool!"); line20: goto line10; } }}Who says goto is evil? I think I might adopt this style for all my applications...
Programmable Web 2006-08-27 21:48:00 Just found this site, which looks like a useful resource for knocking together Web 2.0 (God I hate that term) mashups (God I hate that term) Read more:Programmable
How to choose colours for a website 2006-07-07 14:10:00 With my grade E in GCSE Art, my art skills have never been up to much. So my website
colour choices have always been pretty ugly. I was therefore very pleased to find Colour Blender, which makes the choices for you. Read more:choose
Weather Bonk 2006-05-17 17:13:00 Bonk probably has a different meaning in the US, but other than the strange name, this website is pretty good. I think it's pushing AJAX and Google Maps to its limits, as moving around can get pretty slow, but it has all the weather info you could ever need along with links to webcams. And even better, you can plug it into your own website in about two minutes.
Virgin Wines are spammers 2006-04-08 22:05:00 I can't remember how it all started. I think I entered some competition that offered the chance to win some free wine (how could I refuse?) and VirginWines
got hold of my email address. Soon I was getting an email every week or so exhorting me to purchase a case of wine. I've no idea whether Virgin Wines provide decent wine or not, but the fact I've got a Majestic Wines about five minutes away means I wasn't tempted to purchase anything from them, so I sent an email to unsubscribe@virginwines.com (after all they are reputable company, right?). Then, nothing. the emails kept coming. So I sent another. And the emails still didn't stop.Then I got an email from the founder of Virgin Wines, not apologizing but offering me more wine to buy. So I replied directly to him telling him his unsubscribe functionality didn't work. I then got an email from Customer Services saying "Thank you for contacting Virgin Wines and we have arranged for the email address you have provided to be removed Read more:spammers
Nobody has ever needed to do this before 2006-04-06 17:39:00 So I'm still trawling through this ASP.NET app and keep finding great WTFs. I spotted this method in one of the classesprivate ArrayList SplitString(string str, string separator)So presumably the writer of this piece of code assumed nobody had ever faced a similar problem before and might have provided a solution in the framework???? Anyway, that's some more redundancy I can get rid of. Read more:Nobody
The copy and paste anti-pattern 2006-04-03 17:10:00 I've just picked up somebody else's ASP.NET 1.1 application and like probably every developer who's picked up somebody else's code, I think it's crap.The thing that worries me most is how hard it is to create a new page. I create a new web form and then I have to copy and paste
the markup form another page. Then I need to go through and add a bit of code to the code behind file.ASP.NET provides lots of mechanisms to avoid having to do this (as does pretty much every other web development platform). We have page inheritance, so common code can be put in a parent class. We have user controls, so bits of repeated HTML can be put in them.OK, a bit of setting up of a new page may well be necessary but copying and pasting, whether markup or code, is a very bad sign. When the change request comes through (as it always does) to redesign the whole site, if every single file needs to be modified, life will be very painful.
There's a reason they are called exceptions 2006-03-10 22:10:00 Whenever you read about exceptions, one of the key points is that exceptions should only be thrown in exceptional circumstances. An example might be when a file the application can't survive without doesn't exist. However I've seen on several occassions now exceptions being used where the particular problem could be expected to happen on a fairly regular basis, if not every time the application runs.A common example can be found when trying to convert a string to an int. In .NET 1.1, int doesn't have a TryParse method so a quick and dirty approach to implementing similar functionality might be as shown hereint val = 0;try{ val = int.Parse(stringVal);}catch (FormatException){}This solution can be fine when stringVal will generally be a valid int, but if it's used when stringVal is often not a valid int (when reading the value from a config file that by default doesn't contain any value for instance), it can become annoying. Why's that then I hear you cry? Just turn off breaking
Not everything is high priority 2007-03-26 12:01:00 If every email you send to me is marked as high priority
, they tend to lose their impact, I assume none of them are important. What will you do when you really do want to send me a high priority email? There is no priority zero... I presume you're familiar with the boy who cried wolf?
The evil #if DEBUG 2007-03-30 23:19:00 I recently received a bug report for an ASP.NET site I've been maintaining but when I went off to test out the problem running the site through Visual Studio eveything worked fine. Slightly confused, I went back to the live site and immediately reproduced the problem. So I thought the problem must be caused by the site not being in sync with the the development box so I uploaded the latest code. The problem was still occurring... I was fairly unfamiliar with the code so I started stepping through it. You've no doubt guessed the problem by now from the title of this post. There was some code wrapped in an #if DEBUG directive that actually overrode the parameters passed into the page via a query string. I removed that and the problem on the live site was reproducible in Visual Studio. But I wasted an hour or so getting to the bottom of it. So the moral of the story is don't change behaviour of your code with #if DEBUG statements. The only use I've found for #if DEBUG i
Some useful web resources 2007-03-31 22:31:00 I came across a couple of useful websites today which I thought I'd post here for others and for my own information. First is Domain Tools, which provides the usual Who Is lookup and a whole lot more. Most useful I thought was the SEO text browser that shows how a website looks to a search engine and gives a few pointers to how your pages could be improved for SEO. That site led me to About Us, that is an interesting attempt at generating a Wiki for websites. I imagine this could become an interesting site to browse and find new sites to visit. If nothing else, adding your site will add another inbound link to your site. Another useful resource that I didn't find today but follows on from the SEO text browser above is the HTML Validator provided by the W3C. Running your site through this will show any problems with your HTML code. I've no idea if valid HTML will improve your search rankings but I'm fairly certain it won't hinder them.
The number one internet resource for Metastorm crap 2007-04-03 23:12:00 It's always interesting to look through the search terms that have led people here or to the other sites I have something to do with. It's certainly a great work avoidance tactic. So I was pleased to see that the term Metastorm crap had landed somebody here. Then when I did a search for Metastorm crap myself I was even more pleased to see I'm number one for that search term. So there you are, come here for all the Metastorm crap you could ever need... In fact I've just done a search for Metastorm shit and I'm number one for that as well! I must point out at this point that although the words may have appeared on the same page, they didn't actually appear in the same context... OK, they do now, but I'm not implying anything, OK?
Method calls on value types and boxing 2007-04-05 00:05:00 It was DevWeek 2005 and I was in a session with Jeff Richter about low level .NET things and I foolishly asked him a question. He looked at me as if I had asked the most dumb question ever asked by anyone, so I decided not to follow up on my question, even though I didn't feel he'd really given me the answer I was looking for. So what was the question? Well he was describing boxing
of value types
and how it can cause performance problems so it was best to avoid it where possible, even though it's not always clear when boxing is occurring. I'd asked didn't boxing need to occur for any method call on a value type. On reflection I'm not sure this was a particularly dumb question but I've never really got fully to the bottom of it, mainly because it's never really been much of an issue to me. But here's my take on it, which may or may not be accurate. Boxing is only going to happen if the method call is a virtual method where the value type doesn't override the bas Read more:calls