Posted by Anders
Mon, 09 Apr 2007 15:20:00 GMT
I was going to use ActiveRecord for some simple storage in a small application I’m hacking on. Since ActiveRecord itself has support for lots of databases I figured that it didn’t matter which database I used for testing1.
In Java I would have used Hypersonic, or some other self-contained in-memory database, for this. Looking around in Rails land, you find that most people use Rails’ testing features and run their tests against a separate instance of their production database, usually MySQL. Other people use Sqlite3, which seems to be the simplest database around.
Since I don’t have a production database (and generally dislike MySQL2), I looked at Sqlite. First of all, it requires Sqlite itself to be installed. In OS X this is already done, but it will be a problem elsewhere. Then there’s a confusing selection of different gems with drivers. But once you get the right one installed, it seems to work fine.
Once I started working with it, I ran into a problem. Every time something is wrong with the database structure, no matter if it’s the whole database missing or just a single column misspelled, I get the same error:
`table_structure': ActiveRecord::StatementInvalid (ActiveRecord::StatementInvalid)
Since I was changing the database structure a lot, I got this all the time. Don’t know if this is Sqlite, the driver, ActiveRecord or me that’s to blame, but it wasn’t very practical.
Since my patience is very short, I simply dropped the database storage feature from my app. :) But there seems to be two issues here:
- There is no self-contained, gem-installed database for Ruby
- The error handling in Sqlite, or something on the way to Sqlite, isn’t very good
I now hope that someone will tell me what an idiot I am and that I should use some other driver, or some other database.
1 I’m using RSpec, which is the best testing framework since sliced bread.
2 Bleh.
Update: By enabling debug logging in ActiveRecord you’re supposed to get more information out of it. I’ll try that the next time I work on it.
Posted in Ruby, Programming | Tags databases, testing | no comments
Posted by Anders
Wed, 28 Mar 2007 20:56:00 GMT
626 exponeringar, i kameran chimpade ner till 464 st, sen vidare sållade på datorn till 235… 170… 132 bilder. Tog ett tag, men nu är mina bilder från Thailand klara!
Jag har lagt upp dem på flickr.com


Posted in Photo | no comments
Posted by Anders
Wed, 21 Mar 2007 21:23:00 GMT
Med min nya blixt, mitt nya macro-objektiv och lite prylar jag hittade hemma så tog jag den här bilden:


Jag använde ett brevställ i mjölkvit plast bakom som en fattigmans “softbox” för att få mjukare ljus från blixten. Sen har jag vita papper som reflektorer framför och ovanför bild. Man ser reflektionen av ena pappret längs kanten, mellan klockan ett och fyra. Det var lätt att råka få med reflektioner av sig själv i de kromade fästena till armbandet.
Inte precis det perfekta produktfotot, men för att vara några minuters jobb och mitt första försök så är jag rätt nöjd.
Objektivet, Sigma 70/2.8, är för övrigt helt vansinnigt skarpt. För porträttbilder så ser bilderna knivskarpa ut även i 100% storlek, även de tagna med vidöppen bländare. Skoj!
Posted in Photo | Tags macro | no comments
Posted by Anders
Sun, 11 Mar 2007 17:45:00 GMT
Nu har jag lyckats få nya blixten separerad från kameran. Med ett par special-adaptrar (varken min kamera eller min blixt har några kabel-anslutningar) och lite lödning så löste det sig.
Istället för att köpa speciella “PC sync”-kablar i olika längder, så köpte jag en 20cm kabel, som jag med en sax, kniv, ett par kontakter och en lödkolv gjorde om till två adaptrar för 3,5mm stereoplugg. Sen har jag köpt billiga ljudkablar istället.

Trots att mina lödnings-kunskaper gör mig till en fara för både liv och egendom så lyckades jag faktiskt få kablar som ledde ström, på första försöket. Kameran tog en bild och blixten avfyrades. Samtidigt!
Sen märkte jag att blixten ibland avfyrades även när kameran inte var inblandad. Jag tog isär kontakten och upptäckte att mitt lödande lyckats smälta bort en del isolering. En snabb reparation med Karlssons Klister och allt verkar funka igen. (Jag kollade först att klistret verkligen funkade som isolator).
Succé!

Posted in Photo | no comments
Posted by Anders
Sun, 04 Mar 2007 08:19:00 GMT
Im back home again, after three relaxing weeks in Thailand (minus one day in the non-relaxing but fun insanity that is Bangkok).

Inspired by the great photography tutorials and articles at The Strobist I had decided to buy a flash gun. At Pantip Plaza in Bangkok I found the one I was looking for, at a decent price. I now own the Canon 430EX, which should be usable both as an on-camera automatic flash and an off-camera manual flash (once I get the cables and adapters required). I have already tried it a little at a friend’s, bouncing light against ceilings and walls.

While looking for the flash I couldn’t resist buying a lens, the new Sigma “MACRO 70mm F2.8 EX DG”. It’s similar to the 100mm lens I loved using with the old Canon. Not only a nice portrait lens, this one is also a true macro lens, which will be fun to play with.
Even before getting these new toys I shot roughly 600 photos during my trip, which will take a while to go through.
Posted in Photo | no comments
Posted by Anders
Thu, 08 Feb 2007 19:31:00 GMT
Nog med vinter och mörker: På lördag åker jag till Thailand, för tre veckor av klättring och sol! Större delen av tiden tänker vi vara på Tonsai, en fantastisk plats för klättring. Förhoppningsvis är det redan vår när jag kommer hem i mars.
Jag kanske skriver några uppdateringar här, eller på Resdagboken (som Ghost Ganz), eller så hör jag inte av mig alls. I vilket fall, ha det bra så länge!
no comments
Posted by Anders
Sat, 03 Feb 2007 18:11:00 GMT
Nyligen lunchade jag med ett par gamla kollegor som jag inte träffat på länge. De jobbar med ett affärssystem som har rötter i det vi utvecklade under 2003.
Den gången, 2003, gick det inget vidare. Vi byggde visserligen ett helt affärsssystem på rasande kort tid. Första kunden var också överlycklig över systemet de fick. Men så mycket längre kom vi inte. Marknaden fanns där, och en del nya kunder var på ingång, men finansieringen saknades. (Ledningen skulle också gå att säga en del om).
Nu är det ett nytt bolag sen ett par år, med utvecklarna själva som ägare. De har fått slita hårt och länge för det här, men nu verkar det finnas både finansiering och kunder. Med tiden tror jag de här killarna verkligen kommer skörda frukterna av sitt slit.
Som programmerare är resultatet av ens arbete sällan något bestående. Så då är det riktigt kul att veta att det jag gjorde då fortfarande både används och vidareutvecklas.
Posted in Programming | no comments
Posted by Anders
Sat, 20 Jan 2007 16:30:00 GMT
or: How I Learned to Stop Worrying and Love the Legacy CMS
We had decided we didn’t want to maintain our legacy CMS, so we were going to replace it with something off-the-shelf. So a lot of alternatives were examined. But we learned that the kind of deep integration we required wouldn’t be easy. In fact, it would be so complicated that we wouldn’t be able to deliver anything useful for some time. The cost of maintaining the old CMS paled in comparison to integrating (and then maintaining) a new CMS.
Sure, in the long run off-the-shelf would probably be a win, but a working solution now wins over something that maybe has benefits years from now.
So, in a surprising conclusion, the best CMS turned out to be the one we already had. Or, more correctly, the one we can get by improving what we have. I thought we would be in for a textbook example of Buy over Build, but we ended up with something else.
Posted in Java, Programming | Tags cms | no comments
Posted by Anders
Sat, 16 Dec 2006 12:49:00 GMT
I wanted to access the e-mail on my server through the standard IMAP protocol. Quoting the UW IMAP daemon documentation
:
The IMAP and POP3 servers are plug-and-play on standard UNIX
systems. There is no special configuration needed. Please ignore all
rumors to the effect that you need to create an IMAP configuration
file.
Great, no configuration! This is exactly what I need.
Wait, why are strange things like .bashrc and .bash_history showing as folders in my e-mail client? It’s not exporting my entire Unix home directory to the client, is it?
Consulting the documentation again:
Example 2: suppose you want to change c-client’s idea of the
user’s mailbox directory to be the “mail” subdirectory of the user’s
home directory instead of the user’s home directory.
Yes, please!
The documentation continues:
You will want to change variable mailsubdir, changing the line that reads:
static char *mailsubdir = NIL; /* mail subdirectory name */
to be:
static char *mailsubdir = "mail";/* mail subdirectory name */
I will want to do what?
This is a configuration option that is often (always?) unusable in its default setting. It is so common to need to change it that they prominently mention it in the documentation, and the FAQ too, but they still want me to edit the source code and re-compile to change it?
I think they found the loophole in the “no special configuration” promise.
Posted in Computers | Tags imap, unix | no comments
Posted by Anders
Thu, 14 Dec 2006 15:58:00 GMT
We’ve been looking for a small but powerful Content Management System (CMS) to replace our old in-house CMS. It turned out to be much trickier than we first thought.
Our website is a big high-traffic one, but our demands on a CMS aren’t that complicated. We just want a nice way to edit and manage some content and then put it to our existing pages.
There seems to be two major kinds of Java CMSes:
The “Enterprisey” kind
Don’t get me wrong, we’re willing to pay for a CMS, but:
- No, we dont want to send our developers to a four-day course.
- No, we don’t want to pay more than our Oracle licenses for your CMS.
- No, we don’t want to hire your consultants.
Besides, we’re not trying to manage thousands of business documents, we just want to edit our website.
The Open Source kind
Very promising at first. Magnolia, OpenCms, JBoss Portal, etc. They all look reasonably powerful and modern, even easy to install. Most support open standards like JCR.
But I don’t want to build a new web site on top their nice CMSes. I want to add CMS functionality to our existing website, built on a mix of different Java technologies, but mostly JSP. Re-implementing hundreds of pages to be able to run within some CMS isn’t an option.
If your nice JSP tags must be run within your special Servlet, I can’t use them. If your live inline editing must be run from your J2EE-application, I can’t use it. If your nice CMS requires me to change my web server, etc…
In theory all of them can probably be dismantled and integrated within our system, but in practice I’m not so sure. It sure isn’t a documented feature.
Whatever
It seems a simple JCR back-end (i.e. JackRabbit) solves 75% of our issues, by providing storage, versioning and login management. But I’d hate to have to build our own CMS glue on top of it to get the remaining 25%. Trying to get rid of in-house code is how we got here in the first place.
Why does it feel like we’re the first ones in the world who want to integrate simple CMS functions into our legacy application?
Posted in Java, Programming | Tags cms | 2 comments