Editorial: SDK Frustration – My Experiences with Android, iOS, BB, PhoneGap and others

Through my computer science university experience, my need to download SDK’s was limited. Much of our work was done in Java and so the biggest requirement was to download and install Eclipse and the Java JDK. I was fortunate to be able to take a course in iOS development at university as well (one of the best courses I took by far). The setup experience for iOS development is similarly simple. Just download and install the iOS SDK. XCode and all the other tools are automatically configured and prepared for you. You just open XCode and start coding. I found these setup experiences to be generally quick and painless. I recently needed to test a PhoneGap application in an Android context. I had never done so before and I, perhaps naively, expected the setup to do so to be equally as painless as I had experienced before. Wow was I wrong.

Continue reading

jWorkflow: A JavaScript Workflow Framework

Dude Where’s my workflow?

While working on large javascript projects at tinyHippos we would commonly end up with a rather complex bootstrapping process where we need to execute a large amount of initialization code in a specific order. Some of this code is asynchronous and some is synchronous.

We would start out with a series of events and function calls to attempt to chain together the bootup but it would quickly become hard to inject in new tasks. This prompted us to use the tinyHippos mantra “There has to be a better way”.

Continue reading

Some Observations On Asynchronous Programming In Client Side JavaScript

Programming operations asynchronously in client-side JavaScript can make life a lot easier. Lately, I found myself wondering what async truly means in this case, did some investigations and figured it would be worth mentioning.

Continue reading

Closure in JavaScript – with examples

Here at tinyHippos, we use JavaScript extensively. As a matter of fact it is our core development language right now. So I’m often surprised to see how many developers don’t understand how closure works. There are some great resources out there that I recommend every JavaScript developer read / watch and I’ll post them all at the bottom of this article.

I wanted to start this article with the actual definition for closure, so I went where everyone goes: Wikipedia :-) Here’s what they have to say about closure:

“In computer science, a closure is a first-class function with free variables that are bound in the lexical environment. Such a function is said to be “closed over” its free variables…”

Well then… that statement really confused me, I mean seriously… a closure is said to be “closed over”, brilliant! Let’s try and define closure in plain English and let’s first look at the two major requirement that a language must implement to be able to have closure.

Continue reading

Modular Programming Patterns With JavaScript

These days, if you search around the web even a little, you will eventually come across many examples, tutorials, code snippets, libraries and more on JavaScript (i.e EMCAScript). Unfortunately it being a very flexible and easy to learn language, a good bunch of it is is not an ideal example of good practices. Then again a lot of the examples are very helpful too. Best bet, go to the library, bookstore, amazon or any other veritably knowledgeable source, and do some reading. Don’t forget to get your hands a little dirty by writing some code too!

For those of you that have been trained/educated in using classical object oriented languages, JavaScript will feel a little foreign. And, if you’re like we were when we first started using JavaScript as our platform, you’ll want to apply your OO knowledge to JS… please don’t, you’ll just hurt yourself :-)

In this article we’re going to present our favourite way of creating objects and doing inheritance. Keep in mind, this peg will not fit into just any size hole. Take the time to learn JS and then apply the patterns that match your needs best. We recommend this book to get started:

JavaScript: The Good Parts (very short book, and a must read)

Continue reading

Mobile Widgets – Dynamic Layout Example

This is the third post in our on-going series on Mobile Widget development. The first two can be found here:

Mobile Widgets – Persistence Cross-Platform Wrapper
Mobile Widgets – a primer

Over the past few weeks we’ve seen many developers gravitate towards using Position: fixed in their CSS to pin their widget’s header and footer to the top and bottom of the screen respectively. Although this method does work, it’s not the best, nor do all mobile rendering engines support it. There also seems to be a performance issue with regards to rendering. Scrolling content will often make the header and the footer flicker (very visible on the Nexus One using the new Vodafone Widget Manager).

In this article, I would like to present a different approach to solving the same problem. This approach will attempt to also solve the following:

  • Allow for dynamic resizing when switching between portrait and landscape modes
  • Render properly on different screen sizes
  • Render properly on screen sizes with different PPI (Pixel Per Inch) densities (supported, but not shown here. You’ll need to use CSS media queries)

This layout should work for JIL Widgets, Opera Widgets, as well as plain old HTML5 mobile websites.

Let’s get to it!

Continue reading

CSS Priming For Fun Part 2: CSSPrimer 0.1

A while back I did a small post on parsing HTML/XML files and extracting the ids and classes into a generated CSS file. I finally got around to refactoring and packaging it into a ruby gem. This can help you rapidly prototype your markup without having to write the CSS at the same time. Use the gem to generate a scaffold CSS file that you can then fill out. The generated CSS file can also be used as a template for generating multiple “themes” for your html/xml markup :-).

You can install the CSSPrimer gem  as usual with ruby gems.

–> gem install css_primer

For full documentation and examples check out the source code on github.

Next plans:

  • get a working Redcar plugin!
  • generating a CSS file from multiple html source files

Mobile Widgets – Persistence Cross-Platform Wrapper

This is the second post in our series on building Mobile Widgets. The first post was an introduction to Mobile Widgets.

Mobile Widgets – a primer

In this post we will build a persistence library that works across multiple platforms and abstracts away the differences of those different platforms into a common set of methods.

Seeing that we are also about to release our Ripple Emulator, we will be using it for our testing to showcase the built-in persistence view and platform switching capabilities of the Ripple Emulator.

Lets get started…

Continue reading

Sending email with Gmail and Rails, while supporting multiple Ruby versions

Recently I have been working on a Rails app hosted on our deployment server (Heroku) and trying to get ActionMailer and Ruby working with Gmail’s SMTP service. The one catch is you need to use the TLS protocol and prior to Ruby 1.8.7 (Rails 2.3+) you need to write your own wrapper.

Heroku (still using 1.8.6 on some servers) had a nifty addon (now just a blog post and a Rails plugin) that has a TLS wrapper and configuration for ActionMailer’s  SMTP server settings. Awesome!

But… the plugin still fails to work on a platform with Ruby 1.8.7! Most notably my local development environment. Fortunately the internet is great and solutions can be found.

But… something inside of me still wanted to take advantage of the built in support. So I quickly went ahead and did just that and posted my changes to the Heroku google group (a working alternative to the plugin is mentioned here as well).

Hopefully this helps anyone looking for the same answers as me.

* Update *
Heroku just updated their platform (with a complimentary blog post) to support painless migration to updated deployment stacks (including 1.8.7 and 1.9.1).

Proxying HTTP Requests in Ruby

So building upon my other jaunts into Ruby I decided to post some code to make http requests to external urls. It could use come polish and there there is most definitely better mechanisms out there (probably a gem or two… or three) but tis fun to write well… code.

First, here is an example of using it.

require 'Proxy'
class HttpCaller
  include Proxy
end

caller = HttpCaller.new

response = caller.call "http://www.somewebsite.com"

if response[:error]
  puts response[:object].message
else
  response[:object].each_header do |key, value|
    puts "#{key}: #{value}"
  end
  puts response[:object].code.to_s
  puts response[:object].body 
end

And I have posted the full code sample here.

Follow

Get every new post delivered to your Inbox.