I'm looking for an easy way to generate previews for labels generated as pdfs. It would be great if I could convert these pdfs to images and show them to the user before the actual print/download.
The application is currently running in a Jruby on rails environment, but it's quite possible that we switch to two applications, one running...
hi
I want to extract from a webpage all URLs how can I do that with nokogiri?
example:
<div class="heat">
<a href='http://example.org/site/1/'>site 1</a>
<a href='http://example.org/site/2/'>site 2</a>
<a href='http://example.org/site/3/'>site 3</a>
</diV>
result should be an list:
l = ['http://example.org/site/1...
I want do unzip a lot of zip files, is there a module or script that check which format the zip file is and decompress it?
this should work on linux, other OSs I don't care for this.
...
In the Compass screencast at 23:08 Chris Eppstein starts editing a file called config.rb, in his pure Compass project. Chris uses this file to configure relative path names in his images using the *img_url()* function (which must be undocumented as I can't find anything about it, in the mailing list or on the website.).
I'm working on ...
I am writing an method that takes variable lengths of arrays and compresses and converts them to matching array lengths.
The method accepts an array length of anywhere from 50 to 126 . .. and converts them down based on parameters when called. This means is I am dynamically accessing ranges that are specified at method call. This also ...
We are about to start a new Web2/AJAX app and are trying to decide if its worth the time and effort learning Ruby/RubyOnRails instead of PHP, CodeIgnitor and JQuery we currently use.
The key issues are clean/fast/modern AJAX UI, robust error handling, ans maintainability.
I would appreciate unbiased (if thats at all possible talking la...
I wonder when we write a program in PHP, Ruby, or Python, how do we make it easily downloadable and installable by general users like a Win32 app?
and is it possible to make it a Mac app easily too?
...
Can I sort a list of objects by a property of an associated object?
For example with the following class
class RosterSlot < ActiveRecord::Base
belongs_to :event
belongs_to :skill
belongs_to :person
end
I want to do something like
RosterSlot.find(:all, :order => skill.name)
which means activerecord needs to do a join and or...
I was wondering if PHP can do this as there seems to be no good solution to it yet:
p($i)
and it will print
$i is 5
and
p(1 + 2)
will print
1 + 2 is 3
and
p($i * 2) => $i * 2 is 10
p(3 * factorial(3)) => 3 * factorial(3) is 18
C and Ruby both can do it... in C, it can be done by stringification, and in Ruby, there i...
I have a small test project that I'm using to test the waters for a much larger project. I am using rspec on rails for testing, but recently looked into Cucumber. It looks very nice, but I'm wondering if there's a way for cucumber to run my spec tests, or for rspec (autospec) to run my cucumber features. I've looked around extensively...
I borrowed some code from a site, but I don't know how to get it to display.
class Stopwatch
def start
@accumulated = 0 unless @accumulated
@elapsed = 0
@start = Time.now
@mybutton.configure('text' => 'Stop')
@mybutton.command { stop }
@timer.start
end
def stop
@mybutton.configure('text' => 'Start')
...
I need to make a small application in Ruby that will display log lines received over TCP in different colors.
What is a recommended GUI framework to use for this type of app?
I should work on Windows and Linux.
...
ActiveRecord's has_many and belongs_to methods both take a :foreign_key option. If I need to use it to handle a nonstandard FK column name, should I set it for the parent model (has_many), child model (belongs_to), or both, or does it matter?
...
How do you take paragraph or large amount of text and break it into sentences (perferably using Ruby) taking into account cases such as Mr. and Dr. and U.S.A? (Assuming you just put the sentences into an array of arrays)
UPDATE:
One possible solution I thought of involves using a parts-of-speech tagger (POST) and a classifier to determ...
Anything that saves a few characters and produces horrible, unreadable code is fair game.
My favourite is cheating spacing with the ternary operator. If you're testing a question-mark-method (like .nil?), the only place you need a space is after the second question mark:
x.odd?? "odd":"even"
...
Hello,
I am trying to understand has_one relationship in ruby on rails.
let's say I have two models - Person and Cell
class Person < ActiveRecord::Base
has_one : cell
end
class Cell < ActiveRecord::Base
belongs_to : person
end
can I just use has_one: person instead of belongs_to : person in Cell model?
isn't it same?
...
USER = "user"
PASS = "pass"
QUERY = "SELECT c1, c2, c3, c4, c5, c6, c7 FROM table"
SQLITE_SCHEMA = 'c1, c2, c3, c4, c5, c6, c7'
sqlite_db = SQLite3::Database.new('sqlite.db')
odbc_db = DBI.connect('DBI:ODBC:database', USER, PASS)
odbc_db.select_all(QUERY) do |entry|
sqlite_db.execute "insert into smnt (" + SQLITE_SCHEMA + ") values ...
If you have DB columns created_at and updated_at Rails will automatically set those values when you create and update a model object. Is there a way to save the model without touching those columns?
I am bringing in some legacy data and I would like to set those values from the corresponding values in the (differently named) legacy data...
How can I convert "1234567890" to {0x12, 0x34, 0x56, 0x78, 0x90} in Ruby?
...
In the world of Java, BEA (now Oracle) has created LiquidVM which doesn't require an OS. Likewise, there are a variety of open source projects including SANOS, JNODE OS, Project Guest VM, JavaOS, etc.
Is there an equivalent being created for Ruby?
...