Freelance work what it should be vs what it is.

December 4th, 2009 Paul No comments

1243018_31569956

I am a busy guy, full time job, wife who recently decided to learn how to code, kids – hockey practices at 7 am on Saturdays and bed time stories and many other things normally occupy my day. On top of this, I have to stay up to speed on what is going on with technology, work on my side projects (partypm.com is cool, sorry for the shameless plug) and occasionally I do freelance.  However lately I am not that enthusiastic about freelance projects and this comic from the Oatmeal perfectly describes the reason why.

Read more…

Categories: Business, Management, Projects Tags:

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

Distraction free development department.

July 6th, 2009 Paul 2 comments

keybord

One of the things that drove me absolutely nuts when our department was in the same building as the rest of the company was the fact that nobody could quite understand what we were doing. Quite often we would get a data entry person storm into our office and demand that we fix their Outlook or install Unix on their machine (it turned out that he needed Putty, not a true Unix install). Usually these conversation started with “You guys are not doing anything, right?”. So many times I was trying to explain to everyone that it just does not work like this. We are not just sitting here pressing keys at random most of the time. Best and by far most common argument to support their need for our involvement that I heard was something like this: “It is not going to take long, could you just do this for me right now”. One of our duties was writing a variety of Excel macros for people(I should probably post some tutorials on this subject). After all when dealing with massive amounts of data, it is faster to write a macro then do something by hand. We did not mind doing macros at all, what we did not like is when the person was sitting on the project for weeks and then decided to approach us at the last minute. Client expects the project to be completed at 5 PM, so the analyst strolls into our office at 4:45. Never mind that it takes him about 3 hours to explain to us what on earth does he want macro to do. Never mind that it takes me couple of hours to code the macro in some cases(trust me, there were some huge macros). It had to be done and that is it.

Number of times we attempted to find a solution to this annoyances. For instance we created a little internal web site that would, in theory, help users solve many issues like setting their “Away” message on Outlook and server connection through Putty and such. I did this web site in about 3 days when my computer was send away for repair and I was working on an antiquated piece of hardware we found berried in a storage. Was this web site ever used? No, it was not. Office people would still storm into our office saying that they did not read the instructions as they would not understand it anyway.

The worst part of these interruptions was that it would completely break my line of thought. So you are working away on a complex algorithm with close to no documentation on the objects that have to interact together available. You are concentrated on the task 100 percent, not even noticing that that cup of coffee is now cold, and then all of a sudden you have someone storms in and demanding that you fix their radio right away, or else.

The idea that you just had about this nice piece optimized piece you are about to write is gone now. I must admit that couple of times I flipped. It ended up with me yelling at a poor data entry person, calling them names, questioning their intelligence and so on. After I usually worked from home for a day, but at home there was a urgent need for a game of soccer or emergency epic hide-and-seek battle with my kids. I do enjoy those, but working from home was not a big option from the point of getting any work done.

Few years have passed and then our lease was up. I knew that was the moment when inaction would cost me dearly; I begged and pleaded with my boss to get us a separate office. Likely he agreed with me, and for the last two years we are in a different building, about 40 minute drive away from the main office. At first, main office was really concerned with who would be helping them out with daily tasks, but after about a month they learned to do it themselves. That little web site was finally used on the regular basis. We were not bothered with those requests and could finally spent close to a hundred percent of our time on coding and related things. Our productivity sky rocketed, we were producing better code more quickly and everyone was much happier.

The point is – developers can’t be disturbed. It is a process where ideas and thoughts need to be followed and processed carefully to produce what could be considered good code. You must create a barrier between your coders and outside distraction to produce quality software, and after all it is the purpose of any development team.

Twitter API with C# example(part 1)

July 1st, 2009 Paul No comments

sunflower

Currently I am involved in a project where number of things have to be done using Twitter API. What really amazes me today is the quality of API’s available to developers. Twitter is a perfect example of such API. I will try to publish some code that I used to accomplish several tasks starting with getting the details of a Twitter user providing you are aware of the user password and username.

Following code will retrieve a variety of information about a Twitter account:

  |  copy code |? 
