How to make time series, zoomable diagrams on ruby

I'd like to achieve time series, zoomable highcharts,like following picture, on ruby. I've achieved the following line chart using lazy_high_charts However I have no idea how to get the time series char

Equivalent to OCaml variants in Ruby

Is there a way to create in Ruby something like the OCaml variants? I'm trying to do something like this: type status = | sent of DateTime * Location | paid of DateTime | new But I can't figure how to do this in a a clean, safe and concise way. I hav

Using the Data_bag Chef via Ruby Recipe error?

I have a Chef DataBag that I'm trying to read and use inside of a chef recipe, and its kicking my ass. Please note: I'm not a programmer, and the use of Chef is my first entry into Ruby. Based off of the examples I've found online, here is the conten

DRY: minimize the code

I want a method to create the following json string in many places: {"daily_calendar":{"search":{"print_date":"2014-06-30"}}} I have following four lines of code to make the hash: custom_params, print_date, search =

Remove the item from the table by type

I have the following array: ["--",1,2,3,4] How can I remove elements from the array by element type, ie. remove all non-integer values from the array?I'd do :- ary = ["--",1,2,3,4] ary = ary.grep(Integer) ary # => [1, 2, 3, 4] Note

Proc.arity vs. Lambda.arity

Why do proc and lambda return different values for arity? e.g. proc { |x = 0| }.arity #=> 0 lambda { |a = 0| }.arity #=> -1 proc { |x=0, y| }.arity #=> 1 lambda { |x=0, y| }.arity #=> -2 See:

Combinations of progressive ranks in Ruby

I have multiple arrays, lets say 4 for example: a = ["a", "b", "c" ] b = [1, 2, 3, 4] c = ["xx", "yy"] d = ["abc"] I'd like to "progressively" do product of arrays in an iterative fashi

Ruby on Rails: Pushing to Heroku - Key Error

I have recently moved my app from a linux machine to windows, and I am trying to set it up with heroku again. There are problems with my keys, so I am just wanting to push the app up as a brand new app. I do, git init, then git add ., then git commit

How to join Arel?

Arel 3.0.2 provides two classes to specify the join type: Arel::Nodes::InnerJoin and Arel::Nodes::OuterJoin and uses InnerJoin as default. foo ='foo') bar ='bar') foo.join(bar, Arel::Nodes::InnerJoin) # inner foo.joi

Does Ruby have anything like JavaDoc?

I am trying to learn Ruby, but I am having problems using the API. For example, I am looking at this: decode(json) Converts a JSON string into a Ruby object. # File lib/active_support/json/decoding.rb, line 11 11: def decode(json) 12: YAML.load(conve

Using a Mix Method in an Instance Method

Why does this not work: class Myclass include HTTParty def dosomething base_uri("some_url") end end The base_uri method is a class method of HTTParty. It works fine if I call it from my class, outside of any instance methods, or from a class met

Type the casting values ​​during an attr_accessor

I am a newbie to Ruby and am learning it using "Programming Ruby 1.9" (PickAxe). In the book, I see a program which I modified thus: 1 #!/usr/bin/env ruby -w 2 3 class BookInStock 4 attr_reader :isbn 5 attr_accessor :price 6 def initialize(isbn,

A simple way to always make a tiny field in db

Currently I'm doing the following in the model: before_save :to_lower before_create :to_lower def to_lower = end Seems pretty repetitive to me.You don't need the before_create if you already have before_save. before_save

Rank Postgres as column

I have the following query: SELECT name, rank() OVER (PARTITION BY user_id ORDER BY love_count DESC) AS position FROM items And I'd now like to do a where clause on the rank() function: SELECT name, rank() OVER (PARTITION BY user_id ORDER BY love_cou

How do I generate a rich text link for pbcopy

I've been playing with a script that takes the selected text in Chrome and looks it up in Google, offering the four top choices, and then pasting the relevant link. It is pasted in different formats depending on which page is currently open in Chrome

Convert non-ASCII characters from ASCII-8BIT to UTF-8

I'm pulling text from remote sites and trying to load it into a Ruby 1.9/Rails 3 app that uses utf-8 by default. Here is an example of some offending text: Cancer Res; 71(3); 1-11. ©2011 AACR.\n That Copyright code expanded looks like this: Cancer Re

How to take off the quote from the string in Ruby

I want to strip leading and trailing quotes, in Ruby, from a string. The quote character will occur 0 or 1 time. For example, all of the following should be converted to foo,bar: "foo,bar" "foo,bar foo,bar" foo,barYou could also use th

Ruby String Integer Scanning

Is there a Ruby equivalent of the Java Scanner? If I have a string like "hello 123 hi 234" In Java I could do Scanner sc = new Scanner("hello 123 hi 234"); String a = sc.nextString(); int b = sc.nextInt(); String c = sc.nextString(); i

Can not run Ruby script from file, but IRB works fine?

I have a tiny shell script that writes to a serial device: #!/usr/bin/ruby require 'rubygems' require 'serialport' @sp = "/dev/tty.usbserial-A6004cNN", 19200 @sp.write ["\x01\x01\x04\x00", "n", "\xff\xff\x

Inheritance of ruby ​​type multiple succession type

I got a Base superclass and a bunch of derived classes, like Base::Number, Base::Color. I'd like to be able to use those child classes as if I they inherited from say Fixnum in the case of Number. What's the best way to do this, while still having th

How do I validate XHTML, ATOM and CSS in Ruby?

I'd like to run validations on the static web content I'm creating. Are there any good validators for XHTML, ATOM, and CSS? (The first two would be covered by any general-purpose XML-DTD validator.) Later I failed to specify that I wanted local valid

How does Ruby know where to find a required file?

Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile in the root path of every rails project. I guess this line is used to require vendor/rails/railties/lib/tasks/rails.rb to get all rake tasks loaded: $VERBOSE = nil #