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
# 1) Create lib/loggers/database_logger.rb using code below. | |
# 2) Create 'logs' table (and corresponding Log model) with timestamp, severity, and message columns (plus whatever else you want). | |
# 3) In configuration file of your choice (application, development, etc) first do 'require "loggers/database_logger"' | |
# 4) then set config.logger to Loggers::DatabaseLogger.new | |
module Loggers | |
class DatabaseLogger < ActiveSupport::Logger | |
# Set logdev to nil to prevent it from writing to a file. | |
def initialize(logdev = nil, *args) | |
super(logdev, *args) |
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
# Created a "logs" table and corresponding "Log" model | |
config.logger = ActiveSupport::Logger.new(STDOUT) | |
# Why does this hang? | |
config.logger.formatter = proc { |severity, timestamp, program_name, message| | |
Log.create( | |
:severity => severity, | |
:timestamp => timestamp, | |
:program_name => program_name, |
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
package main | |
import ( | |
"fmt" | |
"time" | |
"math/rand" | |
) | |
func randate() time.Time { | |
min := time.Date(1970, 1, 0, 0, 0, 0, 0, time.UTC).Unix() |
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
# Find common games between users on BGG | |
require 'excon' | |
require 'awesome_print' | |
require 'oga' | |
require 'getopt/long' | |
require 'cgi' | |
# Looks like BGG redirects to non-www url's sometimes | |
Excon.defaults[:middlewares] << Excon::Middleware::RedirectFollower |
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
17911 logger.go:71] [opid=1sgEMWI9smSmasMiuGGprorF33B] {"request_method":"PATCH","request_url":"/api/status-board/v1/peer_dependencies/ac031952-8fa2-422a-82ce-a776821c697c","request_header":{"Accept":["application/json"],"Content-Length":["55"],"Content-Type":["application/json"]},"request_body":{"Reader":{},"Closer":{}},"request_remote_ip":"127.0.0.1:59041"} | |
2021/05/17 17:09:44 http: panic serving 127.0.0.1:59041: uuid: Parse(zzzz): invalid UUID length: 4 | |
goroutine 16 [running]: | |
net/http.(*conn).serve.func1(0xc0002df9a0) | |
/usr/local/opt/go/libexec/src/net/http/server.go:1824 +0x153 | |
panic(0x1aba6a0, 0xc0002e0060) | |
/usr/local/opt/go/libexec/src/runtime/panic.go:971 +0x499 | |
github.com/getsentry/sentry-go/http.(*Handler).recoverWithSentry(0xc000318190, 0xc0007defc0, 0xc000422d00) | |
/Users/dberger/golang/pkg/mod/github.com/getsentry/[email protected]/http/sentryhttp.go:117 +0x14e | |
panic(0x1aba6a0, 0xc0002e0060) |
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
E0517 10:58:53.326752 14255 logger.go:84] [opid=1sfVGNH9AMP0ouVlVs8whdUuhCQ] OCM-SB-9: Unable to create Unable to find all associated services: OCM-SB-7: Unable to find all associated services | |
2021/05/17 10:58:53 http: panic serving 127.0.0.1:54900: runtime error: invalid memory address or nil pointer dereference | |
goroutine 308 [running]: | |
net/http.(*conn).serve.func1(0xc000135c20) | |
/usr/local/opt/go/libexec/src/net/http/server.go:1824 +0x153 | |
panic(0x1bbc6e0, 0x25879f0) | |
/usr/local/opt/go/libexec/src/runtime/panic.go:971 +0x499 | |
github.com/getsentry/sentry-go/http.(*Handler).recoverWithSentry(0xc000524000, 0xc000596a80, 0xc000280d00) | |
/Users/dberger/golang/pkg/mod/github.com/getsentry/[email protected]/http/sentryhttp.go:117 +0x14e | |
panic(0x1bbc6e0, 0x25879f0) |
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
func MakeService(h *test.Helper, ctx context.Context) (*api.Service) { | |
application_group := h.NewApplicationGroup(ctx, "some_application_group") | |
application := h.NewApplication(ctx, application_group, "some_application") | |
service := h.NewService(ctx, application, "some_service") | |
return service | |
} | |
func TestPeerDependencyPatchWithValidServiceIds(t *testing.T) { | |
h, client := test.RegisterIntegration(t) |
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
// Current error: use of package presenters without selector | |
func TestPeerDependencyPostWithValidServiceIds(t *testing.T){ | |
h, client := test.RegisterIntegration(t) | |
account := h.NewRandAccount() | |
ctx := h.NewAuthenticatedContext(account) | |
service_uuid1 := h.NewUUID() | |
service_uuid2 := h.NewUUID() | |
service1 := h.NewService(service_uuid1, h.NewApplication(h.NewUUID(), h.NewApplicationGroup(h.NewUUID()))) |
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
// Current error: cannot use services (type []openapi.Service) as type []openapi.ObjectReference in field value | |
func TestPeerDependencyPostWithValidServiceIds(t *testing.T){ | |
h, client := test.RegisterIntegration(t) | |
account := h.NewRandAccount() | |
ctx := h.NewAuthenticatedContext(account) | |
service_uuid1 := h.NewUUID() | |
service_uuid2 := h.NewUUID() | |
service1 := h.NewService(service_uuid1, h.NewApplication(h.NewUUID(), h.NewApplicationGroup(h.NewUUID()))) |
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 'awesome_print' | |
require 'json' | |
require 'excon' | |
require 'securerandom' | |
url = "http://localhost:8000/api/status-board/v1/peer_dependencies" | |
service_id1 = SecureRandom.uuid | |
service_id2 = SecureRandom.uuid |