Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

Justin Lovell's Blog

Mood: The Grumpy Coder

  • Think you've got a memory leak?

    Earlier this week, Teemu Keiski asked me if I knew of a way to check the memory consumption of AppDomains in a process. You may ask why there was multiple AppDomains in a process -- because the server that he was running the ASP.NET applications was Windows 2000. There has been quite a bit of guess work from my end of what could be going wrong and why?

    Eventually, I came to conclude that it was an application that was always "washing" in and out a huge collection from the database. There were several constraints on what he could do: it was a live server so he could not profile any application as such. The one thing that really frustrated both of us is that the misbahving application could be pinpointed. Or can it?

    I just ran over this article from www.TheServerSide.com. And it is awesome! Wish I knew of this method earlier.

  • Multi-threading... processes... splitting the atom... eish!

    To start off, I am fairly new to threading. One of the recent “module” requirements and other future “module” requirements caused enough reason to start a small framework for time-slotted batch services. Basically, the idea is to have a thread running one 'process' in a certain reoccuring time slot (let's say for every one hour). If a 'process' is unable to complete itself in the allocated time slot, the process then creates a splitted-process to participiate over multiple threads. In practical terms, the 'process' just continously splits itself into more processes until n amount of threads are able to allow a 'process' to complete its task within the allocated time slot. Something that I would like to call “splitting the atom.”

    We all know that when we split atoms, it is followed by a “kaaaboooommmm!” That is why I was so wary when designing this framework. It works very well under simulated unit tests (I've written about a day's worth of code for testing). Extremely well. I can bet my next pay check that this thing is able to scale without a problem... and that is the source of my cold-sweeted nightmares. Generally, things can go terribly wrong with multi-threading and the usual cause is because there are race conditions happening. :-/. That is not the case under my framework -- there is no race conditions but I can't get rid of the images that I might get that “kaaaboooom” and dreaming about the possible framework enhancements to unleash some restrictions that might be encountered.

    Do you get multi-threading nightmares at night?

  • Entertainment for the Bus and this 'n that

    (This is a long blog post but each thought runs into each other).

    Ok, I was a bit rash in my previous blog post. I got a pretty good suggestion from James that I could get stoned :-). Too late becaise I have already started with the medical aid broker as a non-smoker... and as a side note, I've never had a 'joint' despite all the temptations that I experienced for the last four years. I'm personally proud of it. So my plan was today (since I did not have any time to do a quick check up of my mail to see what suggestions came through since the post) was to load a web cast on to the Tablet PC (in future, it would be refered to as “Jabit”). Man, was I pissed when I found out while on the bus that I copied to the wrong web cast. And on top of that... I'm already bored with all of these web casts. Nothing interesting whatsoever. I don't think I will be doing any further public exercises with Jabit -- it just feels weird while on the bus, if you know what I mean.

    While the Durban MVP gang and I went to Microsoft's headquarters, at the end of last month, I struck up a deal to swop one of my Refactoring Patterns for The Gang Of Four Patterns with Ernst Kuschke. I'm still waiting for his end of the bargain to be met -- I've got no thought provoking text on my shelf now. Nevermind dude, this post is just another of those reminders ;-).

    Talking about text for the bus, I also just recently brought a year's subscription to MSDN magazine. I don't know what to really expect because I have only started getting “text books” and magazines in the last two months or so. Talking about the Microsoft camp out and magazines -- I, amongst the other South African MVP's, should be featured in the January's edition of TechNet.

  • Fun things to do on public transport

    Essentially, I want to open this blog post to ask: what weird and wacky things have you done on public transport? I'm running out of ideas on civil things to do. Let me recite on what I tried to do today: while on the bus, I was trying to plan the day ahead of me (hey, it is an hour on the road). Little did I expect that while you are travelling in a bus, you feel every small stone that the bus goes over with little bouyancy. In addition... you feel the brakes when it is applied. It is completely different to a car or mini-bus.

    So that also throws away my next activity: using a Tablet PC on the bus. My handwriting looks like I have been writing italics all my life whilst on the bus. And oh, the constraint here is that hardly anybody talks on the bus... and if there is talk, it is gossip which I steer clear of. :-/. Anything else?

  • Can you send that code in VB.NET?

    That is the most common question that I get after responding to forum posts with the longest bloody code listings. Then the guy turns around and asks “Can you write that in VB.NET? Please!”

    Dudes, if that guy asked me that question right in front of my face, he would have got one wallop from me. The reason being that I have wasted time with the code listings: the possibility of it being undecipherable by the person asking is high. Therefore, my original mission was not completed -- I did not help him. In addition, my assumption was wrong because they normally refer to C# code listings in other articles and don't mention their preference language is VB.NET. And then the arrogrance that I must drop everything to help by translating it. I would probably have to go and revisit that thread over and over again because I got the translation wrong (hey, I do my forum posts in notepad). So can anyone blame me of stepping down on an oke today, with a very simple policy being...

    I refuse to spend another five to ten minutes writing out code. I could be helping someone else out whom is not picky about languages. Get yourself a C# to VB.NET translator if you battle with C#.

  • Frustrated with Visa's due to 9/11

    This is the emotion that I am feeling right now: frustration. To fill the readers in, I have been offered two jobs in the United States. Both of them sounding very promising to add a nitric boost to my career. I am not going to say where I left off in my thought process but it came a reality that I simply cannot enter the USA with a visa that allows me to conducate any sort of business on USA soil.

    Here I am with the two job offers and both of these companies really want me. I could quote some things that they said about my “skill set” which any candicate wants to hear but I cannot grab the oppurtunities. This is frustration at its best and I will be doing something in the near future to get the US immigrant department to see that I am not there to fool around. I don't know how I am going to pull it off with the achieving the two critical requirements but I am pretty determined.

    So if you don't see me in the community for a while (for a week or two), I will be in a sort of pissed off / frustrated / disappointed mood. I'll get over it in day or two but for now, I am just going to write ad-hoc projects to keep my mind focussed on something else. I really wish 9/11 never happened because it sure has affected everyone in the world negatively in one way or another :-/.

    Listening to: Eminem - Lose yourself.

  • I must be the bravest (most stupid) software developer in South Africa

    To get the international guys up to speed, I pledged to www.sadeveloper.net a while ago that I was going to be “witty, daring and incredibly stupid.” Well, when I first said that, the plan was to bombard a radio station to make an announcement (a subtle one) that will solve my commuting problem. Let's say that statement is also true on my latest stunt that was pulled off today: I catch a public bus / mini-bus taxi combination whilst waiting in the middle of town for about forty minutes throughout the day. This is a fact: I put my life on the line of fire here!

    Besides that, I was almost mugged this morning. Because I knew that I was in a dangerous (criminal haven) area, I was on constant alert. For the South African readers: no, absolutely no “blacks” were the problem; it was the indians. All I saw was two guys approach me and the both stood on either side of me. Three seconds followed and then I took a look at what they were looking at. The had their eyes fixed on my pockets and my carry bag (some people mistake it for a lap-top bag). I quickly reacted by walking away... and on top of that, because I was busy trying to ensure that no one else was 'interested' in me, I almost missed the only mini-bus to my destination. One more fact: if any Durbanites ever want to play dodge-ball, sprint across West Street whilst the traffic lights are green.

    Got another story or two tell you guys but my time is up... 12:00 and I am still awake. I am sure my boss will not mind me yawning since I am missing my most valuable piece of equipment at work: my monitor (short story: it is in for repair for four days). I am currently working with a resolution of 640x480 (or some dodgy thing like that).

  • First Day in a Workplace

    Edit: fixed hyperlink.

    Yes, it is a very important thing in my life so mind you :-). The most important thing that I want to say is that it is amazing how true things are from the stories you hear, which things are not true and best of all, which things are exagratted between leeps and bounds. Basically, a little run-down on the company that I work for is MITSOL (www.mitsol.co.za) and I am part of the three man ASP.NET development team. The current project that I am working on, is a portal type of application but I am the only one in charge of working and completing that project. The basic object of me being on that project is to get the feel how the the team's source control and so forth. I just can't wait for tomorrow to actually work again on a mission -- not a write up or a “lousy” forum post; I mean that it is something to strive for in a new challenging and exciting way.

  • My method: formatting code for blog posts

    I was asked how do I format code for blog posts. Well, to be honest, most of the code that I write in blog posts (and forum posts) are written on the fly, hence the formatting is also done on the fly. However, when I do come to copying and pasting code, I follow these steps:

    1. Copy the code into notepad.
    2. Copy the tab character into the clipboard.
    3. Do a find/replace and paste the tab character from the clipboard for the “find” field. It should appear as a square box.
    4. In the “replace with” field, I then place three spaces. Then hit the magic replace all button.
    5. Cut and paste into the blog entry.
  • Things can't get more worse than this

    Allow me to introduce my current MSN display name: “Smile,” they said, “things could be worse.” ... they were right -- it did get worse.

    Sigh. It must be nature's calling not to allow me to finish this project. However, I am determined to finish it -- I have ducted-tape quite a bit of “resources.” Now I am tired, I need sleep... but must continue onwards. I got to slaughter this VS.NET crap out of my machine. Right now, I am uninstalling it -- all of it. I am much more happier coding with notepad. The only problem is that I need a debugger and everything is falling apart. Also, the local forums are filled with little bug holes... I just lost a good fifteen minute of “steam” into a post only to be lost when I submitted the post.

    One thing that has gone right is that I landed a job. A very nice pay (for me) which will be renegotiated after three months. And the best of all: the company that I will be working for seems really cool in terms of flexibility and the enviroment. I think that I am really going to enjoy myself there... the problem that I am still stuck with: how do I get there? :-P. My current options are to spend four hours on the “road” (actually, most of the time will be waiting for connection buses) or allow someone to drive 120km a day. And to make matters worse, no one can easily penetrate into the Bluff area just to pick me up because the major on and off ramps are under construction... so may I ask a hypotheorectical question without any “whys”? Why is everything working against me?

  • Flop of the day

    Armand did the biggest flop of the day. All I know was gracefully admiring the manual of my next motherboard when a MSN conversation of 12 people popped up with the word “shit” following miliseconds later. At that stage, it was dawned on him that he wanted to add one person to a conversation that he was already having but he instead added a whole group.

    I have no problem at all: I managed to add a few more South African people to my MSN list. Only if flops like these happened more often!

  • Still alive but head is close to being submerged

    Hi guys and girls,

    I just wanted to pop-in and say “hi!” No, I am not dead. I have experienced so much problems in the last 30 days, I do not know where to begin. One of my starting positions is that I am not blogging from my own PC (anymore? Read on more details below) so this will be a rushed blog post so please mind the misspells and grammer errors. (The misspells will be due to this keyboard -- I am still deep in wonder how the owner of this PC actually types with this keyboard; it is aweful!)

    My dad runs his own business from home and his PC broke down. I suspect it is the motherboard and right now, I am waiting for the dead PC to be picked up... it just simply does nothing when the power goes on (it is not the power supply -- it was tested as my dad's trade has to do with electronics/electricity). Guess whose PC had to be 'stolen' to replace his? Mine but I gave it up willingly: my life has been too hectic to even get behind my own PC and do my own thing... what I have done in the last 25 days is log-in, fetch the email and respond to the very urgent ones, then log off... and do some research into some subjects. I have no worries after when this chaotic phase of my life is over: I am waiting for a transaction to come through to my bank account and I have my eyes set on getting a heck of a NICE PC.

    Since becoming an MVP, a lot of oppurtunities have opened. I can't talk about what is possibly going to be coming down the tubes as yet because it is not all finalized. All I can say is that I should be at Sun City (an international holiday resort for all of the non-South African readers) right now, enjoying the Tech-Ed conference, but my highest priorities just couldn't allow that. And to ensure that I took the bitter pill is that all of my study material was completely exhausted this morning, shortly after one hour of being awake (I usually wake up at 05:45 ever since the beginning of the exam “term”). I feel that I know my work for the next four exams -- from tomorrow onwards, I will be writing Maths (algebra), Technical Drawing (geometry), Computer Studies (theory) and just before the weekend, Maths (geometry and trignometry). After getting those exams out of the window, it will be smooth sailing until November the 10th.

    One of my duties now with the very unbiased (for my future's sake) prioritizing, I have missed a contract deadline and I have to write THAT email. I told them that I would not be able to start from November the 11th and yet they insisted that I should do one “quick thing” for them. I am not putting blame onto them -- I just blame myself for taking on something that I knew that I would not have the time to do it. The last 30 days was completely impossible to get ANY coding done (and I am suffering from withdrawel symptoms ;-)). I am going to write that email right now whilst I have time...

    And just for your information, I will return soon to answer some questions asked in the previous blog post. (At least 10 days).

  • The other Durban MVP that I know of

    I just met him today. I woke up this morning and just had to meet the second MVP from Durban. I went through to the kitchen and made myself some breakfast. I had to make a run for it because the local user group “meeting” that I was meant to attend starts in five minutes and it is a 25 minute drive to the place.

    I darted into the bathroom to brush my teeth and wash my face. I then started dreaming about the second MVP that I was going to meet today: he is smart, good-looking and is quite young. I then saw his face staring blankly at mine... but that face looks oddly familiar. My head “clicks” onto where I have seen that face before -- that's right, it is mine.

    If you did not fancy the creative writing I just wrote out, then here is the message to all of you folks: I am an MVP for the ASP.NET product group. I actually did not see myself getting even one nomination. Then came the dreaded email that arrived in my inbox about two months back. At first, I thought that I should turn down the nomination but I pondered on it for a moment or two that someone has taken his or her time to nominate me. So I thought that I would obediently fill in the required information -- thinking that I am flattered by the nominee yet I had a gut feeling that I would not make it.

    Off I went to pretend that I was “happy” to Teemu. Much later, he revealed to me that he was the nominee. Look -- he found almost every excuss he could find to talk to me. I thought that I would never really have a chat with him because he was out of my “league”. But it proved pointless to resist talking to him. He is a great guy -- there is no denying of that! I think he was more nervous than me throughout the day waiting for the results being revealed (BTW Ben, well done on the delay :-) -- you had the suspence going there... for Teemu).

    From there onwards, I began bits and pieces from the Durban leads for www.sadeveloper.net. Those bits and pieces slowly but surely revealed that I had a chance for the title. That is another story on its own... but I am glad that the nomination 'just' happened! Why, you may ask? Because it has put me in contact with Ernst and Stuart Gunter. To be quite frank, I was a bit shy to join the local guys because it is completely different.

    But the title that I have been awarded is the cream on the top of story. And I am eternally grateful to Teemu because without him, so much good would not have happened in the follow-up weeks from the nomination.

  • Comments on some article comments

    I just thought it would be beneficial to all if I comment on two comments that I recieved on my article about keeping scrollback position. Let's start off with the contridictary comment:

    Is this the same code as here, did Justin acknowledge Stanley Glass? Even though it is in VB.

    I am unsure. Just look at the date of my article and compare it to the newsgroup post. You should find that Stanley should be the one acknowledging my work... not the other way around. I have already complained a little bit on someone else's blog that people were just replicating my code and passing it off as theirs.

    This will save a lot of people frustration using smart navigation. This is what you would expect from the development community and shows we are all out to solve the same problems. I hope Microsoft solves this problem with ASP.NET 2.0?

    Your hopes and desires are Microsoft's dream :-). Fortunately, Microsoft makes dreams come true. To enable keeping scrolling over post backs, all you have to do is have the following code on your page:

    <%@ Page MaintainScrollPositionOnPostback="true" %>

    Or you can enable it in the web.config file on the page section:

    <page maintainScrollPositionOnPostback="true" />

  • SQL Pagination -- the final solution

    In a previous blog post of mine, I said that Cursors are slow. Little did I know that I was going to come up with an excellent paging solution that... ermm... involved cursors. This took some really abstract thinking to achieve the following script:

    Declare @TotalRows int
    Set @TotalRows = @StartRow + @RowCount

    Declare @PK int
    DECLARE @tmpTable TABLE (
        PK int NOT NULL PRIMARY KEY
    )

    Set RowCount @TotalRows

    DECLARE PagingCursor CURSOR DYNAMIC READ_ONLY FOR
     Select PrimaryKey From LargeTable
       [WHERE CLAUSE]
      Order By PrimaryKey

    Open PagingCursor
    Fetch Relative @StartRow From PagingCursor Into @PK

    while (@RowCount <> 0) And (@@Fetch_Status = 0)
    begin
     Insert Into @tmpTable (PK)
      Values (@PK)

     Fetch Next From PagingCursor Into @PK
     Set @RowCount = @RowCount - 1
    end

    Close PagingCursor
    Deallocate PagingCursor

    Select LargeTable.* From LargeTable
     Join @tmpTable temp ON LargeTable.PrimaryKey = temp.PK
     Order By PrimaryKey

    Set RowCount 0

    The above is quite logical on how things work. So far, this is the fastest solution and best solution to the “generic” mark-up of paging results.

More Posts Next page »