This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# | |
# Example of usage: | |
# 1.9.3p125 :003 > t = GoogleSpeech.load "#{Dir.home}/text.txt" | |
# => #<GoogleSpeech:0x007f89e38ba690 @text="Hello World it's just a text file. Hey yey!!!", @lang="en"> | |
# 1.9.3p125 :004 > t.save("out.mp3") | |
# => "out.mp3" | |
# | |
# 1.9.3p125 :005 > f = GoogleSpeech.new "Thats shit but I love it" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# | |
#1.9.3-p327 :013 > t = GTranslate.new "This stuff is pretty unexpected!", "pl" | |
#=> #<GTranslate:0x0000000195b0b8 @lang="pl", @text="This stuff is pretty unexpected!", @response=["[[[\"Ten materiał jest dość nieoczekiwanego!\",\"This stuff is pretty unexpected!\",\"\",\"\"]],,\"en\",,[[\"Ten materiał jest\",[5],1,0,802,0,3,0],[\"dość\",[6],1,0,792,3,4,0],[\"nieoczekiwanego!\",[7],1,0,726,4,6,0]],[[\"This stuff is\",5,[[\"Ten materiał jest\",802,1,0],[\"Tych rzeczy jest\",0,1,0],[\"Te rzeczy są\",0,1,0]],[[0,13]],\"This stuff is pretty unexpected!\"],[\"pretty\",6,[[\"dość\",792,1,0],[\"całkiem\",9,1,0],[\"pretty\",0,1,0],[\"śliczny\",0,1,0],[\"ładna\",0,1,0]],[[14,20]],\"\"],[\"unexpected !\",7,[[\"nieoczekiwanego!\",726,1,0]],[[21,32]],\"\"]],,,[[\"en\"]],28]"]> | |
#1.9.3-p327 :014 > t.parse[0] | |
# => ["Ten materiał jest dość nieoczekiwanego!"] | |
# | |
class GTranslate | |
require 'net/http' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
attr_accessor :next_item, :value | |
def initialize(next_item, value) | |
@next_item = next_item | |
@value = value | |
end | |
def reversed | |
@a = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def custom_max | |
idx = self[0] > self[1] ? 1 : 0 | |
self.delete_at(idx) | |
self.length <= 1 ? self[0] : self.custom_max | |
end | |
end | |
a = [4,3,6,1,44,4,8,31,41,2,1,98,2,3,1,8,32,1,4,5,6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection | |
class Instance | |
def initialize(id) | |
@id = id | |
end | |
def say | |
"I am #{@id}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding RMagick to combine images | |
require 'open-uri' | |
require 'uri' | |
require 'rmagick' | |
class PhotoDownloader | |
RESOURCE = 'http://access.nypl.org/image.php/' | |
def initialize(id, zoom, dimension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First quick draft | |
require 'open-uri' | |
require 'uri' | |
class PhotoDownloader | |
RESOURCE = 'http://access.nypl.org/image.php/' | |
def initialize(id, dimension) | |
@id = id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding RMagick to combine images | |
require 'open-uri' | |
require 'uri' | |
require 'rmagick' | |
class PhotoDownloader | |
RESOURCE = 'http://access.nypl.org/image.php/' | |
def initialize(id, zoom, dimension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
class Bingy | |
LANDING_PAGE = 'http://www.bing.com/translator'.freeze | |
SPEAK_URL = LANDING_PAGE + '/api/language/Speak?locale=en-US&media=audio/mp3' | |
def initialize(text, gender = 'male') | |
@user_agent = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36' | |
@params = { text: text, gender: gender } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter' | |
# Bot implementation | |
class Complimentator | |
# Module that holds all commands | |
module Command | |
def compliment(tweet) | |
update(tweet, @compliments.sample) | |
end |
OlderNewer