Fair warning, this post is as much for my own benefit as anyone elses.  This is a problem I solve once a year, and I cannot remember how to do it from one time to the next.

The Problem:

I want to position a block element at a particular place in its containing elelment.  In this case I want to put a menu bar a particular point in the header div.

The Solution:

Generally ‘position: absolute’ will position an element with regard to the whole page.  If on the otherhand the contining element has ‘position: relative’ then an absolutly positioned child will be relitive to it’s parent instead.

Read the rest of this entry »

A few weeks ago, I saw as one of GitHub’s featured projects a bit about a CSS design framework called Compass. Actually, Compass is several framework, (Blueprint, 960 and YUI) wrapped up with some very exciting Haml/Sass code. Sense CSS has always take me more time then it should, I decided to give it a try. I wanted to make a static page first so I didn’t have to worry about testing models, and all the other thing that come part and parcel with Merb or Rails. I decided that I would redo my resume in HTML.

I am looking for a job, and have been using Craig’s list as part of my search. Sending along a link to my resume would let me keep track of how often it was looked at. A resume is also a rather static document that I could serve as strait HTML and CSS with a little hand editing as necessary. It turned out to be a great first project and I am happy with the result. Compass is an excellent way to make well structured layouts.

Compass solves one of the major complaints against grid systems: they mix formatting with content. Without a tools like Compass and sass, Grid stylesheets have to define CSS classes like ‘grid-12′ that you add to your mark-up. These class selectors are calculated and designed to form the grid. Compass uses those formulas and the power of sass to apply the appropriate styling directly to the content. All the domain knowledge you have from the grid api still holds. The code goes into your sass stylesheet outlines rather then into classes in your HTML. Bottom line, you get all the power of a grid framework unobtrusively.

While Compass offers three different grid systems, I decided to use Blueprint for this project for it’s flexibility, and manageable set of options. The Compass executable creates a nice project for you with sass files and directory for stylesheets and images. There is a configuration file that will let you point these directories to the appropriate place in an existing project. Using the executable in that directory subsequently will compile the sass file into CSS. There is even an option to have Compass watch for change in the sass files and recompile them. This is very helpful, and something I wish haml would do as well.

I started by writing my resume in haml essentially as a series of lists with titles. I then used the blueprint api to move the sections into the correct alignment. Then applied the typography and utilities modules to the lists to remove the bullets and make the page flow nicely. Fially I used a bit of non-framework code to tweak alignments and colors.

The process was the same for the print alignment, except that a letter size piece of paper at 96dpi is less then 950px across. I changes the size of my box model, in essence eliminating one 40px column to make everything fit on one page and still look nice. I think this is something more sites should do and would eliminate the need for a “printer friendly” version. Finally, had copied all the compiled files (html & css) to the public directory on my web server. From initial download to final product with no previous experience in either Blueprint or Compass was about six hours. In my opinion a far better result in less time then I would have gotten with a pure css implementation.

You can see my source files at Github and the finished product here.

My conclusion is that Compass will be my CSS framework of choice for the foreseeable future. My next project is to write my own blog engine in Merb, and I have already added Compass the the project.

Datamapper has some unexpected bahavior when saving floting point numbers.  I am using datamapper  0.9.11 and I have a ‘property :x, Float’ in my class.  I set that value to a random number with ‘rand * 1000.0′  and found that my records would not save.  They always came back with the error “X is not a number.”

What is actually happening is that my floating point number has 12 decmal precision and Datamappers default is 10.  There are some tickets that indicate that the next version of Datamapper will give more informative errors, but I would also like bigger defaults.

Anyway, the solution to this is to either set a higher precission in you property statment or use ’round_with_precision(10)’ on your numbers before saving them.

I’ve spent today looking at CSS layout frameworks.  As you might be able to tell from the increasingly stale content at the main site, I am not a Graphic Design person.  My hope had been to hobble through a first layout and “work on it later.”  I am now at the point where I have several little pieces that I want to try outside of the clunky text framework I used for sketching. I spent most of my free time a couple of days ago trying to make something that worked.   Not something stunning, just enough to get by. unfortunately, CSS is not bending to my will at a rate that will keep my pore mind interested.  Positioning elements on a page is just not intuitive.

