Forex Exchange Rates Chrome Extension

In my ongoing effort to learn more about Chrome extensions development, I made a Forex Exchange Rates extension.

This runs with Forex Exchange Rates as a background and provides a way for you to compare two different exchange rates with up to date information, right on your toolbar in Chrome.

I used JQuery, and the most difficult hurdle to get over was making using of JSONP for cross domain Ajax handling. I only found out that Ajax doesn’t support cross domain handling until after completing the whole project. Luckily after doing some research the fix was quite easy.

Keyword Density Chrome Extension

I’ve been using keyword density analysers for quite some time, but to get one that works just right has been difficult to get. I decided to create my own one with info that I’ve found through researching various aspects of keyword density.

I decided to make it available for everyone to use on http://www.keyworddensity.info. It works nicely, but I still found it a schlep to copy and paste URLs each time I want to analyse a website or article.

Out of that frustration, my new Chrome Extension for Keyword Density checking was born. It makes it easy for you to check the keyword density of any page.

Try it out!

My first Google Chrome Extension

I’ve been looking for a reason to create a Google Chrome Web Browser extension for a long time now, and today I finally decided to do it.

I wrote a PHP script a while ago to help grab videos link off various websites. Particularly FLV files. I wrote the PHP script because I got tired of getting the FLV in the page source code every time. It was however a schlep to copy & paste the URL every time and then get the links. So it was time to make it more efficient.

I decided to make it a Chrome browser extension.

My first stop was http://code.google.com/chrome/extensions/index.html and from the beginning it was evident it was going to be quite a learning curve.

I checked through the examples, made offline copies and started playing around with the code. It primarily makes use of Javascript and HTML to accomplish what you need done. I normally try and stay away from Javascript, but this forced me to go against it and play around with client side coding.

There were a few snags along the line, but let’s first look at what the extension does.

How this script works:
1. Once installed, you will have an icon on your toolbar
2. When you click on it, it reads the current page’s HTML into memory
3. By making use of regular expressions it gets all the mentions of FLV files
4. It places them nicely one link per line in a popup window
5. You simply click on the link and it opens a new tab with your video there

I had a look at a number of extensions, and it seems everyone does things differently. The part that I struggled with most was getting the content of the current HTML page into memory so that the popup script could use it. I thought it would’ve been easier to figure it out, but nothing worth anything in life comes easy. Once I figured that out it was simply a matter of putting a few finishing touches on there.

I’ve uploaded it onto Google Chrome Extension Directory to get other people to test it as well and give feedback. If you happen to test it and you find a bug, please let me know.

What is a bad programmer?

I think I was born to be a programmer.  Ever since I can remember, I’ve had this thing I do that whenever I see something in the real world I try and work out in my head how you would go about structuring  an algorithm that would simulate or automate it.

As an example, let’s look at how you wash a car.

  1. Spray car with water
  2. Apply soap on a part of the car
  3. If car is completely soaped up, rinse off, otherwise go back to step 2
  4. Dry off part of the car
  5. If car is completely dry, stop, otherwise go back to step 4

When I stand at an ATM drawing money, I go through my head the processes that it goes through when I do a transaction. (note, this is obviously not how an ATM works, and is just here for illustration purposes)

  1. Read information from my mag stripe
  2. Accept my PIN code
  3. Send my PIN code along with the unique ID on the mag stripe to a central database to compare and see if my PIN is correct
  4. If it is correct return the information like bank accounts, etc to the ATM so that I can do a transaction.  If it was incorrect stop and exit
  5. Get transaction information, check it with central database and if possible record that the transaction has gone through
  6. etc

I don’t know what the word is for someone with a personality like this, but that is what I am :)   I am sure that some people who know me wouldn’t expect me to be like this, but I find myself often going through things like this in my head.

I believe the ability and the urge I feel to do this with a lot of things in life has helped me with my programming skills.  It has helped me understand other people’s software as well, which normally results in being able to understand why a certain program is occurring in their software.  As an example, when a program fails at a certain point, I can work out that it’s probably because at that stage it needs to load information from a file but it hangs there.  I am then able to check if the file it needs is indeed there, and if replaced it works.  So without error messages guiding me in the right direction, it’s very often possible to work out what a program is trying to do at what time.

