Skip to content

Instantly share code, notes, and snippets.

@gailimov
Created November 13, 2011 17:12
Show Gist options
  • Save gailimov/1362347 to your computer and use it in GitHub Desktop.
Save gailimov/1362347 to your computer and use it in GitHub Desktop.
Pretty awesome parser of advices from http://fucking-great-advice.ru
# coding: utf-8
# Pretty awesome parser of advices from http://fucking-great-advice.ru
# PHP version from Dmitry Zudochkin: https://gist.github.com/1303241
# Author: Kanat Gailimov <gailimov@gmail.com> (http://gailimov.info) with love :)
require 'json'
require 'open-uri'
require 'cgi'
hash = JSON.parse(open('http://fucking-great-advice.ru/api/random').read)
hash['text'] = CGI.unescapeHTML(hash['text'].gsub('&nbsp', ' ').gsub(/&#[0-9]|;/, ''))
puts hash['text']
@gailimov
Copy link
Author

Джаст фор фан поиграться с рубями :)

@zudochkin
Copy link

теперь занеси его в ~/.bashrc, чтобы при входе на сервак отображался рандомный совет )

@gailimov
Copy link
Author

ага, занесу)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment