I need to encrypt a integer, but all the crypto libraries only support strings.
What is the proper method to convert a integer to a binary string in Ruby? (not '10111', I think that it's ASCII values)
EDIT: I wasn't thinking about Rijndael as stream encryption.
...
Is there a document for Ruby that describes some preferred conventions for whitespace, indentation and other style issues?
I found Python's PEP 8 to be very helpful and am looking for something similar for Ruby.
...
Is it possible to install a RubyGem that I created in NetBeans, through NetBeans without uploading it to RubyForge?
...
I followed the instructions found on the github page exactly. I would post some of my configuration but it matches what's found here on http://github.com/nkallen/cache-money/tree/master
The error reads as follows:
/!\ FAILSAFE /!\ Thu Mar 05 16:45:09 -0500 2009
Status: 500 Internal Server Error
undefined method `indices' for nil:...
Any work going on to get other ruby threads working with Shoes?
...
I have an Array of Events and I want to divide them into a 2-dimensional Array based on event_date (which returns a Time object). But I want it to be by the day part of the date. Here's what I have so far:
def divide_events_by_day(events)
# Sort, so we can start with the first day.
events = events.sort { |x,y| x.event_date <=> y.eve...
Looking around on the Web I found that the Ruby Time class has Time#advance. Where is this documented? I saw no mention of it in the Ruby API docs here.
The search function for the API docs indicated that there is no method called "advance" anywhere.
Nonetheless, in IRB...
>> t = Time.now
=> Thu Mar 05 16:08:57 -0800 2009
>> t.advance...
Ruby 1.8.6, Rails 2.2.2, OS X Tiger
My Test::Unit tests started returning the error below. The relevant line seems to be:
`load_missing_constant':
Expected /Users/ethan/project/mtc/webcalendars/app/models/calendar.rb
to define Calendar (LoadError)
The file mentioned, calendar.rb looks fine. I can't find any errors in it. I trie...
This is to enable the development of postgres functions with embedded ruby code,
but I have been unable to build it.
As advised by
http://www.robbyonrails.com/articles/2005/08/22/installing-untrusted-pl-ruby-for-postgresql
I am trying to build the needed plruby.so from the latest version (plruby-0.5.3.tar.gz) provided at ftp://moulon...
def plural(value, string)
"#{value} #{value.abs == 1 ? string.singularize : string.pluralize}"
end
If not, what would be a short, sweet name for this method?
...
Rails has a nice function, ordinalize, which converts an integer to a friendly string representation. Namely 1 becomes 1st, 2 becomes 2nd, and so on. My question is how might one implement the inverse feature?
To be more general I'd like to handle both of the following cases:
>> s = "First"
>> s.integerize
=> 1
>> s = 1st
>> s.integeri...
Should I use LAMP, .Net, or any other platform? I have access to resources with LAMP, .Net, ROR and Java experience. Thanks.
Sorry for being vague. Could you give me a few pluses and minuses of each like Paul? Thanks for your time and effort.
...
I know I'm doing something stupid or failing to do something intelligent - I'm frequently guilty of both.
Here's an example of what's causing me pain:
I have a module saved in /lib as test_functions.rb that looks like this
module TestFunctions
def abc
puts 123
end
end
Going into ruby script/runner, I can see that the module ...
Why does this line output "z" instead of "?"
$ ruby -e 'puts %x[ echo #{"?"} ]'
Suppose the expression inside the #{...} is a variable that may have the value of "?". How should I modify this script so that the question mark is outputted instead of "z"?
(Please forgive the title of this question -- I don't yet understand what is going...
I have a has_many association like this:
has_many :respostas_matriz_alternativas, :class_name => 'RespostaMatrizAlternativa',
:order => 'respostas_matriz.codigo asc',
:include => :resposta_matriz
Well the fragment that matters is the "order". Codigo is a varchar column wich will contain in most cases numeric value...
I'm working with an application built in Ruby on Rails with very poor error handling right now. If a controller method is executed via ajax, and that method results in a 500 (or 404 or any other response) the 500.html page is rendered and returned as the result to the AJAX request. Obviously the javascript doesn't know what to do with th...
Hi,
In my rails application, I have a file in lib that, among other things, sets up a filter that runs on all controllers.
When running under development environment, everything runs fine. However, under production the filter goes missing. Funny thing is, by inspecting the filter_chain, I noticed other filters remain, eg. those define...
Is there a way to get ruby to do a forced copy? FileUtils.cp_r seems not to have a :force => true option.
...
Hey all,
I'm currently trying to code a custom image cropping system similar to other ones on the internet where a user can select a cropping area and then have their image cropped accordingly. The application is in Rails and we're using Paperclip with Amazon S3 to store the files. I'm having a lot of trouble though getting RMagick to ...
I have a class defined in a file my Rails project's lib dir that will implement a bunch of utility functions as class methods. I'd like to write tests against those methods using Test::Unit and have them run as part of the project's regular testing routine.
I tried sticking a file at the top level of the test dir...
require 'test_helpe...