Archive

Archive for August, 2009

Excel VBA macro – removing blank rows from table

August 5th, 2009 Paul No comments

news

I know not too many people are coding VBA macros, however if you think about it automating office tasks can be a good way to help business people.  I can tell you that most coders will not touch it thinking that users should be able to do this themselves, most users will not be able to do this, simply because you need to actually write the code.  I can tell you that knowing VBA earned me a pretty coin, and trust me, this is not too hard to learn. 

Here is an example of how to remove all blank rows from a table in excel:

Read more…

Categories: Code Samples Tags: ,

What recent computer science graduate should know.

August 4th, 2009 Paul No comments

wheels

Many many years ago when I landed my first coding job, I was amazed at how different working in a software development shop was different from what I had pictured in my mind.  At that time, I did not even graduated yet, I was in need of money and it seemed like a great opportunity so I took the job.  While driving to my new place of employment for the first time, I was running some scenarios in my head, trying to remember some tested and true algorithms, thinking of whole bunch of technical things that might help me impress my then new boss; what came as a complete surprise to me was the fact that I had no idea what the work was about.

After couple of weeks, I began to realize that many things that were part of my job were not covered in school at all.  I can’t really blame school for that, after all they were trying to give me as much information as they could about technical aspects – languages, algorithms and all that jazz, I myself had failed to learn the truth about real time work of a coder, and I did have opportunities to do so.  Later on when I became a manager and was interviewing people for coding positions, I realized that I was not unique in this lack of knowledge.  Most of the recent graduates were in the same boat that I was in years ago. Read more…

Twitter API with C# example(part 2)

August 2nd, 2009 Paul No comments

sundial

First of all, I have to admit that I decided to take a vacation. Vacation from everything – work, freelance, projects, blog, etc. It’s summer and despite the crappy weather here in Toronto, I am spending time with my family which actually rocks. Now vacation is over, let’s get back to coding – today I wanted to continue with Twitter examples. Twitter seems to be very hot, and I was curious as to how to get the most out of it from the coding perspective. Here is a tiny function that gets the followers of a user, providing we know the username and password:

  |  copy code |? 
01
public string FetchFollowers(string userName, string password)
02
{
03
    using (var client = new WebClient())
04
    {
05
        client.Credentials = new NetworkCredential(userName, password);
06
        try
07
        {
08
            using (var stream = client.OpenRead("http://twitter.com/statuses/followers.xml"))
09
            {
10
                using (var reader = new StreamReader(stream))
11
                {
12
                    return reader.ReadToEnd();
13
                }
14
            }
15
        }
16
        catch (WebException ex)
17
        {
18
            //insert code to deal with exception HERE               
19
        }
20
    }
21
    return string.Empty;
22
}

There are two types of “connection” between the people on twitter – followers and friends – I am too lazy to look up the difference between the two, but if you want list of friends then line 8 in the function above should look like this:

  |  copy code |? 
1
using (var stream = client.OpenRead("http://twitter.com/statuses/friends.xml"));

I usually stuff the output of that in XML and then do what I need to do with it.

Let me take a break for now, next time we will cover posting to Twitter (status update).

BTW, first part of this could be found here