I need to parse for the an xml style sheet
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/templates/xslt/inspections/disclaimer_en.xsl"?>
Using nokogiri I have tried using
doc.search("?xml-stylesheet").first['href']
but I get the error
`on_error': unexpected '?' after '' (Nokogiri::CSS::SyntaxErro...
How do I make a new document in TextMate using rb-appscript or AppleScript?
Here is my rb-appscript:
te = app("TextMate")
te.launch
doc = te.make(:new => :document)
But it doesn't work.
Here is the error message I get:
OSERROR: -10000
MESSAGE: Apple event handler failed.
COMMAND: app("/Applications/TextMate.app").make({...
i just want the text out of there with out those tags. Does Hrpicot.XML have any methods for this?
...
I have all kind of scripting with Ruby:
rails (symfony)
ruby (php, bash)
rb-appscript (applescript)
Is it possible to replace low level languages with Ruby too?
I write in Ruby and it converts it to java, c++ or c.
Cause People say that when it comes to more performance critical tasks in Ruby, you could extend it with C. But the wor...
I am planning on making an order form that has
text fields (to gather submitted text based information like names, emails, messages)
link fields (to gather submitted links)
upload buttons (to gather images from a user's hard drive)
I assume I will be using Javascript and Ruby for this but I have a few questions.
how would I activa...
Hi,
I need a loop in this pattern. I need an infinite loop producing number that start with 1.
1,10,11,12..19,100,101,102..199,1000,1001.......
...
any good library to send POST headers in ruby ?
...
This is not a X vs Y question - do not reply as same.
Does anyone know where I could find reviews or reports on tasks that people did in two or more high-level scripting languages to see which one was more suited for a certain job? (note that this is different from looking for a language suited for all jobs!) I really want to know which...
For Web Applications I use Ruby on Rails. And now it's time to see if I can code Desktop Applications with Ruby.
So I wonder which one I should choose.
The way I see it is MacRuby+IronRuby vs JRuby.
The former lets me have desktop applications for both Mac and Windows while the latter lets be have in both, but only learning one tool.
...
Hi everyone,
We have this method in our Ruby project. It accepts an XML object (which consists of three different "trees") and is supposed to copy X elements from the end. For some reason, what it does is move those elements -- and then the original XML object (which we passed to it) gets cut off.
We tried .clone but it doesn't copy th...
What stuff does each one do (or, generate?) pardon the pun.
...
class PostsController < ApplicationController
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
...
What exactly is "respond_to" Is it
part of rails?
What is "do" and"|format|"? Why are there verti...
I have a timestamp that represents the last time a particular record was viewed. I want to present to the user a display that gives a human readable representation of the difference between that time and now.
So it should be something like
"Last viewed 38 seconds ago"
or "Last viewed 1 hour 15 minutes 10 seconds ago"
Is there a qui...
In Ruby, I see that it can be useful to put classes inside modules for namespacing. I also see that it's possible to put moduldes inside classes. But I don't see why you'd do that.
Modules are generally mixed into classes, right? So what would be the purpose of defining a module inside a class?
(I also notice that Googling "ruby 'modul...
Following code works
def lab
Proc.new { return "foo1" }.call
return "foo2"
end
puts lab #=> foo1
Following does NOT work. Why?. I get LocalJumpError
class Foo
def self.doit(p)
p.call
end
end
p = Proc.new {
return 'from block'
}
a = Foo.doit(p)
puts a
...
Hi guys,
I am currently learning Ruby and I am wondering whether you guys can suggest some medium to difficult iterators to implemet?
Thanks
...
Guys,
I need to test the following helper:
def display_all_courses
@courses = Course.all
output = ""
for course in @courses do
output << content_tag(:li, :id => course.title.gsub(" ", "-").downcase.strip) do
concat content_tag(:h1, course.title)
concat link_to("Edit", edit_course_path(course))
end
end
...
I'm currently using:
@user = User.find(params[:id])
@posts = Post.find(:all, :conditions => ["user_id = ?", @user.id])
@comments = Comment.find(:all, :conditions => ["user_id = ?", @user.id])
Which identifies the user, and lists all their comments they've made. However, I want to set a local variable for use in the _comment.html.erb ...
What is the recommended approach to import Apache access log into a MySQL table? I am thinking of a ruby/perl script + a cron job. It'll be great if there is an example or reference.
I am not sure how to handle the bookmarking of the last log entry in last import either. Suggestions are welcome. Thanks!
...
I'm currently using:
@user = User.find(params[:id])
@posts = @user.posts
@comments = @user.comments
To display all my comments with this code in my template:
<% @user.comments.each do |p| %>
<p>Commented on <%= p.post.user_id %>'s post</p>
<p><%= p.body %></p>
<% end %>
Each post has a 'user_id' column which is the user's ID fo...