This gets me to an article I read about whether or not you are a good programmer – Bad Programmers.

In short, you are a bad programmer when:

  1. You struggle to reason about code
  2. Poor understanding of a language’s programming model
  3. Poor knowledge of a platform’s features
  4. Unable to understand pointers
  5. Difficulty seeing through recursion

Signs that you are a mediocre programmer:

  1. You’re not able to think in sets
  2. Lack of critical thinking
  3. Pinball programming – working in just certain states
  4. Unfamiliar with security techniques

And then there are signs that you shouldn’t be a programmer:

  1. Unable to determine the order of execution of code
  2. No ability to think in the abstract
  3. Collyer Brothers syndrome
  4. Dysfunctional sense of casualty
  5. Indifference to outcomes

That is just a summary of it, and I think it’s really worth a read to see where you fall if you consider yourself a programmer.

My Twitterbot

Up to recently I haven’t gotten much into this micro blogging craze, nor really into any of the social networking variations.  Apart from using Facebook to run our group for EC Offroad Adventures which inform people of our upcoming events, and keeping in touch with friends I normally see often anyways, it really hasn’t made an affect on me to want to use it more.

I know Norio from Maxiware uses Facebook’s advertising feature intensely with great success, so perhaps there is something of an untapped avenue for me.

He is also the one that got me onto twitter.  Now admittedly, I don’t find it at all appealing to twitter the whole day about what I’m doing, but what I do find interesting is that this is another avenue of generating traffic to your website.  I have a number of websites I’ve put up, just as a test and experiment most of the time.  Some can be viewed at http://www.cmcs.co.za/websites.  Sometimes I get an idea in my head, and then I see if I can turn it into a website.  Most of the time though, I don’t spend much time after that actually promoting the website and getting visitors there. Big mistake  I know.

Okay, back to twitter.  So the whole thing with twitter is that you can write updates to your profile using 140 characters or less.  Most people use it for stuff like, “Chris has just gotten back from the bank”, “Chris has just gotten off the phone with a stupid client”, or “Chris has just launched a new website, check it out at http://www.cmcs.co.za/websites”.  You see what I mean?  If you’re familiar with Facebook’s status updates, it’s basically that.  Now people that are following you will see these updates in whichever program they’re using to view twitter updates of their friends.

The theory I have, is that the more people are following you, the more people are likely to see your updates.  How do you get people to follow you?  You can either be very interesting, or you can read another theory I have.  If I were to randomly start following 100 people on twitter, chances are that some of them will actually then follow you as well.  So I tested it by randomly following people on twitter.  Within a few hours I had about 3 followers.  Not bad, 3 people to potentially see my updates.

I, however, don’t have the time to sit here each day clicking away following people.  So my mind start working over time to think of a way to automate this.  I see a Developers link on twitter’s homepage, and lo and behold, they have an API.  This is just a way for our little programs to interface with their software.  It allows me to search for people on twitter, follow people, and make status updates.  Perfect!

That was the start of my Twitterbot.

I have a list of predefined tags that it uses to search for people making status updates about those tags within the last hour.  Say for instance everyone with the word #website in their status.  I put the list of all those users into my database table.  This is run once a minute every day.  Then, 3 times an hour I randomly select 1 person from that list, and follow them.  This is the important part of my bot, it collects users for me to follow.  I do it at 3 per hour, so that I don’t start following more than 36 people a day, just to not cause suspicion.

All that was left was to integrate my websites with twitter.  So for instance, when I make a post to http://www.whatifound.co.za/ it automatically updates my status for http://twitter.com/stuffwhatrocks/.  The same with http://www.pichost.co.za/, whenever a new picture gets uploaded, it updates the status.  It has boosted traffic to my sites a bit, but this is a long term experiment.  In total I am now following 1,195 people, and out of those people 202 are following me.  202 potential visitors to my site.  My database of names contains more than 15,000 users at this point in time, and growing by the minute.

Worth the effort of making a twitterbot?  I think so.  It took me about 3 hours to research and make this, and it will now steadily grow the traffic to my websites.

After doing this, and having it running for a few days, I decided to research a bit more about automating twitter.  I then found similar bots to mine all over the Internet.  And here I thought I was special :)

If you’d like to read more about the Twitter API, check this out http://apiwiki.twitter.com/Twitter-API-Documentation