Class instance variable for ruby modules

Sorry if the title is a bit misleading, but this post talks about the scenario such that I have several classes, all extending the same module, and I need to avoid using shared or class variables (@@) in the module because the classes extending the module may change the shared or class variable at the same time and cause problem. So basically we have: class Test   extend TestModule end class TestTwo   extend TestModule end module TestModule   @@val   def somemethod      #do something with @@val   end  end  And the goal is the replace the @@val class variable with a class … Continue reading Class instance variable for ruby modules

Don’t forget the port number when replicating CouchDB

In the afternoon I needed to replicate a database  from my co-worker’s CoudhDB using CouchDBX. In the replicator, I entered my co-worker’s database’s path like the following: http://10.0.0.3/TestDatabase And I selected to replicate to one of my existing databases.  Everything seemed to be right (I could ping and telnet my co-worker’s IP and CouchDB port 5984 without problem), but CouchDBX returned error 500, could not connect to remote database. After a series of diagnostics, we finally realized, we forgot to put the port number in the path of remote database. When we changed the database path to http://10.0.0.3:5984/TestDatabase,  everything just worked … Continue reading Don’t forget the port number when replicating CouchDB

Creating a Merb Rack middleware for running in Merb applications

There are a lot of resources on the Internet showing how to write and run a standalone rack application or middleware, but few showing how to write one to run in other Merb applications. This is actually very easy, so I’m going to share how I did it. Hopefully to be helpful to people in such need. The goal is to have a rack middleware in a merb application, which can be installed as gem, and then can be ued in other merb applications. First, create the merb application: $ merb-gen app application_name where application_name is your proposed application name. … Continue reading Creating a Merb Rack middleware for running in Merb applications

Modify bind address for couchdb 0.9.0

By default couchdb only binds to 127.0.0.1 so it’s not accepting requests from other IP addresses. The bind address setting can be modified in the configuration file. For 0.9.0, by default, the default configuration file is located at /usr/local/etc/couchdb/default.ini, and the local configuration file is located at /usr/local/etc/couchdb/local.ini. Settings in the local configuration file will override those in the default one.  Bind address is in the [httpd] section [httpd] port = 5984 bind_address = 127.0.0.1 Note that in the local configuration file, this may be commented out with a leading “;”, if you want to set it in the local … Continue reading Modify bind address for couchdb 0.9.0

Making an executable standalone Merb Slice gem

I have a standalone Merb Slice which can be started by running the “slice” command in its top directory. Today I needed to make a gem file for this Slice so that people can install the gem and start it directly by running the Slice’s name, for example, “foo”. So I created the Rakefile, in which I specified the executable file in the following way: — Code: Rakefile — spec = Gem::Specification.new do |s|  s.rubyforge_project = ‘merb’  s.name = GEM_NAME  s.version = GEM_VERSION  s.platform = Gem::Platform::RUBY  s.has_rdoc = false  s.summary = SUMMARY  s.description = s.summary  s.author = AUTHOR  s.email = … Continue reading Making an executable standalone Merb Slice gem

Testing exceptions with RSpec

I’m new to ruby and rspec. I wrote a ruby function and wanted to check whether it throws an exception or not in a certain situation with rspec, but I realized should_raise function no longer worked in the rspec version I was using (1.2.2). I tried to find information on the Internet and I found that I should use raise_error. However, when I wrote something like: it “description” do    ObjectName.new(“parameterName”).should raise_error end It did not work. Finally I learned the correct way – using lambda: it “description” do    lambda{ObjectName.new(“parameterName”)}.should raise_error end Wanted to post this here and hope it can be … Continue reading Testing exceptions with RSpec

Writing and Project Samples

PROGRAMMING AND WRITING 1. Windows Mobile Starter Kits: Tic Tac Toe and Home Screen Alarm Plugin Description: These two projects were completed when I was working at Microsoft Mobile and Embedded Devices Content Publishing Team (Summer 07). Both programs were written in C++ with easy to understand documentations. I was involved in the design, development, testing and documentation processes. The Tic Tac Toe project focused on Windows Mobile Ink APIs and screen resolution awareness; the Home Screen Alarm Plugin project focused on Windows Mobile 6 Standard Home Screen Plug-in programming. URL (at Microsoft’s web site): http://msdn.microsoft.com/en-us/windowsmobile/bb264330.aspx 2. EasyCapture User Assistance … Continue reading Writing and Project Samples

Using Eclipse to add/update files to CVS

The command-line based CVS tool is hard to use for first time users; many GUI-based CVS tools are not really well designed to be easy to use either. I’m not against the point that developers and testers should learn how to use a technical tool in no time even though the tool is hard to use, but developers and testers have their schedules and need to be efficient. Having an efficient way to add and update files to CVS is very necessary. Eclipse is the tool I use to deal with CVS file operations. It works really well not only … Continue reading Using Eclipse to add/update files to CVS

How to connect Remote Spy++ to Windows Mobile emulators in Visual Studio 2008

I don’t see any problem doing so, but I got a question from a comment of one of my earlier post. The question states “Hello! Could you please tell more about how to make Remote Spy++ connect to WM 5.0 emulator, which I got with MSVS2008? I’ve read some articles at microsoft.com, but they say you can’t connect to Windows Mobile, only Windows CE…” So I want to explain the process to connect Remote Spy to Windows Mobile emulator in Visual Studio 2008. Here are the steps: 1. On the Debug menu of Visual Studio 2008, click Start Debugging. Note: … Continue reading How to connect Remote Spy++ to Windows Mobile emulators in Visual Studio 2008

No way to join the social – Is the lack of global languages support on Zune a problem, or not at all?

It’s been a pretty long time since the first generation of Zune came out. Microsoft wants to attract us as potential users to join the social – they made pretty good media sharing and community features so that to distinct from similar products made by other companies. However, Zune has a very serious usability problem that even though a huge amount of users have been complaining all the time, it’s never been solved. It is the lack of support for most of the global languages. It’s true that Zune has not yet been available globally. However, the assumption of people … Continue reading No way to join the social – Is the lack of global languages support on Zune a problem, or not at all?