Skip to content

Instantly share code, notes, and snippets.

export class Table<T> {
private lastId = -1;
private readonly data: Map<number, T> = new Map();
private readonly indexes: Map<keyof T, Map<T[keyof T], number[]>> = new Map();
constructor(...indexes: Array<keyof T>) {
for (const idx of indexes) {
this.indexes.set(idx, new Map());
}
package foo
func TestMyQueueWorker(t *testing.T) {
state, err := terraform.Apply(fmt.Sprintf(`
resource "google_pubsub_topic" "in-topic" {
name = "acc-test-%s"
}
resource "google_pubsub_subscription" "in-topic-sub" {
name = "acc-test-%s"
require 'minitest/autorun'
# My helper
class AddTestHelper
def self.add_crud_tests(x)
x.send(:define_method, :test_foobar) { puts 'testing foobar' }
end
end
# My test class
# Ensure any resources with this prefix are removed
Minitest.after_run do
@@client.list_topics[:body]["topics"]\
.map { |t| t["name"] }\
.select { |t| t.start_with?(TOPIC_RESOURCE_PREFIX) }\
.each { |t| @@client.delete_topic(t) }
end
def process_collection(collection, key)
process_flatten_collection(collection, key) { |x| [yield(x)] }
end
def process_flatten_collection(collection, key)
@data[key] ||= []
@data_index[key] ||= {}
collection.each do |item|
yield(item).each do |uid, new_result|
describe ManageIQ::Providers::Google::CloudManager::RefreshParser do
it 'doesnt entirely crash when pulling data' do
empty_collection = double(Fog::Collection, :all => [])
connection = double(
"Fog::Compute::Google::Real",
:disks => empty_collection,
:flavors => [],
:forwarding_rules => empty_collection,
:images => empty_collection,

Setting up events for Google Provider in ManageIQ

(Note: much of this was taken from this public document: https://cloud.google.com/logging/docs/export/configure_export)

Summary

Events can be setup on a per-project basis by using Google Stackdriver Logging combined with Google Pub/Sub. Stackdriver logging is a service that aggregates and exposes log events from various other Google services and applications. This document describes how to export activity log entries for a Google project to Google Pub/Sub, a messaging service.

Prerequisites

  1. You must have owner permission on the project you are exporting
  2. You must have enabled the Google Cloud Pub/Sub API for your project. You can enable the API via the following steps:
  3. Visit the API Library
print "# at all times, a player has a track associated with them"
print "# cnf rep of (hasTrack(p1, t1) ^ track(t1)) v (hasTrack(p1, t2) ^ track(t2)) v ..."
for player in players:
pieces = []
disjs = []
for track in tracks:
piece = []
piece.append("hasTrack(%s, %s)" % (player, track))
piece.append("track(%s)" % track)
pieces.append(piece)