gems – PullMonkey Blog http://pullmonkey.com Fri, 19 Nov 2010 21:52:14 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 2D Vector Graphics in Ruby / Rails http://pullmonkey.com/2010/11/19/2d-vector-graphics-in-ruby-rails/ Fri, 19 Nov 2010 21:42:27 +0000 http://pullmonkey.com/?p=57544 I've been working with Cairo the last day or two to build a sign generator.   I chose Cairo because it seemed like a good fit for building a sign that had to be loss-less in detail and scalable, this rang vector graphics.   I found a few good examples here and there, but they were very few and the documentation was not exactly ruby-friendly.

So I'm going to do a few posts about what I learned and I am going to start with the very basics, since all I could find were completed and elaborate images, way too complicated for a beginner.

Let's start with rotating a square box by 45 degrees.  Very simple.

rotated_square

That's it, pretty simple, right?

]]>
Spreadsheet Gem – data may have been lost http://pullmonkey.com/2009/04/30/spreadsheet-gem-data-may-have-been-lost/ http://pullmonkey.com/2009/04/30/spreadsheet-gem-data-may-have-been-lost/#comments Thu, 30 Apr 2009 14:48:00 +0000 /2009/04/30/spreadsheet-gem-data-may-have-been-lost I've been using the spreadsheet gem lately for a couple projects I am working on to modify existing spreadsheets. I have quite often stumbled upon this error when opening modified spreadsheets in excel:

File error: data may have been lost

Like most microsoft errors, it was useless and the spreadsheet came up just fine. But that error was just so annoying, other spreadsheet applications (open office, excel on mac) opened without any problems. So after quite a bit of hacking and digging around, I finally tried setting the encoding, which defaults to UTF-8. Well it just so happens that the spreadsheet being modified was encoded with UTF-16LE.

So part one of my solution became this:

1
2

Spreadsheet.client_encoding = 'UTF-16LE'

Then doing a little more digging I decided that this would be a better long-term solution:

1
2
3

book = Spreadsheet.open spreadsheet_file
Spreadsheet.client_encoding = book.encoding

Well, hopefully it wasn't just me and someone will be able to save a bit of time with this.

]]>
http://pullmonkey.com/2009/04/30/spreadsheet-gem-data-may-have-been-lost/feed/ 1