Blog

Project Three Sixty Five

Yesterday I was reading LifeHacker, as I have recently started to do, and came across this article: 366 Days, or How I Tricked Myself into Being Awesome

It got me thinking about how I keep saying I want to become a better programmer but never actually do it. So I’m going to try to take the plunge and learn as much as I can for the next year.

I’ve started with a book that a friend recommended on ASP.NET MVC.

Every day I will attempt to learn at least one new thing and post about it.  Thus turning my blog into a daily journal for the foreseeable future.

Base Knowledge

Last month I finished my Bachelor of Science in Computing and Information Systems through Athabasca University and Grande Prairie Regional College (collaborative).  During this time I took classes on Java, C++, C, Assembler, HTML, CSS, XML, JavaScript, Java Mobile, Java Server Pages, SQL, and even Game Maker Language.  University has given me a wide range of knowledge but it has failed to cement in me any confidence as a programmer.  I dabble in everything but I’m a master of nothing.  So today I begin an exercise in me.  Exercise has never been my strong suite but here we go…

Day One

Last night would have been day one (I think this is the format I’ll be taking, learn at night then post the following day).

I read Chapter 1 which described the history of Microsoft web frameworks which included CGI, Webforms and now MVC.  The book also spent some time on competing frameworks such as Ruby, Sinatra, Node.js and Rails.  It also didn’t hold back on attacks against Webforms.  I’ve never used Webforms so I cannot attest to their capabilities.

The rest of the chapter went over the pros for ASP.NET MVC.

  • MVC architecture
  • Extensibility
  • Control over HTML and HTTP
  • Testability
  • Modern API
  • Open Source

I’ll leave it there for day one and pick up tomorrow.

PhoneGap iOS UIWebView and Safari.app Links

When creating a PhoneGap jQuery Mobile project you have two options for opening links:

  • UIWebView This is PhoneGap’s in app browser
    • The draw back for me was that there is no navigation in UIWebView. Thus no way to navigate back to the app
    • The upside for me was that I could use iFrames (out of necessity not out of want) using UIWebView
  • Safari.app As you can guess, this is iOS’s default browser
    • Links open in Safari and load as expected
When I was creating my project I had a bunch of external links that I was happy sending off to Safari but I had a 3rd party iFrame for a chat feature that needed to function within the app.  To just enable UIWebView for the single URL I used this code [projectFolder > Classes > AppNameDelegate.m]
1
2
3
4
5
6
7
8
9
10
11
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
      NSURL *url = [request URL];

      if ([[url absoluteString] rangeOfString:@"URLToOpenInUIWebView.com"].location != NSNotFound) {
            return YES;
      }
      else {
            return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
      }
}

To enable external domains in PhoneGap you have to whitelist the URLs as of PhoneGap 1.0.
To do this go to projectFolder > Supporting Files > PhoneGap.plist
You should have a list of Key/Type/Values.  First check to see if ExternalHosts is one of the keys.  If it isn’t then right click the list and choose Add Row.  You’ll want it to look like ExternalHosts/Array/count (this is auto generated)
Now that you have ExternalHosts you will want to add URLs to this array to whitelist.
You can use the wildcard symbol * in this list.  So *.domainName.com would allow all subdomains.  There is nothing stopping you from using * or *.* to allow ALL URLs to be whitelisted.  I leave that to you.

I was using Xcode 4.2.1, OSX Lion 10.7.3, PhoneGap 1.4.1 and jQuery Mobile 1.0.1

Zombie Lane Gifting URLs Exploit

Zombie Lane (Facebook game) uses URLs to send in game items called Gifts.

Therefore the game normally locks out specific items until the player has reached a specific character level.
For instance a user should be level 30 before being able to send +7 energy to another user.  Using the URLs below allows you to circumvent this.

As of version 1.1.8 of the game this is still a security hole that has not been patched.