Fortunately, I ran across a post about CSS layout frameworks today and spent some time looking at how they work.  This seems tobe the answer to the rapid layout problem.  Now the trick will be to decide among them.  I looked at the 960 grid system, Blueprint CSS grid, and Yahoo UI Grid.  unfortunately there is not enough time today to give any of them a good try but I’m looking forward to it.

Read the rest of this entry »

Yesterday, I finally got around to installing Ubuntu 9.04 on my laptop. I’m still debating about whether to use Xubuntu or the standard desktop edition for my aging desktop. I’ll try for a writeup of Jaunty Jackolope once I have had a chance to really get to know it. The more important thing to not is that I’ve been using Ubuntu almost exclusively for a year and I have only had to boot up window 3 times. I love it!

Read the rest of this entry »

Ok, it is the time of year when I always have too much to do.  Fortunately, things have quieted down now.  Unfortunately, this slowing and other factors have also brought my current career path to an end.  At least for the moment.

I am now looking for work, and trying out some new directions in life.  Including looking for some Gigs in web design.  This also means that we should see progress on Antares Trader pick up again.  If anyone in the Sacramento Area or Bay Area is willing to take a chance on a hobbiest looking to go pro in the Ruby world e-mail me.

It’s good to be back.

Sorry for the long silence.  There have been a number of reasons.  Real life getting in the way and a nasty cold among them.

The biggest one has been my inability to wrap my head around how to make good user interface.  I have though a great deal for a long time about how to build the back end of AntaresTrader.  I have not put in anywhere near as much though to how a user would want to interact with this backend.  I find that I am writing a lot of code to satisfy “Given” cucumber steps which basically just set up models for a story.  But, I am getting stalled by Then steps that need to have controllers and views that work.

Read the rest of this entry »

If you are looking for answer, look elsewhere.  This is something I just can’t get my mind around.

I’m working on an exploration algorythm for Antares Trader.  There are a number of things thace can be discovered in the game.  You just have to have the time, money and equiment to go look.  Examples are thing like finding planets around stars, building sites on planets, mineral deposits at a site, etc.  My question is how do model finding these thing?  Here are the parameters I have so far.  I’m going to use finding sites on a planet as an example:

Read the rest of this entry »

Ok, January is not over yet, but here goes anyway.

  • JZForm is at least good enough to get user registration working the way it should.
  •  Accounts are back in the game after an extended life in ActiveRecord purgatory.
  • Logging has been a pain. I want to be able to read the logs on line, but I also don’t want to send database access through the roof.
  • Counting in DataMapper suffers from bad N+1 disease.  Have to look into why.
  • Var (the global game state model) got a total rewrite.  It now can cache and is ready to use IPC to sync across multiple instance.
  • Cucumber integration testing is great.  It lets me write lots of big picture stuff then bridge that down to failing tests at in an effecient way.
  • Still RSpeing models based on what is needed to get cucumber working
  • Ideas for some kind of universal admin interface are in the works.  Will need to happen soon. Must be done before long overdue redeploy.

My current estimates say that I am 1/8th of the way there, but they may be a little optimistic.

Generally in Ruby one will use the ‘to_i’ method to get an integer from it’s string representation.  Unfortunately, this method always returns a number regardless of whether or not the the string made scene as a number.  For example “foo”.to_i #=> 0.  This is not always what you want. To only get number from strings that make sense as numbers use Integer(str) instead.  If it cannot make a number out of it it will raise an ArgumentError.  The same applies to Number(str) for real numbers.  The format of numbers is the same as that for the ruby parser. (ie if you can write it that way in ruby code, it is accepted by the Integer and Number methods.)

  • Stats

    Visits today: 24 | Top Post Merb: Routing 201