Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

A Ruby script adhering to the Ruby Way

Name: Anonymous 2006-10-17 11:11

Probably, I don't know what the Ruby Way is! (other than a book)  I did replace my tabs with two spaces, so and that should be enough!
#!/usr/bin/ruby -w
require 'net/http'

def babelfish text
  ['en|ja', 'ja|en'].inject(text) do |txt, pair|
    Net::HTTP.post_form(URI.parse('http://www.google.com/translate_t';), {:text => txt, :langpair => pair}).body.scan(/result_box dir=ltr>([^<]+)<\/div>/)[0][0].strip.gsub(/'/, "'")
  end
end

def nifty text
  ["EN,JA", "JA,EN"].inject(text) do |txt, pair|
    Net::HTTP.get_response(URI.parse("http://nifty.amikai.com/amitext/indexUTF8.jsp?translate=%E7%BF%BB%E8%A8%B3%E3%81%99%E3%82%8B&langpair=#;{URI.escape(pair)}&sourceText=#{URI.escape(txt)}")).body.scan(/translatedText" rows="5">([^<]+)<\/textarea>/)[0][0].strip.gsub(/'/, "'")
  end
end

exit 1 if ARGV.empty?
str = ARGV.join ' '
begin
  while true
    [:babelfish, :nifty].each do |meth|
      str = self.method(meth).call str
      puts str
    end
  end
rescue Interrupt
  # ...
end
Use like this:
./babel.rb hello im fairX the haxxor join my community of hackers if you payme enough i will give you access to a private area of haxx \;\)Output:
  Today as for im fairX access to the private use area of payme me haxx of haxxor sufficient; If it gives, it joins to my community of the hacker)
  im fairX access to the private use area of payme -- being related -- haxx; of today, me, and sufficient haxxor -- it connects with a hacker's community of me, when it gives.
  The access of im fairX to the private use use area of payme -- It is related, but it is -- haxx; Today, me, and sufficient haxxor -- When my community of the hacker giving, you connect that.
  payme (it is associated.) However, it is access of im fairX to the private use use area of that's right.   haxx; today, me, and sufficient haxxor -- My community of giving a hacker when and it are connected.
[...]

Name: Anonymous 2006-10-17 13:00 (sage)

goggles, do nothing, etc.

Name: Anonymous 2006-10-17 13:43

>>2
Enjoy your magic strings!

Name: Anonymous 2006-10-17 13:48

I never realised that Ruby could be abused so.

Maybe Guido had a point.

Name: Anonymous 2006-10-17 14:12

Can anyone think of an easy way of generating the two functions so I can save some code there as well?

Name: Anonymous 2006-10-17 17:49

jesus fuck use some white space. Fucking ruby losers.

Name: Anonymous 2006-10-17 18:44

Thread saved.
import urllib, urllib2, re

def babelfish(langpair, text):
    url="http://babelfish.altavista.com/tr?lp="+langpair+"&trtext="+urllib.quote(text.encode('utf-8';))
    html = urllib2.urlopen(urllib2.Request(url,None,{'Accept-charset':'utf-8'})).read()
    m = re.compile("white class.s..div.style.padding.10px..([^<]*)</div",re.U).search(html)
    return m.groups()[0].decode('utf-8').replace(u'\n',u' ')

def log(f, num, text, encoding='utf-8'):
    out = (unicode(num)+u': '+text+u"\r\n")
    print out.strip().encode('ascii','replace')
    f.write(out.encode(encoding))
    f.flush()

def mutate(text, steps, langpairs, outfile):
    t = unicode(text)
    f = open(outfile,"wb")
    n = 1
    log(f, 0, t)
    history = [t]
    br = False
    while not br:
        for lp in langpairs:
            t = babelfish(lp, t)
            log(f, n, t)
            if n==steps: break
            n += 1
            if t in history:
                br = True
                break
            history.append(t)
        if n==steps: break
    if br: log(f, n, u"[loop found]")
    f.close()

mutate("Hay guys what's going on in this thread?", 20, ['en_ja','ja_en'], "nonsense.txt")

Name: Anonymous 2006-10-17 20:20

LOL UTF-8 IN RUBY LOL

Name: Anonymous 2009-01-14 12:33

LISP

Name: Sgt.Kabu᳑�kimanḯ 2012-05-28 20:38

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List