Originally I was pretty psyched to create an application that would allow other ZL players to easily do this as well.  The problem comes in the form of time.  Already wasted 3 hours making a solution specific to me (a single webpage with 32 ZL players that when I click on their 32×32 pixel FB photo an individual page loads prompting 7 pop up windows to send all 7 items to that specific user).  So now I click on 32 images and some super crude Javascript window.open pop ups do the work for me.  Of course I had to tell my browser to allow pop ups and each browser has limits on the number of pop ups it will allow (Chrome allowed me to load 25 before it blocked further, Firefox 4 blocked after 20 and Internet Explorer 8 allowed me to open all 192 pages while almost freezing my 8GB RAM, 6 core computer).  I couldn’t find where to alter these limits.

If anyone is interested in making an app that would take advantage of these links would have to consider these points:

  1. Facebook vanity / username URLs won’t work
    &recipient=some.name.that.you.chose won’t work.  So you’ll have to convert vanity names to UIDs.
  2. Possible TOS issues
    I skimmed through both Facebook Developer TOS and Zombie Lane TOS and didn’t see anything that would be an issue.  After all these are using URLs that are publicly available.
  3. Pop Ups
    To open the URLs you will need to use pop ups.  No one likes pop ups.  Every browser has pop up blockers enabled and it will be a hassle to have people unblock them.
  4. Storing User Facebook Friends
    If you make it web based you are going to have to keep track of who people want to send to, otherwise they will have to enter this information every time.  So now you have to handle the privacy issue.  You can encode the data, but the average user is still going to be suspicious of your intent.
  5. Webbased vs Standalone
    So PHP, Javascript, FBML, Ruby.  Now you need hosting or you have to have people trust a EXE.  Fun times.
  6. Digital Chocolate changes exploit in next version and you wasted a huge amount of time
    THIS.

So what do I suggest.  Just use the URLs for yourself for now.

Shotgun
+3 Energy
+5 Energy
+7 Energy
Blueprint
Grenade
Land Mine

Shotgun
http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262
Energy +3
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola&request_type=GiftRequest&recipient=580606262
Energy +5
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola2&request_type=GiftRequest&recipient=580606262
Energy +7
http://apps.facebook.com/zombielane/SendGift?gid=EnergyCola3&request_type=GiftRequest&recipient=580606262
Blueprint
http://apps.facebook.com/zombielane/SendGift?gid=Blueprint&request_type=GiftRequest&recipient=580606262
Grenade
http://apps.facebook.com/zombielane/SendGift?gid=Grenade&request_type=GiftRequest&recipient=580606262
Land Mine
http://apps.facebook.com/zombielane/SendGift?gid=LandMine&request_type=GiftRequest&recipient=580606262
How the links look.  Replace the &recipient= at the end to the UID of your friend.

To find this I made this really quick.  Enter a vanity name and it will show you the user ID number.

http://www.facebook.com/

All that is left to do is to create a list of links that you can click on.  You’ll have to look into HTML or Javascript

HTML Example

<a href=’http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262′>Shotgun</a>

Javascript Pop Up Example

<script language=”javascript”>window.open(‘http://apps.facebook.com/zombielane/SendGift?gid=Shotgun&request_type=GiftRequest&recipient=580606262′,”,’width=350,height=200′)</script>

Hope this helps.

Tax Return Spending

Upgraded my computer a few weeks ago.  I had a Dual Core 2.2GHz, 4GB RAM with a Nvidia 8600 GTS graphics card.  My new computer is a AMD Phenom II X6 (6 cores), 8GB of RAM with a ATI Radeon HD 6670 1GB DDR5.

I was also using an old wooden writing desk that my parents had bought when I was a teenager.  With my tax return I bought a new BENQ 20 inch LED LCD monitor (man they are thin) and a desk from Ikea.

All and all, I love my new work area.

Ordered Some Threadless Shirts

Today I purchased a few shirts from Threadless for $12 a piece.  I wouldn’t have even known about the sale if it wasn’t for a Facebook ad.  I find this interesting because it is the first time that an online ad has resulted in me purchasing something.  I’m sure it won’t be the last, but I felt like sharing that online marketing does work, or at least it works on me apparently.