I'm trying to create a DSL in ruby, can you suggest me some good books? I looked around amazon and safari but so far couldn't find any.
Thanks in advance!
I am looking for a system to parallelise my tests in a Rubyon Rails app (using rspec, cucumber) that works using JRuby.
The systems I can find (hydra, parallel-test) look like they use forking, which is problematic in a JRuby environment.
I have seen this sample written in Ruby code, how i can simulate it in C language?
Open3.popen3(command) do |stdin, stdout, stderr|
@stop_stdin = stdin
while !stdout.eof do
output = stdout.read(1024 * 100)
list_pipes.each do |out|
out.print output
end
end
end
I manually placed a library in the library directory (/usr/local/lib/ruby/site_ruby/1.8) and when I try to require it, it says "no such file to load".
I used "$:.first" to get the library path, so why wont it work? Is there any good way to debug this?
Thanks
I am looking to host multiple rubyon rails apps and want to use lighttpd or nginx.How do I do multiple name server configuration. ?
I know how to do it in apache through webmin control panel.But trying to move away from apache here
Is it possible to read binary in ruby file and execute it directly in memory?
for example something like this:
x = IO.read('/bin/ls')
execute(x)
I tried system(x) but it doesn't work
ArgumentError: string contains null byte
Hi,
I was going over some pages from WikiVS, that I quote from:
because lambdas in Python are restricted to expressions and cannot contain statements
I would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language.
Thank you for your answers, comments and feedback!
Hello,
how would I develop an Email client in Ruby-on-rails taking Gmail as an example? I would be especially interested in the send email functions
Thanks for any pointers
Every time I try to debug my Rails app via Netbeans I get a ...
"Could not connect to web server - cannot show http://localhost:3000"
Rails - 2.3.5
Ruby - 1.8.7-p249
Anyone know how to resolve this?
Thanks
I'm not sure what to call this, so I'll give an example.
In PHP
1==2 || 2 returns 1 or true
In Ruby
1==2 || 2 returns 2 (The second statement if the first evaluates to false).
Is there any short way to implement similar thing in PHP?
In the effort to learn python and/or ruby, I was wondering how a file shredder would be implemented? I would like it to take in a file as an argument and then employ an algorithm to make that file unrecoverable. Would possibly add the support for multiple files or even whole directories later.
In ruby, how do I test that one array not only has the elements of another array, but contain them in that particular order?
correct_combination = [1, 2, 3, 4, 5]
[1, 5, 8, 2, 3, 4, 5].function_name(correct_combination) # => false
[8, 10, 1, 2, 3, 4, 5, 9].function_name(correct_combination) # => true
I tried using include, but that is used to test whether [1,2,3].include?(2) is true or not.
Any recommendation on libraries to do audio processing in Ruby. I need to do the following two tasks:
Find silences, for which I'm happy to just be able to iterate over each sample in the wave.
Cut and paste pieces of wav files to form a new wav file.
Convert wav to mp3, which I will probably leave to lame anyway.
I'm looking for the equivalent of NAudio, a C# library.
What are the best practices for reading and writing binary data in Ruby?
In the code sample below I needed to send a binary file using over HTTP (as POST data):
f = File.new("resp.der", "r") # binary file
begin
while true
out.syswrite(f.sysread(1)) # out is an output stream (type IO)
end
rescue EOFError => err
puts "Sent response."
end
While this code seems to do a good job, it probably isn't very idiomatic. How can I improve it?
I'm trying to write a ruby script which automatically downloads some files from some server ever 30-45 minutes (to prevent overload) as long as my computer is turned on. It's possible that my computer might be turned off at some point, but the download should resume (probably re-download the current file).
I already have the file list but I can't figure out how to make such a script to run autonomously.
What are some ways I can do this?
I want to unescape the following string:
'\u00020\u0002Standard\u00023\u0002Doe John\u000169\u0002\u0010\u0002Lorem\u0002\u0011\u0002Ipsum\u0002\u0014\u0002'
Javascripts unescape function works ok, however how can I unescape it in ruby?
Take in mind that unescape(previousString) is 0Standard3Doe John69LoremIpsum.
Hello,
I've a remote cgi script hosted on Apache using SSL. It takes in two input variables a and b.
I want to call call the cgi script with right input variables using ruby.
Any clues would be appreciated.
I'm looking for a much more idiomatic way to do the following little ruby script.
File.open("channels.xml").each do |line|
if line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)')
puts line.match('(mms:\/\/{1}[a-zA-Z\.\d\/\w-]+)')
end
end
Thanks in advance for any suggestions.
I found ruby class Timeout very useful for my project.
But i need to run a block of code in background and keep it under a timeout..
For example
Timeout::timeout(2) { block.call }
How to do that?
If I'm building a library in ruby, what's the best way to allow users of the library to set module-wide settings that will be available to all sub classes etc of the library?
A good example would be if I'm writing a library for posting to a webservice:
TheService::File.upload("myfile.txt") # Uploads anonymously
TheService::Settings.login("myuser","mypass") # Or any other similar way of doing this
TheService::File.upload("myfile.txt") # Uploads as 'myuser'
The idea would be that unless TheService::Settings.logout is called then all TheService operations would be conducted under myuser's account.
Any ideas?