Android 1.6 Donut released

by Michiel on September 16, 2009 · 0 comments

in Android Development

Today is a good day for Android developers, and for Android users in the future: The new 1.6 version of the Android operating system is released. See this movie for the changes:

{ 0 comments }

Installing Beanstalkd queing daemon on Mac OS X

by Michiel on August 28, 2009 · 0 comments

in Uncategorized

Beanstalkd is a queueing deamon that let’s you queue messages from one client and let them be processed by another client. It has features like burrying messages for later usage if the command at the first time can’t be executed and more stuff like that.

We use it for queuing things in Ruby on Rails applications which are time-intensive. For example, executing an install command on a remote server can take some time and you don’t want your web application to block or queue op other requests in this case.

Beanstalkd has excellent Ruby bindings which you can use in  your Rails app. There’s even a gem for it:

gem install beanstalk-client

Using it is as easy as:

beanstalk = Beanstalk::Pool.new(['10.0.1.5:11300'])
beanstalk.put('hello')

beanstalk = Beanstalk::Pool.new(['10.0.1.5:11300'])
loop do
  job = beanstalk.reserve
  puts job.body # prints "hello"
  job.delete
end

Installing on Mac OS X

Beanstalkd depends on libEvent, so you’ll need to install that first:

wget http://monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure
make
sudo make install

And then you can install Beanstalkd:

wget http://xph.us/dist/beanstalkd/beanstalkd-1.3.tar.gz
tar zxvf beanstalkd-1.3.tar.gz
cd beanstalkd-1.3.tar.gz
./configure
make
sudo make install

{ 0 comments }

Objective C and iPhone development for Ruby developers

by Michiel on July 10, 2009 · 1 comment

in Uncategorized

I started learning Objective C 2.0 (ObjC) – the primary programming language used to write Apple and iPhone applications – a few days ago after seeing the Stanford iPhone Development Course on iTunes U. I really recommend watching the lectures in this course as a podcast and making the assignments which are publicly available on the course website.

I always thought ObjC was crap and hard to understand but after a few hours of playing with it, it is actually quite easy. Here is a list of code examples for ruby developers.

The most important thing

The most important thing you should know is how to use ObjC as an Object Oriented Programming language. ObjC has everything from classes to instances to super- and subsetting classes, from class methods to instance methods and variables. The only thing you need to know is how to call them.

ObjC uses the following syntax for this:

[object message:first_argument andSecondArgument:second_argument]

Here, “object” is the object on which you want to call the function “message”. After that is a colon (:) and a comma-seperated list of the arguments. In fact the [ ] (square brackets) are the “.” and “::” in Ruby or “->” and “::” in PHP.

Assigning strings

my_string = "Hello, world!"

translates to

NSString *myString = [NSString stringFromString @"Hello, world!"]

or more convenient:

NSString *myString = @"Hello, world!"

Creating objects and calling instance methods

person = Person.new
person.walk(10); # Let's a person walk by 10
                           # metres by calling the "walk"
                           # method on the instance of person

translates to

Person *person = [[Person alloc] init]
[person walk:10] // Given that 10 or the variable in this place
                  // is an integer. In this case it's the integer 10

Arrays and hashes

my_hash = {'key' => 'value', 'key2' => person}

my_array = ['value', person]

translates to

NSDictionary *myDictionary = [NSDictionary
    dictionaryWithObjectsAndKeys:@"value", @"key", person, @"key2", nil]

NSArray *myArray = [NSArray arrayWithObjects:@"value", person, nil]

/* Notice that the "lists" when initializing the dictionary (hash) and the array
   should be terminated with "nil" */

I hope this post helps you getting started with developing applications in Objective C 2.0. If you have any tips or questions, please drop a line in the comments, get to me on Twitter/FriendFeed or send me an e-mail.

{ 1 comment }

Why The Pirate Bay deal is great

by Michiel on June 30, 2009 · 0 comments

in General Posts

Today TPB announced it would sell itself to the Global Gaming Factory X AB. This is great for the future of the open internet and might be a step forwards to open up the conservative big copyright watchers and media companies Here’s why:

  • It shows commercial interest in an “illegal” practice started by a wide community of both regular people and people interested in protecting the openness of the internet.
  • If I believe TPBs blogpost, the company buying the torrent site is not only interested in earning money, but also in keeping the site running in the philosophy as it started, but also find ways to maybe bring commercial methods of downloading the files linked to as torrents.
  • The money will go into a foundation protecting the freedom of speach, freedom of information and openness of the internet.

{ 0 comments }

4 Rails gems and plugins you should know about

by Michiel on June 18, 2009 · 0 comments

in Uncategorized

Here are four gems and Rails plugins I generally like to use to build Rails applications. Use them to support authentication, internationalization, haml/sass and model avatars in your new Rails app.

Blueprint CSS framework, haml and Sass

If you’re still using erb for your standard views you are old school. You should use Compass, the Rails gem that allows you to easily create stylesheets based on the Blueprint framework, using Haml and Sass in your styles and views.

Internationalization on models (I18n)

You can use the excellent Globalize2 by joshmh for making your Rails apps international. This plugins allows you to translate attributes on your models (dynamic translation). You can do this by creating the correct translation migrations and by adding this to your models. Use this plugin in combination with the standard Rails I18n API to fully translate your application labels and models.

class YourModel < ActiveRecord::Base
  translates :title, :text
end

Restful authentication with Authlogic

The authlogic gem by binarylogic allows you to create a flexible authentication system with accounts for your application. It supports a lot of options to configure and you can keep it as basic as possible. For example, you can create parent accounts (example: businesses and users of the application in that business), password reset functionality, OpenID and more. Check it out!

Account avatars and product previews

Want to add user profile pictures or product previews if you're running a web shop or other catalogue application? Use the Thoughtbott Paperclip plugin to generate avatar columns, handle the file uploads and scale to different sizes. If you like Paperclip, be sure to check out other Thoughtbott Rails marbles!

{ 0 comments }