Thursday, January 28, 2010

First task accomplished - Adding Adsense to body of blog post

After spending two afternoons reading up on the web and numerous trials and errors editing my blogger template, I was finally able to get the Adsense code into the body of my blog successfully. I think it was my 20th attempt. Learned a great deal in the process; that blogger is written in xml and does not communicate with adsense javabscripts and that I need to parse the code so it can be understood when the url is served. Using a code parser found readily on many websites, I parsed the Adsense codes that I had generated and inserted where it should go. It did not work. First it would not let me save the changes, with error message saying that my xml is incomplete. I made some changes the best I could,closing xml tags and when I was finally able to save the changes (assuming my tags are all closed and correct), the ads did not appear and in its place another error message appeared "webpage cannot be found". Having spent 4 hours going through web resources and forums and getting nowhere, I decided enough time is spent and I should just take another look another day.

It was bugging me all night though, it seemed so straight forward and yet I am not able to fix it, what am I missing? I decided to parse my Adsense code using a different code parser from another website. At first, I had the same xml tag not closed error, I looked at it carefully and added <div> at the beginning and </div> at the end. Low and behold, it let me saved the changes. I am making progress!! The ad appears except it is at the top of my blog post, not with the body text around the code. The next thing I decided to do (which I learned a long time ago) is to study source codes of other sites (View -> Source) and see what the difference was between my codes and theirs. I found a webpage that had an Adsense code embedded (wrapped) within his post and I saw he had two additional lines. I added them to mine and that fixed it!!

So here they are:

I inserted the following after <div class='post-header-line-1'/>
</div>
<div class='post-body'>
<div style='float: left; padding: 3px; 3px; 3px; 3px;'>

PARSED ADSENSE CODES

</div>

A few things to do before you start making all these changes, download a copy of the template and save it in case you mess up and need to revert to the working template. Second, make all your changes on notepad until you are ready to copy paste to insert it in your blog template.

P.S In order for the html codes above to appear as they are in my blog post and not to be be confused as a xml code, I had to change first "<" to & and lt (without the space) and that did the trick.

Wednesday, January 27, 2010

The Prologue

I started this blog as a way to chronicle my own development as a programmer, as a complete novice knowing only the most basic html codes and ziltch on Java and C++. It is a challenge to myself to see if I can put my head to it during my spare time and design something useful that someone would use. I spent most of my working life working for others until I caught the dotcom fever late 90s and I quit my very well paying job to work for myself. I have not looked back since. I am not rich by any means, in fact, you could say I am poor but contended, that I get to call my own holidays and work as much or as little as I want, as long as I plan ahead and make sure my own finances are in order.

So here it is, the tech revolution has caught my imagination and I wanted to give myself a challenge, if I could learn something new that is Greek to me and build an interesting application.

I have three passionate pursuits, photography, art, wine. Conservation and reducing my own carbon footprint is important to me so I have some ideas where I could start.

First of all, I need to learn programming. After extensive research on the web, I came across a link that took me to itunes classes at Stanford U. Apple has decided to make the Apple IPhone programming course lectures available via itunes to the general public. In addition, there were also lectures on Programming Methodology and Programming Abstraction one could download and watch at your free time. So I sprang into action, downloaded all the lectures, about 50 of them in total.

I have watched both lectures 1 and 2 of the Apple IPhone Programming Course and have just finished watching my third Programming Methodology lecture by Prof Mehran Sahami. Now these are lecture notes from Fall 2008. (2009 lectures were not on itunes for some reason). I am not sure if Prof Mehran Sahami is still teaching that class, but you should take the class from him if he is. Prof Mehran is so funny and makes this beginning programming class interesting and yes not intimidating, can I say that.

A book I bought recently to read that I highly recommend:
The Hidden Language of Computer Hardware and Software by Charles Petzold, Microsoft Press, 2000. Here is a link to Amazon page