Wednesday, October 6, 2010

JNI - where's the env->CallStringMethod?

It makes me cry. JNI is a necessary evil, but still evil.

Why isn't there some nice way to call a CallStringMethod? Especially when working with
Android's bundles, which have getString. It would make life a million times easier.


Anyway here's a workaround:

jstring my_java_string = (jstring)env->CallObjectMethod(bundle, myBundle.getString, env->NewStringUTF("test"));
if(
my_java_string == NULL){
// Error
return;
}
char*
my_c_string = strdup(env->GetStringUTFChars(my_java_string, 0));
env->ReleaseStringUTFChars(
my_java_string, my_c_string);

Sunday, September 19, 2010

First Brew tasting

I was unsure that the brew was fermenting, as there were no bubbles whenever I checked. Then the bad (read: useless) bottle capper meant that there was such a loose seal that the beer didn't carbonate. This also led to a lack of cleaning of the bottles after the bottling as I didn't want to disturb the delicate seal. This caused mold, so I had to clean and dry the whole batch.

After purchasing a better bottle capper and re-sugaring the bottles (and waiting about 2 weeks) - Tasting time!

So bearing in mind that it was a bare bones homebrew kit (no dry malt extract - DME, hops etc.) it tasted like a slightly carbonated malty cordial with a slight apple aftertaste. I'd give it a 2 out of 10. Alcohol content really isn't a concern for me, it's all about flavour. But I would estimate about 4% due to some unreliable gravity readings.

The lessons learnt from this brew are:
  1. Don't skimp on a bottle capper - buy a good one!
  2. Dextrose is good but still gives a slightly appley after taste.
  3. No DME makes a fairly body-less beer.
  4. Thoroughly wash and dry the bottles after bottling and muck on the outside will cause mold.
So now I'm making a Coopers IPA to hopefully bring out some true flavour. I have used DME instead of half the sugar, and after reading up on other people's blogs and tasting the malt extract I decided to hold back on adding any extra hops.

So I'll report back with the results :)

Saturday, September 11, 2010

Google AI Comp

I'm entering the Google AI comp again this time - looking forward to challenge and aiming for a top ten result. Halla tummarna :)

For starters I'll get a basic bot then explore a few more advanced techniques. Watch this space.

Monday, August 9, 2010

First Brew

I remember Dad preparing a batch of homebrew in the evening then a lazy sunday spent bottling the 20 litres or so of beer. I have always wanted to brew over here in sweden but due to lack of linguistic knowledge, I have never found a place that I could pick up a plastic vat to ferment the beer. Until this afternoon. I went to Malmö and picked up a 25L vat with all the necessary equipment on my way to band practice.

As much fun as it was using it as a drum at practice, I brought it home tonight and using a Cooper's Pale Ale extract and a kilo of dexterous made my first brew. All ready to bottle over the weekend. I'll report back with photos and a flavour report.

Saturday, August 7, 2010

Open Drums

I wanted to be able to record any ideas I had for drum beats quick and easily. This was much simpler that I expeced.

After getting OpenDrums, and installing a few graphics packages:

$ sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev
$ make

It works like a charm, now to change the default sounds to something a little more realistic.

Monday, August 2, 2010

Canon Pixma MP270 driver in 64bit Ubuntu

Canon provides the 32bit drivers to the Pixma MP270, but not 64 bit driver. Instead of building them from source, just get the 32 bit drivers from canon's site.

In the packages directory there are 2 debs. All you need to do now is:

sudo dpkg -i --force-architecture ./cnijfilter-common_3.20-1_i386.deb
sudo dpkg -i --force-architecture ./cnijfilter-mp270series_3.20-1_i386.deb

And the printer should work :)

Sunday, August 1, 2010

Ruby on rails 3 - rvm, bundle, eeeekk

Having a freshly loaded Ubuntu 10.04 on my main desktop (after checking it out for months on my laptop), I thought I'd get ruby on rails set up. After setting up Rails 2 with the minimum of fuss, I took the challenge of upgrading to Rails 3 (release candidate).

RVM is now an essential component of any rails environment, letting you change between rails version in an instant (Theoretically, but more on that soon).

Installing it was as simple as:
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

After installing all the necessary ubuntu packages

$ rvm install 1.9.2-rc2
$ rvm 1.9.2-rc2
$ gem install rails --pre

I can't seem to switch between rubies as I would like, but I'm sure I can solve this soon.

To start a new project we have to forget the rails 2 ways and start with:

$ rails new test
_project

You should see the usual files (plus a few new ones) being created.

$ cd test_project
$ bundle install

This is where I had some problems with mysql. I had installed every possible mysql package but it stll wasn't working.

Using activeresource (3.0.0.rc)
Using bundler (1.0.0.rc.1)
Installing mysql (2.8.1) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby1.8 extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib


Gem files will remain installed in /home/stumacd/RoR/projects/wiki/ruby/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /home/stumacd/RoR/projects/wiki/ruby/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `each'
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
from /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:198:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/source.rb:96:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/installer.rb:51:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/installer.rb:40:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/installer.rb:8:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/cli.rb:115:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/task.rb:22:in `send'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/invocation.rb:109
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/invocation.rb:116:in `call'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/invocation.rb:116:in `invoke'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor.rb:161:in `start'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor/base.rb:379:in `start'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/lib/bundler/vendor/thor.rb:140:in `start'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.1/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19

The trick was to install it with the correct parameters (found by using $ which mysql)

$ gem install mysql -- --with-mysql-conf=/usr/bin/mysql --with-mysql-lib=/usr/lib/mysql

This allowed all the applicable gems to be installed.

And now with a:

$ rails server

WEBrick was up and running and http://localhost:3000 was showing the standard page. Gold dust :)