01
02
public string FetchUserDetailsAsXml(string userName, string password, string IDorScreenName)
03
{
04
 
05
        if(string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
06
        {
07
            throw new ArgumentException("userName or Password are not supplied, that is not good.");
08
        }
09
 
10
    string url = string.Format(TwitterBaseUrlFormat, "users", "show" + "/" + IDorScreenName, "xml");
11
 
12
    using (var client = new WebClient())
13
    {       
14
        client.Credentials = new NetworkCredential(userName, password);
15
 
16
        try
17
        {
18
            using (var stream = client.OpenRead(url))
19
            {
20
                using (var reader = new StreamReader(stream))
21
                {
22
                    return reader.ReadToEnd();
23
                }
24
            }
25
        }
26
        catch (WebException weex)
27
        {
28
            if (weex.Response is HttpWebResponse)
29
            {
30
                if ((weex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotFound)
31
                {
32
                    return null;
33
                }
34
            }
35
            throw;
36
        }
37
    }
38
 
39
 }
40

That’s pretty much it. Need System.Net and System.Web for this, obviously. What you get out of that looks like this:

  |  copy code |? 
01
02
 
03
- <user>
04
  <id>14381487</id>
05
  <name>pzubkov</name>
06
  <screen_name>pzubkov</screen_name>
07
  <location>Ontario, Canada</location>
08
  <description>Coder, mostly .net</description>
09
<profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/56116140/Me_normal.jpg</profile_image_url>
10
  <url>http://www.paul-zubkov.com</url>
11
<protected>false</protected>
12
  <followers_count>39</followers_count>
13
<profile_background_color>709397</profile_background_color>
14
<profile_text_color>333333</profile_text_color>
15
<profile_link_color>FF3300</profile_link_color>
16
<profile_sidebar_fill_color>A0C5C7</profile_sidebar_fill_color>
17
<profile_sidebar_border_color>86A4A6</profile_sidebar_border_color>
18
  <friends_count>61</friends_count>
19
  <created_at>Mon Apr 14 05:08:22 +0000 2008</created_at>
20
  <favourites_count>0</favourites_count>
21
  <utc_offset>-18000</utc_offset>
22
  <time_zone>Eastern Time (US  Canada)</time_zone>
23
<profile_background_image_url>http://static.twitter.com/images/themes/theme6/bg.gif</profile_background_image_url>
24
<profile_background_tile>false</profile_background_tile>
25
  <statuses_count>49</statuses_count>
26
  <notifications>false</notifications>
27
  <verified>false</verified>
28
  <following>false</following>
29
- <status>
30
  <created_at>Wed Jul 01 19:15:11 +0000 2009</created_at>
31
  <id>2424620582</id>
32
  <text>twitter api rocks, this is sweet</text>
33
  <source></source>web
34
<truncated>false</truncated>
35
  <in_reply_to_status_id>
36
  <in_reply_to_user_id>
37
  <favorited>false</favorited>
38
  <in_reply_to_screen_name>
39
  </in_reply_to_screen_name>
40
  </in_reply_to_user_id>
41
</in_reply_to_status_id></status></user>

As we can see from above, I am not an avid Twitter user myself, but I find that the API produced by Twitter is extremely well done. In Part 2 and 3 I will cover sending new update and getting followers.

New (at least for me) IO functions.

June 30th, 2009 Paul No comments

embarrassing

Well, live and learn. This was an interesting day. I am working on a little project right now, can’t really discuss details, and quite frankly it is nothing that I am going to be too proud of once it is done. But this is not the point. I had to do some minor IO work with this and this is when I found that instead of doing stuff like:

  |  copy code |? 
01
02
 
03
_fsCFileStream = new FileStream(sFileName, FileMode.Open, System.IO.FileAccess.Read);
04
_srStreamReader = new StreamReader(_fsCfMCCSV, Encoding.GetEncoding(1252));
05
 
06
try
07
{
08
    if ((sLineIn = _srCfMCCSV.ReadLine()) == null)
09
        //do stuff here
10
}catch(){}
11

I can simply do
  |  copy code |? 
1
2
File.ReadAllLines();
3

I guess I was stuck on .Net 1.3 for so long, I completely skipped 2.x and now 3.5 is full of surprises. I know I am behind times, need to catch up soon. Gone to do some reading.

Categories: Coding Tags: , , ,

Codeigniter – I like PHP again!

June 11th, 2009 Paul 19 comments

jumping

In the last few years my focus was on .Net, I love C# with all my heart(my wife does not read this blog, so I am free to say that). It is the language that is structured enough and at the same time powerful and flexible. There have been many advances in .Net, WPF and MVC are exactly what was needed by the development community. Although there are still issues with .Net that have to be resolved, I feel that the framework itself is on the right track. With all my love for .Net I have forgotten about one of the languages that I had started my coding with – PHP.

One of the greatest advantages of .Net as to compare to scripting languages like PHP is ability to really trace the code diving into smallest details. I have hard time imagining debugging something without ability to “watch” the variables that I am working on. Visual Studio is a very well written IDE, I can’t even think of an IDE that comes close to VS, so I got spoiled by all this luxury, until a week ago my boss came up with a project that required use of PHP.

I decided to take on the project myself, wanted to refresh the stuff I knew about PHP and all that. By saying that I would be taking on this myself, I mean the back end, after all my designing skills are very limited and I had given up on creating nice UI long time ago. Will, the UI dude would be making this thing look nice. So after accepting the project, I had started reading on what is going on with PHP, and guess what, there have been some incredible things that were released since I last worked on PHP. Which should not be a surprise, progress can’t be stopped, just me with my deep submersion into .Net stayed completely oblivious to this part of coding. This is how I found Codeigniter.

Now, nobody is paying me for this (I wish someone did), so this is an honest plug of the framework that was done so well, I had coded that silly file sharing thingy that my boss wanted in about 3 days. Keep in mind, this was just the back end, now Will is goofing around with design, and I am sure he will do great, as usual. I found that Codeigniter made my work so much easier. Great documentation is written for the framework, there is a forum and even an IRC channel. To me, this represented a great change from the wild days of my PHP coding. I would recommend Codeigniter to everyone who is interested in doing work with PHP quickly.

Other great things I used on this project – Aptana Studio (excellent IDE, still have not figured out how to use that build in Subversion plugin) and WAMP.

Categories: Coding Tags: ,

Firefox as development platform?

May 28th, 2009 Paul 4 comments

gears

FireFox has been my browser of choice for quite some time. I am the kind of guy who likes customization. There is a certain ways my computer has to be set up, its just the kind of person I am. Perhaps for me the most important feature of FireFox would be plug-ins. This is the best tool for customization of your browser. Now, I have been impressed with newest Internet Explorer, add-ons are step in the right direction, but at this point there are no add-ons to help with coding, but when it comes to FireFox, well, let me just list some:

Most obvious - Web Developer – lets just say that this is a must have if you are coding for web. List of features is just too long and I am just to lazy to list everything, lets just say without it any kind of coding for web would just take too long.

Firebug - simply put one of the best tools for debugging your web site. Add YSlow and get in depth analysis of what is going on with your project.

Pencil – free and quite powerful tool for UI prototyping and diagrams, try it out. It won’t replace industry standard software, I for one prefer Visio or coffee shop napkins and black pen, depends on where the idea strikes me, but if you need to do something quick, Pencil would do just fine.

FireFTP I can’t really count number of times I needed to ftp something quickly. FireFTP serves just that purpose. I can’t really recommend it for transferring bunch of files, keeps on timing out, but then again, I have not really played with all settings to affect that.

Codetch - an IDE like plugin which lets you work with your files in a manner similar to Dreamweaver. Once again, for a full blown project I would use a stand alone IDE, most likely Visual Studio or Komodo Edit, but for a quick change Codetch does the job.

There are more, much more. These are the things that I use quite often. Now, with all that great functionality, would I consider FireFox as a development platform? The answer is no. There are tools that are designed specifically for development purposes, while FireFox is a browser. It might be handy to keep a jump drive with overloaded FireFox installed handy for some quick coding while your machine is unavailable, but for full blow development project, there are tools that can do the job much better.

Optimizing Developer

May 15th, 2009 Paul No comments

man_rain

Have you ever looked at a code that you wrote several years ago? I have to do this all the time, after all I am working on the same application. Not only do I do it to fix bugs, but I do it to optimize the production code. And at times I see my old code and think what was I thinking when I wrote this. You see, with every release our main product grows, new features, core changes, you name it. One can say that we are optimizing the software by adding things our clients ask for and this leads to optimization of code. Optimizing your code is extremely important, normally there are few ways in which a particular problem could be solved, but if you are serious about your work, you do want to pick the most efficient way of doing things. Many books have been written on the subject, simple Google search will produce lots of articles concerning code optimization. Today I am not going to talk about that, instead I will talk about optimizing a developer.

If you are like me – doing coding full time and at times after hours, you want to achieve something which falls beyond simple financial compensation for you work. I want to grow as a developer. I have read somewhere that it takes roughly 10000 hours to master a task – be it musical instrument, a sport or any other activity. I think similar thing is applied to programming. I have been thinking of a way to apply optimization to myself, after all if my code can be optimized, why can’t the writer of the code. Here are some principles that I have came up with. This works for me, might not work for everyone. Once again, just my own opinion. Read more…

This blog has been fine-tuned by 6 WordPress Tweaks