Archive for the 'Work' Category

Sun
31
Dec '06
Tab-completion and syntax-highlighting for irb
by Frank Spychalski filed under Ruby
wirble shell example on dark background
wirble shell example on light background

Please forgive me if I state the obvious, but I just found out about this great gem called Wirble. Wirble adds tab-completion and syntax-highlighting to irb.

Installation is really simple, just install the gem (gem install wirble) and add this to your .irbrc:

require 'rubygems'
require 'wirble'

Wirble.init
Wirble.colorize

For a console with a dark background everything looks pretty good but I prefer a light background where yellow is not easy to read. Thanks to the really helpful README the solution was easy to find. I had to add a few more lines to my .irbrc to change some settings from yellow and white to something readable in my console.

require 'rubygems'
require 'wirble'

Wirble.init
Wirble.colorize

colors = Wirble::Colorize.colors.merge({
  :object_class => :purple,
  :symbol => :purple,
  :symbol_prefix => :purple
})
Wirble::Colorize.colors = colors


Sat
23
Dec '06
Changes…
by Frank Spychalski filed under Work

Yesterday was my last day at Schlund+Partner. I have a few days of vacation left and next year I will start working for Gameforge AG.

I’m glad that I was able to quit at S+P without burning any bridges. My former manager told me that “… if it is not working out, I will happily take you back…”.

I will continue to write software, but the tool set will change: from Java, EJB and way too much of XML to PHP (probably with cakephp) and I will try to sneak in some Ruby every once in a while :-) The thing I like most about my new job is that I will start working on a brand new project. I spent the last year working on two projects started by others, which droppen into my lap and I had to get them into production shape.

I hope I will be able to talk more about my new project next year. But I want to check with my new bosses first.


Tue
12
Dec '06
Magic Ruby Hacker mug
by Frank Spychalski filed under Fun, Ruby

ruby hacker logo in courier

There is a CafePress shop for RubyHacker stuff with a few nice thingies. But I wanted something else :-)

magic mug

A shop (fotokasten.de) sells all-black mugs which only reveal the image when something hot is inside. Therefore I needed my own RubyHacker image and couldn’t find one online. To save everybody else the work, here’s my result.

I will post images of the mug when I have it :-)

Update:
I made a mistake and put the wrong image online. Fotokasten does not accept gif (which is pretty lame but I cannot change it). Changed the image to a jpg.


Tue
24
Oct '06
Ruby search engine
by Frank Spychalski filed under Ruby

When I read that Google offers customizable search engines, I spent a few minutes to create one for my usual ruby searches. It can be found here. Right now, it doesn’t look very nice and I added only about a dozen sites, but I will add more and fine-tune the searches in the next few days. If anybody else wants to contribute, be my guest…

Update:
Google provides a bookmarklet called Google Marker, which helps adding new sites. This morning I added about 20 new sites and tweaked the searches.

Update:
This morning I added a few more pages and changed the default behavior from “Search the entire web but emphasize included sites.” to “Search only included sites.”.

Update:
3 contributors have signed up and I added a lot of new sites. Go visit Ruby & Rails Search and test it.


Mon
2
Oct '06
Profiling Rails Unittests
by Frank Spychalski filed under Rails, Ruby

Thanks to a hint by Chris Mear on the Ruby on Rails Mailinglist I had an idea how to add profiling my unittests. It’s a simple 3 step process and adds just 5 lines of code to your unittests:

Step 1:

require 'profiler'

Step 2:

 def setup
  # ...
  # your normal setup code
  # ...
  Profiler__::start_profile
 end

Step 2:

 def teardown
  Profiler__::stop_profile
  f=File::new("#{RAILS_ROOT}/log/profiler.#{name() + ' ' +
              Time.now.strftime('%Y-%m-%d %H:%M')}.log", 'w')
  Profiler__::print_profile(f)
  # ...
  # your normal teardown code
  # ...
 end

As you probably guessed from the code, this will log the profiling results into a file for each test. But beware: this is VERY SLOW! The tests I was profiling took 9s without profiling and 1267s with profiling… But slow profiling still beats no profiling :-)

If you are looking for memory profiling, there is a nice article by Scott Laird on Memory leak profiling with Rails.


Mon
7
Aug '06
Playing on the CodeGolf Range
by Frank Spychalski filed under articles, Computer, Fun, Ruby

picture by bigpru

I stumbled over this funny site called CodeGolf.com and tried my luck on the first problem (actually it’s the sixth, but it was the last and therefore appeared first on their page – confused?) Writing a Brainfuck Interpreter:

The brainfuck language uses a simple model of a computer consisting of an array of memory cells, a movable pointer into the array, an output stream, an input stream and the program itself. The program is formed from a sequence of the below commands :

  • > – Increment the pointer to point to the next cell to the right.
  • < – Decrement the pointer to point to the next cell to the left.
  • + – Increment the byte pointed to by the pointer.
  • - – Decrement the byte pointed to by the pointer.
  • [ - Jump forward to the command after the corresponding ] if the byte at the pointer is zero.
  • ] – Jump back to the command after the corresponding [ if the byte at the pointer is non-zero.
  • . – Output the value of the byte at the pointer.
  • , – Accept one byte of input, storing its value in the byte at the pointer.

It didn’t take me very long to write a running interpreter. My first version was more than a thousand characters. Even after renaming the variables and stripping all the whitespaces I still needed around 700 characters, which is huge compared to the best Ruby solution with only 142 characters. Read the rest of this entry »


Mon
31
Jul '06
Planning a Ruby course – request for comments
by Frank Spychalski filed under Ruby

Later this year I am going to hold a beginners course for Ruby at the VHS in Karlsruhe. Yesterday I started thinking about the topics I want to cover. The participants will have some programming experience which means I don’t have to explain the very basics. The course runs for two days with six hours each day, so I will have 12 hours to teach them Ruby. From the tutorials I read, I liked Mr. Neighborly’s tutorial best and I will use a similar structure. Read the rest of this entry »


Mon
24
Jul '06
Mocking context lookups
by Frank Spychalski filed under Java, Work

Sorry for another non-ruby post, but I’m currently very busy at work playing with JBoss 4, EJB 3, EasyMock, and a bunch of other pretty cool technologies.

I’m a big fan of EasyMock but frequently I ran into problems when code performed lookups to get resources like:


Context ctx = new InitialContext();
UserTransaction trans = (UserTransaction) ctx.lookup("UserTransaction");
trans.begin();

Read the rest of this entry »


Tue
18
Jul '06
XSL Best Practice
by Frank Spychalski filed under Rants, Work

I have to work with XSL templates again and in addition to XML being a terrible language to write any kind of code in I found this anti-pattern. Read the rest of this entry »


Thu
13
Jul '06
Getting rid of Hypersonic Db in Jboss 4
by Frank Spychalski filed under articles, Java, Work

I don’t know how much time I could have saved, if someone told me I should not use the hypersonic database for a production JBoss system.

jboss.org/wiki:
hsqldb is not a production quality database.

Read the rest of this entry »