You might often want to connect to different databases using ActiveRecord. Here’s how you do it:
class DatabaseCurrent < ActiveRecord::Base
self.abstract_class = true
class DatabaseOld < ActiveRecord::Base
self.abstract_class = true
#Model definitions (current):
class Video < DatabaseCurrent
class Photo < DatabaseCurrent
class User < DatabaseCurrent
class Tag < DatabaseCurrent
#Model definitions (old):
class FileDB < DatabaseOld
Pretty easy. The only thing to note is that you should
set_table_name, otherwise, AR chokes up. Also, often you want to directly play directly with SQL. Unfortunately,
ActiveRecord::Base.execute doesn’t work any longer (coz it doesn’t have a connection), but you can do it this way:
That’s the tutorial for the day!
An easy way to deploy JAR/JAD content on all phones with GPRS is to create a WML site and provide a link to the JAR file that you have. [As an aside, the whole J2ME scene is so fragmented that it sucks completely. Let’s hope Android sorts it out.]
Here’s how you go about setting up that in Lighttpd:
Add these mimetypes (to lighttpd.conf or mime-types.conf):
mimetype.assign += (
".wml" => "text/vnd.wap.wml",
".wmlc" => "application/vnd.wap.wmlc",
".wmls" => "text/vnd.wap.vmlscript",
".vmlsc" => "application/vnd.wap.wmlscriptc",
".wbmp" => "image/vnd.wap.wbmp",
".jar" => "application/java-archive",
".jad" => "text/vnd.sun.j2me.app-descriptor"
Add the index.wml file as a valid DirectoryIndex:
server.indexfiles += ("index.wml")
Make this .wml file and upload it somewhere (replace JARCLIENT with your .jar file, and JADCLIENT with your .jad file):
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
<p>Download the Jar file:</p>
<a href="JADCLIENT.jad">Download (JAD)</a>
Restart your server, and that should be it! If you’re using Apache, the steps are similar.
For BarcampKerala, I made a small 2D game in Ruby and Gosu, which is a clone of a popular flash-based game by the same name.
I call it Gosu-N3wton, and I had great fun developing this game. Go check it out! (The code is opensource)
A hint for developers on the Orkut Sandbox, download its two CSS files: here and here and use those classes to style your content. It feels much more a part of orkut that way. To figure out what styles to use, firebug the orkut page.
A lot has been said about OpenSocial and Facebook, this is an attempt to say a bit more. As usual, a free-flowing list of observations:
- It’s currently not clear how OpenSocial apps communicate between each other across networks and how one app maps a user profile in one network to another. Without this, it’s mostly a single API which works across multiple containers in isolation. A single API that collates multiple containers is much more interesting.