Skip to content

Instantly share code, notes, and snippets.

View everton's full-sized avatar

Everton J. Carpes everton

  • http://www.nutrebem.com.br
  • Rio de Janeiro, RJ - Brasil
View GitHub Profile
@everton
everton / gist:1080407
Created July 13, 2011 14:35
jRuby bug with encoding
#-*- coding: utf-8 -*-
str = "<h1>Bugs#index</h1>
<%= @user %>
<p>á</p>"
str =~ /(?m-ix:<%(=+|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?)/
@everton
everton / Bhaskara
Created April 6, 2011 13:45
Weird way to say Bhaskara in Ruby (or "((-b).± √ Δ(a, b, c))" / (2 * a) as a valid Ruby expression)
#!/usr/bin/env ruby
#-*- coding: utf-8 -*-
def √(n)
Math::sqrt(n)
end
class Numeric
def ±(n)
r = [self + n, self - n]