ruby

Printing to IP receipt printer from ruby

Want to send text to a network receipt printer using ruby. I know the IP address of the printer. The printer is accessible through the network, but it is not directly connected to the computer. I'm using a Star TSP100LAN, but I'm sure it would be using the same protocol as other receipt printers. ...

Rails, Finding objects in complex hashes

I'm building an app that integrates with Highrise, and so-far-so-good, however, when trying to import a person Highrise::People it spits out a huge hash similar to this: [ ..., #<Highrise::Person:0x1035084b8 @attributes={"contact_data"=>#<Highrise::Person::ContactData:0x1034f8b30 @attributes={"email_addresses"=>[], "addresses"=>[], "we...

It's a good idea use ruby for socket programming?

My language of choice is Ruby, but I know because of twitter that Ruby can't handle a lot of requests. It is a good idea using it for socket development? or Should I use a functional language like erlang or haskell or scala like twitter developers did? ...

Passenger and Rails on Scalr.net

I'm having an issue with Passenger and Rails working together on my Scalr application server. I have Rails 2.3.5 installed and Passenger 2.2.7. I am running ruby 1.8.6 (patchlevel 111). Previous version of both Rails and Passenger worked fine together but now I get shown just a file tree and no application after updating: http://matchm...

How do I make Rails pick up gems from local source directories?

I'm creating a few gems by extracting out parts of a Rails project that can be reused (and that I have duplicated in other Rails projects). The problem I have is that testing every change to the gems is now very slow. Changing a Rails project is very fast as most of the time the change is re-loaded automatically, but changing a gem impl...

How do you overload the << operator in Ruby?

I'm not sure how to accomplish overloading the << operator for a method. This is how I assumed it would work: def roles<<(roles) ... end That however, throws errors. Any suggestions? ...

Scriptaculous drop down menu not working in views/show

My knowledge of Ruby on Rails and javascript is rudimentary so please forgive me if this question has a simple answer. I have a website that needs a multi level dropdown menu. I have adapted scriptalculous drop down menu which is working on a test copy of my website using mongrel. There are several pages each with its own layout. When I ...

Ruby without Rails

I've already developed some simple applications in Rails(just to test) without any knowleadge of Ruby, but now I want to change my life, I'm going to start learning Ruby(and never learn Rails for some personal reasons) and focus only on it, but before doing this I need tp know some things: How can I build GUI applications with it? It'...

undefined method `reduce'

So in my local app, everything is fine. Both are running Ruby 1.8.7, and Rails 2.3.5, however my deployed app gets the following error. ActionView::TemplateError (undefined method `reduce' for #<Class:0x7fbbd034d760>) The only difference that I can think of is the OS, I'm working on OS X and deploying to Linux. That can't really be ...

creating a controller in Rails

I'm trying to use the generate script to create a controller. I run the following command: > ruby script/generate controller Greeting and the controller seems to be generated no problem. Then I add a method called index to the GreetingController: class GreetingController < ApplicationController def index render :text => "<h1>We...

New iMac - New Rails Environment - Dropbox - Permission Problem...

Ok, I just bought the new 27 inch iMac and I am trying get everything set up. I am new to rails and have been developing on my MacBook Pro and seem to be having some trouble sharing my applications. I use dropbox which allowed me to easily access the new files from my new iMac and therefore my rails applications but after installing rail...

Add image to layout in ruby on rails

I would like to add an image in my template for my ruby on rails project where i currenly have the code <img src="../../../public/images/rss.jpg" alt="rss feed" /> in a the layout stores.html.erb file however this doesn't seem to load as it looks like its missing a route which i'm not sure what its supposed to be. Any ideas please? ...

Fastest/One-liner way to print XML node's XPath in Ruby?

What's the fastest/one-liner way to print the current nodes xpath, or just "path/to/node", in Ruby with Nokogiri? So this: <nodeA> <nodeB> <nodeC/> </nodeB> </nodeA> to this (say we've gone down to nodeC by processing xml.children.each, etc...): "nodeA/nodeB/nodeC" ...

Mimic Tabs in Textile and HTML (in Ruby)?

How do you mimic tabs in HTML? Specifically, I would like to be able to use tabs to align things in a textile document, and convert those to "non-breaking spaces" and whatnot in HTML, using RedCloth in Ruby. Is this possible? Is there an alternative working method? ...

Running fork(2) from Windows with Cygwin. Possible?

Hi, I am trying to use a Ruby gem called shotgun that requires fork(2) command which I discovered is aa Linux command, and might be available in Cygwin. Is it possible to make it available through Windows command shell? ...

How do you remove the documentation installed by gem install?

I know it's possible to install a gem without the documentation, but unfortunately, I didn't for the first three months I used ruby. In that time, I managed to install a significant amount of gems, but not once since I started using ruby have I used the documentation on my computer. I always look to docs on the internet. What is the bes...

DataMapper has n through Resource DELETE (Remove from association) not working

Hi, I'm have this two classes class User include DataMapper::Resource property :id, Serial property :name, String has n :posts, :through => Resource end class Post include DataMapper::Resource property :id, Serial property :title, String property :body, Text has n :users, :through => Resource end So onc...

Help with multidimensional arrays in Ruby

I have this code to split a string into groups of 3 bytes: str="hello" ix=0, iy=0 bytes=[] tby=[] str.each_byte do |c| if iy==3 iy=0 bytes[ix]=[] tby.each_index do |i| bytes[ix][i]=tby[i] end ix+=1 end tby[iy]=c iy+=1 end puts bytes I've based it on this example: http://www.ruby-forum.co...

SimpleDB vs Tokyo Cabinet

Has anybody compared SimpleDB and Tokyo Cabinet for performance and scalability? I'm coding my project against SimpleDB at the moment and considering benchmarking TC, be nice if somebody had already done it and could tell me whether it's worth testing my specific storage and searching operations. If not I'll run some direct comparisons a...

Guess name from email

Is there a standard or simple way to guess a name from an email address, similar to what gmail does? For example, "[email protected]" should give "John Smith". Doing this shouldn't be too hard (strip domain name, remove special characters, capitalize, etc), but I'm sure there should be existing code for this. Code in Ruby would b...