Hi
I need to check for
"Apple" = "Apple" TRUE
"Apple" = "APPLE" TRUE
"Apple" = "Apple1" FALSE
in ruby
I need a string comparison but for the check to not be case sensitive.
thks
I have a binary files which needs to be sent as a string to a third-party web-service. Turns out it requires that it needs to be base64 encoded.
In ruby I use the following:
body = body << IO.read("#{@postalcard.postalimage.path}")
body is a strong which conists of a bunch of strings as parameters.
So...how do I base64 encode it into this string?
Thanks.
Hi there
I've put some of my free time on reading/learning about cakephp but now I'm wondering if will not be better to switch completely to rubyon rails.
Can you give me the good and the bad of those tools, when is about web-development?
many thx
How do I check If a Class already exists in Ruby,
My code is:
puts "enter the name of the Class to see if it exists"
nameofclass=gets.chomp
eval (" #{nameofclass}...... Not sure what to write here")
I was thinking of using:
eval "#{nameofclass}ancestors. ....."
I'm working on integrating ruby with ldap. And it's working fine.
Created test.com in ldap and I can bind with it successfully.
Then I created a new organizational unit company. Under company there are some users
Now I want to bind with the users(authentication) under company organizational unit.
I can access the user using Filter.eq
But I want to bind with the users.
Suggestions plz..
A friend of mine asked me if I was aware of Rubyon Rails ... and frankly I have heard a lot about it but know practically nothing about it. Any help will be much appreciated.
Can't seem to find how to check if an object is a boolean easily. Is there something like this in Ruby?
true.is_a?(Boolean)
false.is_a?(Boolean)
Right now I'm doing this and would like to shorten it:
some_var = rand(1) == 1 ? true : false
(some_var.is_a?(TrueClass) || some_var.is_a?(FalseClass))
Hello all, I have been trying to post blogs to Blogger via the API provided for posting but the problem I have is how to write the ruby code for the http post that will be able to carry the texts and make the post. In the API, it is stated that one has to First, create an XML representation of the post to publish.
Please can someone help me with a suggestion. This is the API that was provided: "http://www.blogger.com/feeds/blogID/posts/default"
The post office actually publishes a list of commonly used street suffixes in addresses:
http://www.usps.com/ncsc/lookups/abbr_suffix.txt
I want to take this list and make a ruby function that takes a string, takes the last word ("183 main strt".split[' '].last) and if it matches any of the commonly used street suffixes ("strt"), replace it with the official Postal Service Standard Suffix ("st").
Is there a better way to approach this than a massive str.sub.sub.sub.sub.sub?
ruby on rails ferret search:.only 10 records are getting from table.For pagination i did it ,but only 10 records are getting even though there exists more records satisfying the search condition.if any of you know how to solve this,please reply. no limit is givenf it is not a ferret search all records are getting from table , and pagination is working
the code is:
@search_sd_ticket_result=ServiceDeskTicket.find_with_ferret(params[:sd_ticket][:servicedeskticket]).paginate :per_page =5, :page=params[:page]
My company has data messages (json) stored in gzipped files on Amazon S3. I want to use Ruby to iterate through the files and do some analytics. I started to use the 'aws/s3' gem, and get get each file as an object:
#<AWS::S3::S3Object:0x4xxx4760 '/my.company.archive/data/msg/20131030093336.json.gz'>
But once I have this object, I do not know how to unzip it or even access the data inside of it.
Hi guy,
In ruby ActiveRecord doesn't provide dynamic binding for update and insert sqls, of course i can use raw sql, but that need maintain connection, so i want to know if there is simpler way to escape update or insert sql before executing like code below:
ActiveRecord::Base.connection.insert(sql)
i think i can write code by gsub, but i know if there has been a ready method to do it.
thank you very much, and Merry Christmas for you all.
How do I include the 'autofocus' attribute on an HTML5 form using the text_field form helper in ruby?
e.g. <%= f.text_field :email %
Where does autofocus go?
Thanks
I want to install a ruby gem which tries to build a native extension. The gem in this case is nokogiri. If I do gem install nokogiri, the native extension dynamically links against libxml, libxslt libs. I want to statically link against those libs. How should I go about this?
hi,
anyone know how to create a suggestion box in rubyon rails? all the materials i found so far are about observe some text field and update some list in other , not related to suggestion box...
Thanks!
Are there any logging frameworks in ruby that allow you to log a specific event type only once?
logger = IdealLogger.new
logger.log(:happy_path, "We reached the happy path") # => logs this message
logger.log(:happy_path, "We reached the happy path yet again") # => Doesn't log this
logger.log(:sad_path, "We've encountered a sad path!") # => logs this message
Also, is there a term for the concept of logging a certain event type only once?
for instance in python it is possible to assign a method to a variable:
class MyClass
def myMethod(self):
return "Hi"
x = MyClass()
method = x.myMethod
print method() # prints Hi
I know this should be possible in Ruby, but I don't know what's the syntax.
Hi,
I write a little ruby script, which sends me an email when a new commit added to our svn.
I get the log with this code:
log = `/usr/bin/svnlook log #{ARGV[0]}`
When I run my script from bash I get good encoded character in the email, but when I try it and create a new commit I get wrong hungarian characters.
I commited this:
tes
oéá
I get this in the email:
Log: tes
?\197?\145?\195?\169?\195?\161
How can I solve this issue?
Is this a ruby bug?
target_url_to_edit = target_url
if target_url_to_edit.include?("http://")
target_url_to_edit["http://"] = ""
end
logger.debug "target url is now #{target_url}"
This returns target_url without http://
In a simple Ruby example, I'm getting an error that does not occur in irb.
name = "Joe"
def say_hi
"\"Hi there!\" said #{self}"
end
response = name.say_hi
puts response
This code should return, "Hi there!" said Joe.
It works perfectly fine in irb. However, when I attempt to put the same code in a file and run the file, I get this error:
say_hi.rb:8:in `<main>': private method `say_hi' called for "Joe":String (NoMethodError)
Any suggestion about why this happens?
So I know in ruby that x.nil? will test if x is null.
What is the simplest way to test if x equals ' ', or ' ', or ' ', etc?
Basically, I'm wondering what the best way to test if a variable is all whitespace?