Running Linux system commands from Ruby script
I have the following Ruby script that creates a Debian package, which works fine: #!/usr/bin/ruby dest = "#{File.dirname(__FILE__)}/../build" package = "foo" [ "cd #{dest} &" part of each command? ...
I have the following Ruby script that creates a Debian package, which works fine: #!/usr/bin/ruby dest = "#{File.dirname(__FILE__)}/../build" package = "foo" [ "cd #{dest} &" part of each command? ...
My setup: thin running on port 1234 with --prefix /foobar apache running on port 80 apache reverse proxies /foobar to thin on port 1234 I would like the static assets to not be served via the proxy to thin, but instead be served at /assets directly via apache instead. I have to use a relative path because I don't know the host name/...
In ruby, begin # ... rescue # ... end won't catch exceptions that aren't subclasses of StandardError. In C, rb_rescue(x, Qnil, y, Qnil); VALUE x(void) { /* ... */ return Qnil; } VALUE y(void) { /* ... */ return Qnil; } will do the same thing. How can I rescue Exception => e from a ruby C extension (instead of just rescue => e)...
I often hear the term 'middleware' in the context of Ruby on Rails. What exactly is it? Can you provide specific examples? ...
I have a string I want to split: D017209D019169D019014 into D017209, D019169, and D019014 with commas in between. If I have a = D017209D019169D019014 b = a.slice("D") puts b My result looks like: 017209 019169 019014 What am I missing? ...
This is so simple that I am stunned it is failing. I am testing a very simply login sequence and essentially my code does this: require "watir" user = "[email protected]" pswd = "qwerty" br = Watir::Browser.new br.goto("http://mysite.com") br.link(:id,"login-menu").click # click the login menu br.text_field(:id,"l...
I would like to write a Rails app that is able to capture a webpage like the Evernote clipper does. If you are not familiar, in your browser, you can click a button on the toolbar and it captures a pretty accurate copy of the webpage layout. For an example, go to http://www.evernote.com/pub/jssmith072/shared and click on the single note ...
Is there a list of language codes in YAML or JSON somewhere out there? Another format is fine, I can convert it if necessary. ...
I'm working with what should be a fairly basic iteration. I understand that I could accomplish it with Ruby code, but I am working already in a C extension, so I would prefer to keep this function in C with the rest of the code- especially since this should work (one way or another) without issue. The issue is with rb_block_call. Here ...
Most material on the net deals with spawning a separate instance of Internet Explorer with WIN32OLE. Thats all well however I'd really like to be able to control, or rather monitor an existing Internet Explorer instance. I don't need to control it directly, just check its state, i.e has the page finished loading?. Is this possible with w...
mainly I just need to know what the commands are to get month, day and year, first day of month and last day of month. I should be able to figure it out from there. I've built a nice one in PHP but I would rather use ruby since using a database is so much easier in ruby. So if you can point me in the right direction. ...
I'll try to be concise this time around! I'm still working Project Euler, this time back to #2. My real issue here is I'm terrible with Ruby. When I run the following code x = 1 y = 2 sum = 2 while x >= 4_000_000 do |x| sum += y if y % 2 == 0 z = x + y x = x ^ y # xor magic y = x ^ y # xor magic x = x ^ y # xor magic...
filename = "#{k}""/kabab" extension = ".txt" for i in 1..10 $stdout=File.open("#{filename}#{co}#{extension}" ,'w') puts "sachin" end puts "amit" whats my problem is in last file means kabab10.txt i geeting the output like sachin and amit but i don't want amit to be come in 10th file how to solve it` ...
Is there any data regarding how browsers actually support rest http verbs (especially PUT, DELETE). This question is mostly motivated by the fact that many sources (such as this stackoverflow answer) inform that most browsers don't suport PUT and DELETE but don't say which. Rails solves this using a patch on the client, and reversing th...
I wrote a ruby file which can be used as a library. But in order to test it, I also write some test data. For example: class Checker do some thing end # if this file is used as a library, I don't want following code executed checker = Checker.new checker.dosomething I know there is a way to determine if the file is used as li...
require 'fileutils.rb' k=FileUtils.mkdir_p "d:/pptomasdsdr1xks_6b27" filename = "#{k}""/kddabab" extension = ".txt" co=1 $stdout=File.open("#{filename}#{co}#{extension}" ,'w') puts "sachin" $stdout.close puts "amit" im getting error like stdout.rb:14:in write': closed stream (IOError) from stdout.rb:14:inputs' i d...
Hello guys ! I am coding a little app in order to learn ruby and web development in general. The app is a little blog and the web server is mongrel. I have set up a simple MVC structure on top of mongrel, with a front controller and a url dispatcher. When I go to the url http://myapp/article/show/hello for the first time, the content of ...
I am trying to get a decent navigation between my methods in TextMate. I would love to have a list of them in a drawer, but I guess there is no such solution yet, right? Therefore I am trying to set up RubyAMP to work with Ruby 1.9.1-p378 installed via RVM, but have some troubles. RubyAMP needs ruby-debug, and here is what I get if I try...
Greetings, I want to store some data in a redis db and don't know which way I should go. The data is equivalent to something like an address with the variables name, street and number. They will be stored under the lower cased name as key, there won't be doublets. Now, should I save it as a list or should I serialize the hash ({:name =...
If I have an array a: a[a.length] returns nil. Good. a[a.length, x] returns []. Good. a[a.length+x, y] returns nil. Inconsistent with 2. While this behavior is documented, it seems odd. Can anybody explain the reasons behind this design? ...