ruby

RMagick installation failed in Ubuntu 9.04

I already installed the following: imagemagick libmagickwand-dev but still i get this error. ====================================================================== Mon 05Oct09 19:36:06 This installation of RMagick 2.12.0 is configured for Ruby 1.8.7 (i486-linux) and ImageMagick 6.4.5 Q16 ============================================...

What tool can I use to convert a 8bpp image to a 4bpp format?

I have a script that runs recursively over many directories, and I'd like to convert all the 8bpp images to 4bpp ones. Is there something already written that can perform this sort of thing? I'd like to avoid to write the conversion in Ruby. Maybe something written in C could offer some performance boost? Any ideas? ...

Ruby: how to match a double quote in a regexp

I am trying to remove some double quotes (") characters from a text file using a Ruby one liner, with little success. I have tried the following, and some variations, without success. ruby -pe 'gsub(/\"/,"")' < myfile.txt This gives me the following error: -e:1: Invalid argument - < (Errno::EINVAL) I am running Ruby on a Win machi...

Wanted: DB for fast read operations to be accessed from ruby apps

Basically it's a financial database, with both daily and intraday data (date,symbol,open,high,low,close,vol,openinterest) -- very simple structure. Updates are just once a day. A typical query would be: date and close price of MSFT for all dates in DB. I was thinking that there's got to be something out there that's been optimized for...

How to define {min,max} matches in treetop peg

With Ruby's regular expressions I could write /[0-9]{3,}/ I can't figure out how to write this in treetop other than: rule at_least_three_digit_number [0-9] [0-9] [0-9]+ end Is there a 'match [at least|most] n' rule for treetop? ...

What's another way of writing this block without using do-end?

How would you write this on the same line or on consecutive lines without do-end? map.resources :magazines do |magazine| magazine.resources :ads end ...

Java to Ruby (Base64/SHA1) public digest generation

Give a public key, I want to generate a public digest. Below is the code in JSP, but I need this in Ruby. I'm uncertain of the equivalents of SecretKeySpec, doFinal, etc. I'm using hmac, and hmac-sha1 on the Ruby end of things. String pub = 'my_public_key'; BASE64Encoder encoder = new BASE64Encoder(); Mac sha1Mac = Mac.getInstance("Hmac...

how to delete from the last character at the end of a string, to a slash in the middle of a string?

assuming, string1 = "/var/usr/local/noob/" i need to start from the last character to the closest "/" preceiding it. so i am expecting: remove_last_block_of_string() i should get "/var/usr/local/noob" if i run remove_last_block_of_string() again, "/var/usr/local" running it again, "/var/usr" ...

Are there ruby equivalents to car, cdr, and cons?

Are there ruby equivalents to the lisp car, cdr, and cons functions? For those unfamiliar with lisp, here's what I want from ruby: [1,2,3].car => 1 [1,2,3].cdr => [2,3] [2,3].cons(1) => [1,2,3] (in lisp): (car '(1 2 3)) => 1 (cdr '(1 2 3)) => (2 3) (cons 1 '(2 3)) => (1 2 3) ...

What are some large, model-rich open source applications?

I need to identify a large model-rich open source ruby, c-sharp, objective-j or java applications so that I can target them for a series of projects. Are you guys aware of any that I could use? ...

Howto get include directories (ruby.h) for Linux Ruby C extension project?

I'm using scons to build a linux C based ruby extension. What is the "right" way to get the include paths right? By "right" I mean it works out of the box on 1.9 and 1.8. I don't want to use the mkmf/Makefile solution. Thanks! Dave ...

guid generator in ruby

How do I generate a globally unique ID in ruby (without rails/merb)? ...

Rails' ActiveRecord serialize :attr method gives "Missing Class or module error"

Hi there, I'm trying to serialize a simple attribute in an ActiveRecord model, and Rails 2.3.4 doesn't like it. class Shopper serialize :tags end >> a = Shopper.new => <#Shopper...> >>a.tags = ['aoeu','stnh'] => ['aoeu','snth'] >> a.save => TypeError: class or module required anyone know what I'm missing? ...

How do I define ActiveRecord relationships between two models that relate to each other in two different ways?

In my app I have the classes User, Video, and Vote. Users and Videos can relate to each other in two different ways: as a one-to-many or as a many-to-many. The former is when a User submits a Video (one user can submit many videos). The latter is when a user votes on a video (users have many videos through votes, and vice versa). H...

Naming Boolean columns in Rails

Let's say I have a Dog and I want to store if it is trained in Rails. Conventionally, Ruby methods that return booleans have names that end with ?. Should I call the database column trained?, or should I call the database column trained and have a method class Dog def trained? trained end end The latter option seems inefficien...

Is an applet a proper solution for hardware detection and driver install?

Can I use applets to inform me which hardware is installed on client system (fingerprint reader)? And if it is installed, can it tell me its version, so that it can download the proper plugin from a site? So that after everything is OK, the user can use his fingerprint reader to authenticate himself? ...

Is it possible to create XML files using Hpricot?

I know I can parse XML using Hpricot, but is it also possible to create files? All the tutorials I found only demonstrate parsing. ...

Rails RestClient MultiPart Post

I have a spooling app that sits between a Ruby on Rails app, and a few Pandastream instances. Prior to the creation of the spooling application, the Rails app posted it's file data straight to Panda without issue. I've got the spooler receiving the file information and connection to the appropriate instance to pass the file data on, bu...

libxml-ruby and multiple namespaces

having this xml declaration: <didl:DIDL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:didl="urn:mpeg:mpeg21:2002:02-DIDL-NS" xsi:schemaLocation="urn:mpeg:mpeg21:2002:02-DIDL-NS http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didmodel.xsd"&gt; what is the way to defin...

Shell execute from Ruby

Assume, I have a file 'text_file.txt' within my .rb script. How do I execute a default windows program for that file from the Ruby? ...