Equivalent of Scheme's dynamic-wind in Ruby
Ruby has continuations... does it have a dynamic-wind construct like Scheme? ...
Ruby has continuations... does it have a dynamic-wind construct like Scheme? ...
Hi there! I'm writing a tiny Sinatra app, and I want to host it on Heroku for simplicity sake. But, what I have is a task that scraps some sites and adds some data into my database every hour. Currently this is just written as a ruby script that needs to be executed. What Heroku has is a rake based cron job. Now if this was a rails ...
I have a rails app that needs to start a supporting Sinatra web service. I would like to invoke it via a rake task. But I want the Sinatra app to start inside a new terminal (command) window. Yes, I need to see it executing. # rake task namespace :daq_controller do desc "start the DAQ contoller web service" task :start do dir =...
What's the idiom in Ruby when you want to have a default argument to a function, but one that is dependent on another parameter / another variable? For example, in Python, an example is: def insort_right(a, x, lo=0, hi=None): if hi is None: hi = len(a) while lo < hi: mid = (lo+hi)//2 if x < a[mid]: hi = m...
Hello, I have a problem where I am trying to search for a substring in string. That sub string may or may not be in the string. str = "hello how are you?" substr = "how are" Two ways which I know if can be done are: 1. string.indexOf("how are") 2. regex But, is there any other "optimized" way? What would have you done? Can ruby pr...
I'm trying to use zookeeper gem and example code from README fails: require 'rubygems' require 'zookeeper' z = Zookeeper.new("localhost:2181") z.get_children(:path => "/") causes error: ./zookeeper.rb:3: uninitialized constant Zookeeper (NameError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from...
When using RVM with ruby 1.8.7 I am unable to run the debugger. I am using rails 2.3.9 and mongrel script/server --debugger returns: You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug' this is what my gem list looks like: ruby-debug (0.10.3) ruby-debug-base (0.10.3) ...
This Twilio API Sample code isn't working in Rails 3: #voice_controller.rb def reminder @postto = BASE_URL + '/directions' respond_to do |format| format.xml { @postto } end end #reminder.xml.builder xml.instruct! xml.Response do xml.Gather(:action => @postto, :numDigits => 1) do xml.Say "Hello this is a cal...
I would like to know how to parse a YAML file with the following contents: --- javascripts: - fo_global: - lazyload-min - holla-min Currently I am trying to parse it this way: @custom_asset_packages_yml = (File.exists?("#{RAILS_ROOT}/config/asset_packages.yml") ? YAML.load_file("#{RAILS_ROOT}/config/asset_packages.yml") : nil) ...
I was trying to switch the layout using Ruby on Rails but I am getting the error: undefined method `layout' for #. I am using Rails 2.3.5 Am I missing an include? Here is the code: class HelloController < ApplicationController def index layout 'standard' @message = "Goodbye!" @count = 3 @bonus = "This is the bonus m...
Hello, I am working on a God script to monitor my Unicorns. I started with GitHub's examples script and have been modifying it to match my server configuration. Once God is running, commands such as god stop unicorn and god restart unicorn work just fine. However, god start unicorn results in WARN: unicorn start command exited with ...
I've run into a strange problem with Ruby that I can't explain. I have the following script that grabs whatever code is currently in the clipboard, runs it through a syntax highlighter, then puts the new version BACK into the clipboard: #!/usr/bin/ruby1.9.1 require 'coderay' language = "auto"; if(ARGV.length > 0) language = ARGV[...
I'm trying to use the garb gem to access data from the Google analytics API and find that http requests using garb work just fine from a Linode account, but are refused from home (Comcast). Is Google rejecting some kinds of http requests from certain ISPs, or am I just doing something wrong? Simple example is below: require 'garb' Ga...
When a certain request hits my app I would like to reset the database back to its original state which is backed up in an sqlite3 file. I'd appreciate any help. The app is hosted on heroku. ...
Okay, I'm trying to write a ruby simulation of my grandmother. I can't quite get the loop to work the way I'd like though. I want granny to respond with "OH, THAT REMINDS ME OF BACK IN (random year) ..." when you answer her in all caps but I also want her to respond with "WHAT'D YOU SAY????" when you don't use all caps. I can...
Lets say I'm writing a sinatra extension which mounts a second public directory at a given mount point. require 'sinatra' require 'sinatra/moar-public' set :moar_local, './downloads/' set :moar_remote, 'dls' I now expect a user going to http://myapp.com/downloads/thing.bin to be given the file at [sinatra_root]/dls/thing.bin. Writin...
We use DelayedJob to run some of our long running processes and would like to test with Cucumber/Webrat. Currently, we are calling Delayed::Job.work_off in a Ruby thread to get work done in the background, but are looking for a more robust solution What is the best approach for this? Thanks. ...
Sinatra can serve files from a static directory with the set :public, 'your_directory' command, but how can I replicate this in a new route? Importantly, this new route needs to respect byte ranges too! Any ideas? I feel like I should be able to leverage the already present code in the static serve part of sinatra. ...
Hi, I am trying to set up Vagrant. I am following the guide on the web site and currently have trouble with the Provisioning part of the guide (http://vagrantup.com/docs/getting-started/provisioning.html) I have followed this thing to exactly as it is on the site but I am receiving this error, I am on Mac OSX if it's of any important e...
Hey, I've just installed paperclip 2.3.3 and paperclipftp 0.1.0. Paperclip was working fine, the attachments were saving and everything was great. Enter paperclipftp. I've included both gems in my Gemfile, installed it with bundle and made sure all dependencies were satisfied. I've also double checked that all my ftp info is correct ...