Sunday, December 8, 2013

List<Awesome> BucketList

1. Build a Robot
2. Develop a Game
3. Become Proficient with 3D Animation
4. Talk with Neil deGrasse Tyson
5. Talk with Elon Musk on another planet :)
6. Understand Quantum Mechanics
7. Make one major discovery

Tuesday, October 1, 2013

Converting Twitter Links To Follow Buttons

Forgive the rushed nature of this post as I'm taking a short break to do it

So I saw this and decided why not follow them. We'll be there too, right?

Woah! 70 repeated click,navigate and follow instances. There must be a better way.


So, I did a quick search and after some thought realized that the following jQuery snippet should work.

I already had jshell inststalled. so I popped it in and waited.


Then, click, click, click, click.

The End.

Tuesday, September 10, 2013

Embedding Facebook Post plus TFS and ALM Guidance

I saw an article via, I think, about embedding Facebook posts in your website. Well today I had my chance to test it out while sharing some content that I'll definitely use personally. I've been on a mission to try to improve the quality of the work I do and this I'm sure will help. The steps are as follows

  1.   Click the drop-down to the top right of the post and select "Embed Post"

  2. Follow the instructions in the pop up to paste the html and javascript generated in your website's html.

The result,

Monday, September 9, 2013

Key Value Pair Service on Google App Engine

I had the need to include in-game dictionaries for an online game I was enhancing through a Google Chrome Extension.

When I decided to look for a simple key value pair service to load the dictionaries, I assumed I'd find loads of examples or some stable implementation that I could leverage. I found one service that appeared to not have much support and a few examples which were not quite there.

 As I was busy with a few other things at the time, I mentioned Google App Engine to the developer I was working with as a possible solution. I said, we might have a free solution if we manage to remain within the specified quotas. I hadn't conceptualized the flow, so I couldn't say whether or not that was possible. We needed to keep the price low (read zero) because the extension is free, and will always be. When a window opened up I decided to go for it.

First decision,

  1. Go with PHP as that is the language I've used most often
  2. Go with Python to get more experience as I had done only a few basic example before.
Easy choice, Python. Time to reduce the verbosity and get to the gold.

Step 1.

Convert dictionaries to a static file that could be read quickly. I had a few failed attempts at getting good performance with
  • JSON
  • msgpack - It claims to be like JSON but fast and small. It still didn't work so well for me.
  • marshal
I then decided to try to implement cPickle which I'd read about before the other two but for some reason, I didn't try it.

To be continued.........

Saturday, August 17, 2013

When jQuery met Wikipedia for a game of Scrabble

I needed to obtain a JSON object containing the tile values on scrabble tiles for a project I took on. This was across 8 dictionaries (6 languages). The problem was, I couldn't  find a good source for the required data. I have since found a far easier way to obtain the data but it was still a fun challenge.

The best I could do at the time was

The data was laid out as displayed below and it didn't look very friendly.


English-language editions of Scrabble contain 100 letter tiles, in the following distribution:
  • 2 blank tiles (scoring 0 points)
  • 1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4
  • 2 points: D ×4, G ×3
  • 3 points: B ×2, C ×2, M ×2, P ×2
  • 4 points: F ×2, H ×2, V ×2, W ×2, Y ×2
  • 5 points: K ×1
  • 8 points: J ×1, X ×1
  • 10 points: Q ×1, Z ×1

With a little inspection, I was able to identify the formatting applied to the required elements.

Enter Google Chrome plus the jsshell extension. Jsshell allows you to run jQuery on any page. Now isn't that somethin' :-).

So after a few (debatable) minutes I came up with the following

In other words

  1. For each of the six languages specified, find the span with an id  equal to the language.
  2. Find the first list following the parent of the identified span
  3. For each bold letter in the list, assign the integer value of the italicized text which is a sibling of that letter to that letters index in that languages array.
    • Example, for the English dictionary, Q and Z (bold) are 10 points (italicized). The integer value of  "10 points" is of course 10.

The result,

Lines of code : 10

Friday, August 16, 2013

I love pi, I do. All infinity digits, no wait...infinity and 1

I needed to get this party started, so why not do it with a little pi loving.

I'm not a die-hard pi-thusiast. I'm just a nerd who thinks that I'm the one (who knocks?) who ended up with this irrational love for a sequence of digits. Maybe it is the fact that it is the ratio of a circle's circumference to its diameter. I don't love circles. I don't dislike them, but they're just not that special. However, I think of time as a circle, I haven't studied time but that is just what I think. History tends to repeat itself,  recurring themes and so on..... but this post is about pi.

So here's my pistory
  • I memorized the digits of pi from my calculator in high school. I think at the time this was 3.141592654 rounded.
  • During an electronics lecture at the University of the West Indies, the lecturer asked the class to state the digits of pi. Oooooh, my time to shiiiiiiiineeee! Some stopped after 2 digits, some after four and Sir Dale (I've been knighted) of course went valiantly through his 10 digits :3
    Not bad, Mr. Ross
  • Of course, this drew attention, and the lecturer asked me to repeat, I think. He then went on to recite about 30 or so digits.
    Are you kidding me, seriously?!
  • I made a deal with the lecturer to receive imaginary marks if I could get to 100 digits by the end of the course.
  • On my final exam I included the following (I could only remember 93 while doing the post but it might be due to code-induced-insomnia). I Google™d (3.5-1.5 on the Bing test) the other 8 digits, sue me! No, please don't!
  • That's 101 digits, because stopping at 100 would have required rounding and that's not cool, man. I got my imaginary marks but they only reported the real component, claiming it was too complex! The nerve!
    Awwww Yeahhhhhh!

  • Did you notice the pi in the Dajen Group logo? Of course you did!
So there you have it, my first post in the code room. 
Lines of code : 0