I am looking for a simple and automated way to store the page cache on S3 (and of course cloudfront.) I know of a plugin that does this with the fragment cache, but before I create it myself, wanted to tap into the collective wisdom here :)
Edited: To make myself more clear, I am not looking to use S3 to serve the files, but rather, th...
I'm trying to figure out how to check if a string matches a regular expression, but I want to know if the entire string matches just once. Here's my code but it seems absurdly long
def single_match(test_me, regex)
ret_val = false
test = regex.match(test_me)
if (test.length==1 && test[0].length == test_me.length)
ret_val = tr...
Is it possible to conditionally set a dependency on a gem at install time? Here's my situation which will hopefully clarify the question.
There is a gem I maintain that depends on the json gem. However, I frequently use jruby which has a port of the json gem that's called json-jruby. To work around this I have to build two separate gems...
I have a single Rails 2.2.2 app that I want to 'share' with multiple clients. Each client has his own domain name and database. The purpose is to allow one Rails app to 'host' many websites.
I am using Apache as a front end to a mongrel cluster, as the web server. To enable Rails to know which request is for which client, Apache adds a ...
Does anyone know any good Ruby, Rails or .Net specific libraries for working with barcodes?
...
Is it possible in Ruby to get a reference to methods of an object ( I would like to know if this can be done without procs/lambdas ) , for example , consider the following code :
class X
def initialize
@map = {}
setup_map
end
private
def setup_map
# @map["a"] = get reference to a method
# @map["b"] = get refere...
Is there something similar to the Python utility virtualenv?
Basically it allows you to install Python packages into a sandboxed environment, so easy_install django doesn't go in your system-wide site-packages directory, it would go in the virtualenv-created directory.
For example:
$ virtualenv test
New python executable in test/bin/p...
Hi y'all. I've just learned the basics of Ruby after being very happy with Python for several years (I'm still using Python for some things), but I'd like to know if there's an idiom or hack to solve this particular problem.
I have a Ruby script which I'd like to be able to do require script_name with, but I'd also like to be able to ru...
What tools do you use for automated code sanity checks and adhering to the coding conventions in your Ruby apps? How do you incorporate them into your process? (I mean tools like roodi, reek, heckle, rcov, dcov, etc.)
...
In some scenario of Ruby 1.8. If i have a hash
# k is name, v is order
foo = { "Jim" => 1, "bar" => 1, "joe" => 2}
sortedByValues = foo.sort {|a, b| a[1] <==> b[1]}
#sortedByValues is an array of array not longer a hash!
sortedByValues.keys.join ','
my workaround is to make method to_hash for Array class.
class Array
def to_hash(&bl...
I'm building an app which is going to have to handle and store a large amount of email (around 2-4 thousand a day) which will need to be seen and dealt with in various ways by a lot of people worldwide. Sounds like a ticketing system, right? With one twist -- I have a separate app which handles a lot of the processing for people who wi...
I have to be specific for this to make sense. In my application I have a model called theme which contains widget color theme information. We provide a few themes, but mainly rely on the user to create their own themes. So the question is: where do I store my themes? If I store them in the theme database, then anytime I switch databas...
In shoes, how would I dock a stack to the bottom of the window?
For example I have the following snippet.
Shoe.app do
stack :height => 100 do
background red
end
stack :height => 100 do
background blue
end
end
I would like the blue stack to dock to the bottom of the window, and stay there whenever I resize the win...
I'm writing a model that handles user input from a text area. Following the advice from http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input, I'm cleaning up the input in the model before saving to database, using the before_validate callback.
The relevant parts of my model look like this:
include ActionView::Helpers...
In ruby I want to do roughly the following and have it print out "changed":
class Whatever
def changeFoo
@foo="changed"
end
end
@foo = "original"
o = Whatever.new()
o.changeFoo()
puts "it changed" if @foo == "changed"
puts "it did not change" if @foo == "original"
The problem is, of course, that inside Whatever, @foo b...
I'm hopelessly trying to write a method to manipulate an array in ruby. I'm trying to generate all in-order permutations of an array where each item is in turn replaced by an outside item. An example...
Given input:
arr = ["a", "b", "c"]
Desired output:
newArr = [ ["a", "b", "c"], ["a", "b", "*"], ["a", "*", "c"], ["a", "*", "*"],...
Basically I would just like to run a script that queries munin for certain stats periodically instead of getting alerts or checking a graph page. Some sort of ruby lib for getting perf info would be awesome.
...
How would I go about creating multiple database tables at runtime that utilize the same model given that rails wants to infer the table name from the model name? I want to be able to create a new object based on a model, then create a new table with a unique name that the object will reference. Does anyone have any examples or advice t...
In PHP you can do:
print_r($var) or vardump($var)
which prints "human-readible" information about variable.
Is there equivalent functions / helpers for those in Ruby / Rails ?
...
I'm trying to write a Ruby script that will ssh over to a server, run a given command, and fetch the output from it. Here's what I've got so far, mostly adapted from the Programming Ruby book:
require 'pty'
require 'expect'
$expect_verbose = true
PTY.spawn("ssh [email protected]") do |reader, writer, pid|
reader.expect(/[email protected]'s password:.*...