ruby

prdoueddelay between statement in ruby

again i m asking this question how to produce delay in ruby puts"amit" sleep(10) puts "asda" i want delay between two statement when i tried the above example first i have a delay of 10 sec than both statement execute that ui don't want plzzzz help me ...

Regex to match 1234, 1324, 2341 (all permutations of {1,2,3,4})

I am implementing the following problem in ruby. Here's the pattern that I want : 1234, 1324, 1432, 1423, 2341 and so on i.e. the digits in the four digit number should be between [1-4] and should also be non-repetitive. to make you understand in a simple manner I take a two digit pattern and the solution should be : 12, 21 i.e. the...

OCIError on 'require'; permissions issue?

I've just recently started learning/using Ruby at work. I've got a super-simple test script that just connects to our Oracle 10g database, runs a select, and 'puts' the results to the screen. This is on a Solaris 10 server. If I run the script as the 'apps' user (the system user that runs our automated scripts), the script runs fines....

Convert C# CUSTOM getSHA512 function into Ruby

hello, I was wondering if someone could help me to get this method converted to ruby, is this possible at all? public static string getSHA512(string str){ UnicodeEncoding UE = new UnicodeEncoding(); byte[] HashValue = null; byte[] MessageBytes = UE.GetBytes(str); System.Security.Cryptography.SHA512Managed SHhash = new Sy...

vlad the deployer vlad:start_app with passenger issue

I'm trying to deploy a rails app using vlad the deployer. I'm using nginx and passenger. I have an issue with the vlad:start_app task. When I deploy I get the following issue touch: cannot touch `/var/www/mysite.com/releases/20100623130302/tmp/restart.txt': No such file or directory rake aborted! execution failed with status 1: ssh ...

How do you write and execute Ruby tests in a Ruby interpreter?

I was working with the lotrepls Ruby interpreter, and I want like to write tests in the interpreter that I can then write Ruby code to pass. In Python, I can write doctests and then write code to pass the doctests. For example: >>> b 1 This tests that b=1, and entering b=1 will get this doctest to pass. Is there a similar way to...

Authlogic Facebook Connect and SSL

User_sessions has ssl_required for new, create and destroy. If I use authlogic_facebook_connect_button from an ssl page everything works, if I use it from a non-ssl page like the front it fails with a "Unknown Action / No action responded to index" Please help... Is there a way to authlogic_facebook_connect_button to use xd_receiver_s...

Rmagick on windows segmentation fault

I have problems installing RMagick on top of Windows. I did as I should according to the instructions: Downloaded the archive: RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip from here and unzipped to a local folder. Installed ImageMagick-6.5.6-8-Q8-windows-dll.exe gem install rmagick-2.12.0-x86-mswin32.gem --local Even a reboot Then I fol...

cron tab to restart my delayed_job server.

I want to create a cront tab to restart my delayed_job server if it breaks. how may check that my delayed_job server is running or not with ps command? how may i create a cron tab to check this thing work? Like if my server break than cron tab will restart it. I want to set cront tab to check it every 5 minute. ...

PNG black background transparent images Ruby on Rails application

Hello, I am currently running a Ruby on Rails application with Imagemagick and Paperclip and have a problem with PNG transparent images. They show with a black background and I'd like to know how to do to make that background show white. I found some resources but unfortunately only in PHP. Would be great if you could share with me a so...

How should I deal with estimated dates in Ruby on Rails?

Hello, For my application I need to handle estimated dates, for example "about Jun. 1940" needs to be accepted as plus or minus 2 years around Jun 1940. Or they could type "about 1940" needs to be accepted as plus or minus 2 years around 1940. Here is the full list of possible formats. 1940 Nov.1940 Nov. 1940 6 Nov.1940 6 Nov. 1940 A...

Ruby send with no symbol

Is it possible to send nothing to an object? Let me elaborate. For instance I could have something like this: val = some_stack.include?(some_val) ? some_val : nil obj1.obj2.send(val).obj3.obj4 The above call wont't work because nil is not a symbol. So the solution is: if val.nil? obj1.obj2.obj3.obj4 else obj1.obj2.send(val).ob...

Ruby 1.8 and disk I/O in a multi-threaded setting

Ruby 1.8 uses userspace threads, not operating system threads. This means that Ruby 1.8 can only utilize a single CPU core no matter how many Ruby threads you create. On the bright side, not all is bad. Ruby 1.8 internally uses non-blocking I/O while Ruby 1.9 unlocks the global interpreter lock while doing I/O. So if one Ruby thr...

RubyRails: Mixing Sanitize and Truncate can be a dirty thing..

So stand alone I get what I need. But I want to truncate it, my dynamic text comes out with dirty text globbered with Microsoft Word garbage. An Example : ≪! [If Gte Mso 9]>≪Xml> ≪Br /> ≪O:Office Document Settings> ≪Br /> ≪O:Allow Png/> ≪Br /> ≪/O:Off... So how do I get the best of both worlds? Is there a s...

Find Similarities between Blocks of Text between Many HTML Documents?

If I have say 20 HTML pages and I want to extract out the shared/similar portions of the documents, what are some efficient ways to do that? So say for StackOverflow, comparing 10 pages I'd find that the top bar and the main menu bar are the same across each page, so I could extract them out. It seems like I'd need either a diff progra...

Ruby on Rails - Global Variable?

Hello, I am a new Ruby on Rails user and had a question. I have an idea of what I want my Users DB to look like but was wondering whether or not I should add an additional value to it. Basically I need a variable to signal to all users that it is safe to proceed with a certain action. This variable would be persistent across all users a...

Sanitize pasted text from MS-Word

Here's my wild and whacky psuedo-code. Anyone know how to make this real? Background: This dynamic content comes from a ckeditor. And a lot of folks paste Microsoft Word content in it. No worries, if I just call the attribute untouched it loads pretty. But the catch is that I want it to be just 125 characters abbreviated. When I add tr...

RAILS_ROOT with shell script.

I have created one shell script in my lib folder. And i want to use RAILS_ROOT in that script instead of the long path. Is there any way i can do this? This my script if ! [ -s delayed_job.pids ]; then RAILS_ENV=production /home/app/script/delayed_job start fi I want to modified this line with something like that. if ! [ -s d...

Can I start logging application-initiated sql queries so I can learn what it's doing?

Hey, I'm learning an ecommerce package (Spree). The problem arises after I delete a product thru the GUI. I try to manually undo the delete by changing/adding rows back in, but I fail. My question is this: is there any way I can add application or dbms code/config/software to log transactions? Preferably, this will work with sqlite3,...

foreign keys in activerecord migrations vs. schema.rb

I'm running activerecord 3.0.0beta. I know you can create columns with foreign keys like create_table "my_things" do |t| t.reference "other_thing_id" end but I forgot and just made it a plain integer. Now, I've added a migration like execute("alter table my_things add constraint fk_other_thing foreign key (other_thing_id) reference...