Skip to content

Instantly share code, notes, and snippets.

Aja thagomizer

Block or report user

Report or block thagomizer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View colors.yml
colorTable:
colorWhite: &colorWhite
rgb: [255, 255, 255]
hex: "FFFFFF"
colorRed100: &colorRed100
rgb: [255, 255, 255]
hex: "FFFFFF"
colorRed300: &colorRed300
rgb: [255, 255, 255]
hex: "FFFFFF"
View cloud_build_to_dag.rb
require 'graph'
require 'psych'
steps = Psych.load(File.read(ARGV[0]))["steps"]
previous_steps = []
digraph do
steps.each do |step|
id = step["id"] || step["name"]
View day_13.rb
data = File.read(ARGV[0]).split("\n").map { |l| l.split(": ").map(&:to_i) }
layers = {}
data.each do |a, b|
layers[a] = b
end
max = ARGV[1].to_i
View bin_packing.rb
# A greedy algorithm for bin packing
class Array
def rest
self[1..-1]
end
end
def optimize_pack inventory, order
loop do
View stackdriver_monitoring_three.rb
require "google/cloud/monitoring/v3/metric_service_client"
client = Google::Cloud::Monitoring::V3::MetricServiceClient.new
project = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path(PROJECT_ID)
View stackdriver_monitoring_two.rb
interval = Google::Monitoring::V3::TimeInterval.new
interval.start_time = Google::Protobuf::Timestamp.new(seconds: start_time)
interval.end_time = Google::Protobuf::Timestamp.new(seconds: end_time)
View stackdriver_monitoring_one.rb
require "google/cloud/monitoring/v3/metric_service_client"
client = Google::Cloud::Monitoring::V3::MetricServiceClient.new
project = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path(PROJECT_ID)
metric = "appengine.googleapis.com/system/memory/usage"
end_time = Time.now.to_i
start_time = end_time - (60 * 10) # 10 minutes
@thagomizer
thagomizer / LICENSE
Last active Jan 12, 2017
Code to go with my Authenticating Google Cloud Ruby Gems blog post
View LICENSE
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
View upload_cloud_storage.rb
require "google/cloud/storage"
gcloud = Google::Cloud.new "Your Project", "Path To Your Key"
storage = gcloud.storage
bucket = storage.create_bucket "my_goat_pictures"
bucket.create_file "goat.jpg", "uploaded_goat.jpg"
View metadata.rb
require "net/http"
url = URI.parse("http://metadata.google.internal/computeMetadata/v1/project/attributes/")
req = Net::HTTP::Get.new(url.path)
req.add_field("Metadata-Flavor", "Google")
res = Net::HTTP.new(url.host, url.port).start do |http|
http.request(req)
end
You can’t perform that action at this time.