Created
April 23, 2017 21:02
-
-
Save beccasaurus/4d5c58e652e364d7883626bf63828e6d to your computer and use it in GitHub Desktop.
6 LOC :: Google Cloud Client Library Samples
This file contains hidden or 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 "google/cloud/datastore" | |
datastore = Google::Cloud::Datastore.new | |
query = datastore.query("Dog").limit(5) | |
datastore.run(query).each do |dog| | |
puts dog["name"] | |
end |
This file contains hidden or 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 "google/cloud/dns" | |
dns = Google::Cloud::Dns.new | |
zone = dns.zone "example-com" | |
zone.records.each do |record| | |
puts record.name | |
end |
This file contains hidden or 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 "google/cloud/language" | |
speech = Google::Cloud::Language.new | |
document = language.document "The dog barked." | |
document.annotate.sentences.each do |sentence| | |
puts sentence.sentiment.score | |
end |
This file contains hidden or 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 "google/cloud/pubsub" | |
pubsub = Google::Cloud::Language.new | |
subscription = pubsub.subscription "notifications" | |
subscription.pull.each do |message| | |
puts message.data | |
end |
This file contains hidden or 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 "google/cloud/speech" | |
speech = Google::Cloud::Speech.new | |
audio = speech.audio "audio.wav" | |
audio.recognize.each do |result| | |
puts result.transcript | |
end |
This file contains hidden or 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 "google/cloud/storage" | |
storage = Google::Cloud::Storage.new | |
bucket = storage.bucket "dogs-images" | |
bucket.files.each do |file| | |
puts file.name | |
end |
This file contains hidden or 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 "google/cloud/vision" | |
vision = Google::Cloud::Vision.new | |
image = vision.image "dog.png" | |
image.labels.each do |label| | |
puts label.description | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment