Ruby

Strip HTML in any string in Ruby

A little code snippet to let you remove HTML from any string in Ruby:
[source:ruby]
class String

# remove all HTML tags from the source string
def strip_html
self.gsub(/< \/?[^>]*>/, "")
end

end
[/source]
Then to run the code just do this:
[source:ruby]
blurb_html = "

Thanks for visiting our site.

"
blurb_text = blurb_html.strip_html
[/source]

Tags: 

Programming for kids, and older kids

One fault that could be levied at the computer industry is that they've lost a lot of the out-of-the-box creativity experience from the early days, back in the 80's when every computer you bought came out of the box with a programming language that anyone (with a manual or two) could start writing their own Hello World apps. Back then most people didn't learn to program at college, they learned from their $200 home computers.

Tags: 

MySQL + Rails on Cygwin tip

Here's a really quick tip for anyone using Rails on Cygwin. If you want to connect to a MySQL database the understood practice is to compile MySQL and go through the hassle of getting it all working within Cygwin itself. After what I've gone through with it all, the best way of getting this combination to work is to:

Tags: 

Pages

Subscribe to Ruby