Runt provides a Schedule class for managing collections of events, each represented by a temporal expression. The Schedule class provides an update method, cited in the release notes as "allowing clients to update existing expressions". The implementation of this method, however, simply calls a supplied block, providing the temporal expr...
Is there a ruby gem that will format dates relative to the current time? I want output like "Tomorrow at 5pm", "Thursday next week at 5:15pm", I'm not too concerned about the exact output, just as long as it's relative dates in natural language
...
I've got an app that I'm trying to get working again after wiping my system and installing Snow Leopard. I installed Ruby 1.9 from Macports (now a later version) and the dev server starts up just fine, but then dies on the first request, only telling me "Illegal instruction". I have no idea what's causing this or even how to go about deb...
I feel this should be very simple but my brain is short-circuiting on it. If I have an object representing the current user, and want to query for all users except the current user, how can I do this, taking into account that the current user can sometimes be nil?
This is what I am doing right now:
def index
@users = User.all
@user...
Hi-
I'm attempting to get my first "hello world" rails example going using the rails' getting started guide on my OSX 10.6.3 box.
When I go to execute the first rake db:create command (I'm using mysql) I get:
simon@/Users/simon/source/rails/blog/config: rake db:create (in /Users/simon/source/rails/blog) Couldn't create database for ...
I'm testing out a piece of code to ping a bunch of websites I own on a regular basis, to make sure they're up.
I'm using rails and so far I have this hideous test action that I'm using to try it out (see below).
The problem though, is that sometimes it works, and other times it won't ... sometimes it runs through the code just fine, o...
I've been trying to take apart this app which creates a search tree based on keywords, but I'm afraid its a bit too complex for me. Would anyone mind explaining it?
The format is off, so here's a pastebin (is pastie.org down?) version of it.
Any help is appreciated.
...
Hello people,
I have two models with a HABTM association, let´s say book and author.
class Book
has_and_belongs_to_many :authors
end
class Author
has_and_belongs_to_many :books
end
The author has a set of attributes (e.g. first-name,last-name,age) that can all be blank (see validation).
validates_length_of :first_name, :maximum...
I have an array:
tokens = [["hello","world"],["hello","ruby"]]
all_tokens = tokens.flatten.uniq # all_tokens=["hello","world","ruby"]
Now I need to create two arrays corresponding to all_tokens, where the first array will contain the position of each word in sub-array of tokens. I.E Output:
[[0,0],[1],[1]] # (w.r.t all_tokens)
To m...
Let's say I have these two floats:
a = 50.0
b = 1048576.0
c = a/b
By printing c, I get this:
4.76837158203125e-005
Doing the division with calc.exe gives me the result 0.0000476837158203125 . Is there any way of achieving the same thing with Ruby without installing any additional gem?
...
I need to get the exact start and end dates (month, day and year) of a given year.
E.g., 2008
Jan. 1, 2008
Mar, 30, 2008
Any thoughts on how to do this?
array = [2007, 2008, 2009, 2010]
array.each do |a|
#code to get array of date for a (year)
end
...
I have a named_scope in rails that finds episodes by there directors given name
named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} }
It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'.
P.S....
I'm developing a Rails 2.3, Ruby 1.9.1 webapplication that does quite a bunch of calculation before each request. For every request it has to calculate a graph with 300 nodes and ~1000 edges. The graph and all its nodes, edges and other objects are initialized for every request (~2000 objects) - actually they are cloned from an uncalcula...
I've a master text file and exceptions file and I want to match all the words in exception file with master file and increase counter, but the trick is with wildcards.
I'm able to do without wildcards with this:
words = %w(aaa aab acc ccc AAA)
stop = %q(/aa./)
words.each do |x|
if x.match(/aa./)
puts "yes for #{x}"
...
Hey guys I've got a couple of issues with my code.
I was wondering that I am plotting
the results very ineffectively, since
the grouping by hour takes ages
the DB is very simple it contains the tweets, created date and username. It is fed by the twitter gardenhose.
Thanks for your help !
require 'rubygems'
require 'sequel'
require...
Hi,
I am using recaptcha in my RoR application, i have my public and private keys defined in the environment.rb. Whenever i try to validate the recaptcha value using
verify_recaptcha it always returns false
i went inside the code of verify_recaptcha and found out that i always get following error
"input error : error parsing input c...
Is there a way to change the minimum length for passwords with restful_authentication? Currently it's 6 characters and I need another value.
I've tried calling validates_length_of before and after Authentication::ByPassword like this
validates_length_of :password, :within => 4..40, :if => :password_required?
include Authentication::B...
Hello, i have some problem with creating a function to my Rails app.
I want it to work like this:
str = "string here"
if str.within_range?(3..30)
puts "It's withing the range!"
end
To do that i added this into my application helper:
def within_range?(range)
if self.is_a?(String)
(range).include?(self.size)
elsif self.is_a?(In...
Has anybody succeeded in sending standalone attachments using the standalone attachment API (if possible gziped) to couchDB from ruby?
I know there are a few CURL examples, but my tries with Typhoeus haven't been successful so far. It usually just stops and waits for > 1 minute after the first few documents.
CouchRest doesn't seem to sup...
Python has the idea of metaclasses that, if I understand correctly, allow you to modify an object of a class at the moment of construction. You are not modifying the class, but instead the object that is to be created then initialized.
Python (at least as of 3.0 I believe) also has the idea of class decorators. Again if I understand cor...