I'm designing the back-end for an iphone application. I'd like to use Core Data. Is there an ideal transfer format for iphone apps? I'm leaning towards JSON unless there's some custom binary thing. I'm probably using ruby on the backend.
For example, in the Flex/Flash world, you can install a small piece on your server that lets you se...
What's the best way to sort an Enumerable in descending order?
I've been doing @array.sort.reverse or @array.sort_by{|song| song.title }.reverse
I suppose I could do something like @array.sort{|a, b| b.title <=> a.title}, but I find this hard to read and verbose.
...
I found that this issue had been discussed in Ticket #58 of DataMapper, apparently way back in 2007, but I can't find how to do it in the latest version (dm-core-0.10.2). I want to define two composite indexes, each of which are partially based on a certain property. I was hoping I could do this...
class Stat
include DataMapper::Resou...
I'm storing linked lists of data in records that look like this:
CREATE TABLE IF NOT EXISTS `data_nodes` (
`record_id` int(11) NOT NULL,
`prev_node` int(11) NOT NULL,
`data` varchar(200) NOT NULL,
PRIMARY KEY (`record_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
where prev_node is the record_id of the previous item in the list,...
I use HTTParty to consume a foreign API, but how can I convert the response into a Ruby class or Rails model?
...
I have an application class
class MyApplication < Sinatra::Base
# ... do something ...
end
and a config.ru file
# ... load libraries ...
run MyApplication
I usually use Passenger as my development environment which works perfectly fine for a normal – non-modular – Sinatra application. But in this case I have no error output inste...
In my sphinx config file, I have the following:
ignore_chars: "U+0027"
charset_table: "0..9, a..z, _, A..Z->a..z, U+00C0->a, U+00C1->a,
U+00C2->a, U+00C3->a, U+00C4->a, U+00C5->a, U+00C7->c, U+00C8->e,
U+00C9->e, U+00CA->e, U+00CB->e, U+00CC->i, U+00CD->i, U+00CE->i [SNIP]"
(The charset_table entry is from here: http://speeple.com...
I'm maintaining a Rails app that has content in the public/ folder that will now need to be protected by a login. We're considering moving those folders of files into a path outside of public/ and writing a Rails controller to serve up the content.
Before we begin writing this, I was curious if anyone else has ran into this sort of pro...
Hi all,
I can't seem to be get Ruby installed on my Mac. These are the steps I've taken so far:
Downloaded the package from Ruby's site (http://www.ruby-lang.org/en/downloads/)
Unpacked it running { tar xzvf ruby-1.9.1-p376.tar.gz }
Went into the new ruby folder, and configured using {./configure}
This is where the error happens. ...
Suppose I have
an_array = [[2, 3], [1, 4], [1, 3], [2, 1], [1, 2]]
I want to sort this array by the first value of each inner array, and then by the second (so the sorted array should look like this: [[1, 2], [1, 3], [1, 4], [2, 1], [2, 3]])
What's the most readable way to do this?
...
I'm working on a piece of logic that I would like to express on the server as well as in the browser. Something like validating a form where there must be certain logical relationships between the elements based on what has already been entered.
So... If I can write the logic once and somehow end up with both Ruby and with Javascript, I...
any idea how I can pass correct argument to xpath? There must be something about how to use single/double quotes. When I use variable
parser_xpath_identificator = "'//table/tbody[@id=\"threadbits_forum_251\"]/tr'" gives me an incorrect value or
parser_xpath_identificator = "'//table/tbody[@id="threadbits_forum_251"]/tr'" gives me an ...
I used hash of hashes to store settings in my code. I wonder if I can have something like class variable that is the same for all instances of the class for my @profile hash. So both profiles below would have general profile variable equal to both of them. I want the solution to use hash.
@profile = {
"vB4Discussions" => { #profile...
Hi
I am learning Ruby and I have written the following code to find out how to consume SOAP services:
require 'soap/wsdlDriver'
wsdl="http://www.abundanttech.com/webservices/deadoralive/deadoralive.wsdl"
service=SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
weather=service.getTodaysBirthdays('1/26/2010')
The response that I get...
As title, warden is very pluggable, I wonder if there is anything works with warden/devise?
...
I just started using bundler for gem packaging in vendor/. The problem is with certain gems (like rspec and cucumber) that have binaries. The binary path that is under my_app/vendor/gems/ruby/1.8/...cucumber-0.6.2/bin/ is not in my path, therefore when I go to run cucumber i get command cannot be found.
What is the easiest way to execu...
Hello there,
I'm trying to make an API for dynamic reloading processes; right now I'm at the point where I want to provide in all contexts a method called reload!, however, I'm implementing this method on an object that has some state (so it can't be on Kernel).
Suppose we have something like
WorkerForker.run_in_worker do
# some cod...
I can't figure this out:
22.584\r\n\t\t\tl-6.579-22
I want to match the "\r\n\t\t\t" and replace with a single space " ". Problem is the number of "\t", "\r", and "\n" fluctuates, as do the surrounding characters.
Help!
...
I would like to know how to write unit tests for a module that is mixed into a couple of classes but don't quite know how to go about it:
Do I test the instance methods by writing tests in one of the test files for a class that includes them (doesn't seem right) or can you somehow keep the tests for the included methods in a separate f...
I have bunch of Rails apps running on Rails 1.x. I need to upgrade the gems so the question is, will these old apps still work after I upgrade gems?
Thank you.
...