I'm trying to test the aws-s3 gem for ruby, but I'm getting a weird reply:
I connect, and can see I am connected, then I run: AWS::S3::Service.buckets and get the [] reply as expected, then I create a bucket AWS::S3::Bucket.create('some-name') and get true as a reply, then I run AWS::S3::Service.buckets but still get the empty array as ...
i have 4 arrays.
["one", "two", "three"]
["1", "2", "3"
["un", "deux", "trois"]
["ichi", "ni", "san"]
is it possible to concatenate each element in their respective arrays ?
so i end up with single lines of string like like
"one, 1, un, ichi"\n
"two,2, deux,ni"\n
and so on...
is it possible to do this in one loop ?
for i in (1....
given:
module A
class B
end
end
b = A::B.new
we want to be able to get the module nesting as an array. This can be done if the class is known in advance. eg:
module A
class B
def get_nesting
Module.nesting # => [A::B, A]
end
end
end
But, how to do it for an arbitrary object, so that we could do something lik...
I'm trying to download account transactions (an XML file) from a server. When I enter this URL from a browser:
https://secure.somesite.com:443/my/account/download_transactions.php?type=xml
it successfully downloads a correct XML file (assuming I've already logged in).
I want to do this programmatically with Ruby, and tried this code:...
I tested the performance of GServer by implementing the most basic server and checked how many requests per second it could handle. The result was 81. This is very slow compared to the 9900 requests per second that my most basic TCPSocket server can handle. Am I doing something wrong or is GServer really this slow?
Client
require 'socke...
I'm all new to the open source free software thing, but any way I'm going into it pretty well (I guess!!).
Now the thing is: in the way to distribute my program, I'll have to distribute my source code, so it will be a (.gz) with an installer for sure, or maybe a (.deb).
My questions are:
(I know this is a silly one, but I'm new here)...
Hi there
I'm trying to script Dice's Coefficient, but I'm having a bit of a problem with the array intersection.
def bigram(string)
string.downcase!
bgarray=[]
bgstring="%"+string+"#"
bgslength = bgstring.length
0.upto(bgslength-2) do |i|
bgarray << bgstring[i,2]
end
return bgarray
end
def approx_string_match(test...
Can anyone suggest a CMS able to offer the following features:
Free/open source
Support for multiple languages (both frontend and backend)
Support for translating content (i.e. an article can have 1+ translations)
Support for different content types, namely pages, articles (timestamped, with comments) and image (galleries).
Support for...
In the Sinatra ruby framework, I have a route like this:
get '/portfolio/:item' do
haml params[:item].to_sym
end
This works great if the template that exists (e.g., if I hit /portfolio/website, and I have a template called /views/website.haml), but if I try a URL that doesn't have a template, like example.com/portfolio/notemplate, I...
When submitting a form to create a new object i get an error message when submitting the form. When i use the same form but then with an instance variable everything seems to go fine, any clue why the submit with the :symbol fails?
The error message says: Only get, put, and delete requests are allowed.
The code for the new form with :s...
I am trying to decode some HTML entities ('<' => '<').
I have found an old gem (http://github.com/tma/html_helpers/) but it seems to have been abandoned twice.
Any recommendations? (will need to use it in a model)
...
The data is a UTF-8 string:
data = 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
I have tried File.open("data.bz2", "wb").write(data.unpack('a*')) with all kinds of variations for unpack put have had no success. I just get the string in the file not the UTF-8 encoded binary data in the stri...
I want to stub just a specific model, but not only a specific object and not every instance
E.g. Given class 'Person' with attributes 'name' (string) and 'cool' (boolean). We have two models:
person_bill:
name: bill
cool: false
person_steve:
name: steve
cool: false
Now I want to stub just steve, which works alright:
p1...
Is it possible for a lambda, proc, method or other type of block in ruby, to yield to another block?
something like...
a = lambda {
puts 'in a'
yield if block_given?
}
a.call { puts "in a's block" }
this doesn't work... it just produces
in a
=> nil
I'm wondering if there is a way to get the block to call a block, though...
...
I've isolated a problem with Ruby on Rails where a model with a serialized column is not properly loading data that has been saved to it.
What goes in is a Hash, and what comes out is a YAML string that can't be parsed due to formatting issues. I'd expect that a serializer can properly store and retrieve anything you give it, so somethi...
What I want is to do something like this in my views:
<% page_header "Your Posts" do %>
<div class="add">
<%= link_to 'Add a new post', new_posts_path %>
</div>
<% end %>
And have the HTML render something like this:
<div class="page_header">
<h2>Your Posts</h2>
<div class="add">
<a href="/posts/new">Add a new p...
I'm getting a strange nil problem with the following code.
The view (part of it):
<p>
<%= label :maintenance, :name %>
<%= text_field(:maintenance, :name, :size => 20) %>
</p>
<p>
<%= label :maintenance, :type %>
<%= select :maintenance, :type, @m_types %>
</p>
If I remove the text_field or move it below the select, I get a ...
I currently use the following code to sanitize a string before storing them:
ERB::Util::h(string)
My problem occurs when the string has been sanitized already like this:
string = "Watching baseball & football"
The sanitized string will look like:
sanitized_string = "Watching baseball &amp; football"
Can I sanitize by just t...
I am using a homegrown captcha system. This uses Rmagick and Rmagick comes with ImageList. Existing code is like this.
im = ImageList.new("#{@@captcha_image_path}/#{captcha.pos}.JPG")
@imgdata = im.to_blob
send_data(@imgdata, :filename => 'captcha.jpg',
:type => 'image/jpeg',
:d...
When I do the following:
`sshfs [email protected] /tmp/dir1/`
in a irb console, the console freezes.
If I use something like system("sshfs [email protected] /tmp/dir1/") it works, but I need to use backticks because the system call is in a method used many times, and some of them need the return from the shell.
Any tip?
...