Skip to content

Instantly share code, notes, and snippets.

View djberg96's full-sized avatar

Daniel Berger djberg96

View GitHub Profile
[1] pry(main)> i = ActiveSupport::Inflector.inflections(:en)
=> #<ActiveSupport::Inflector::Inflections:0x0000000002532f30
@acronym_regex=/Api|GraphiQL/,
@acronyms={"api"=>"Api", "graphiql"=>"GraphiQL"},
@acronyms_camelize_regex=/^(?:(?-mix:Api|GraphiQL)(?=\b|[A-Z_])|\w)/,
@acronyms_underscore_regex=/(?:(?<=([A-Za-z\d]))|\b)((?-mix:Api|GraphiQL))(?=\b|[^a-z])/,
@humans=[],
@plurals=
[[/(z)ombies$/i, "\\1ombies"],
[/(z)ombie$/i, "\\1ombies"],
require 'hexapdf'
# Use local copy of http://foersom.com/net/HowTo/data/OoPdfFormExample.pdf
file = 'pdf_form_example.pdf'
doc = HexaPDF::Document.open(file)
page1 = doc.pages.first
widgets = page1[:Annots]&.filter{ |a| a[:Subtype] == :Widget }
# See what the widgets look like.
@djberg96
djberg96 / keybase.md
Created May 13, 2022 13:47
keybase.md

Keybase proof

I hereby claim:

  • I am djberg96 on github.
  • I am djberg96 (https://keybase.io/djberg96) on keybase.
  • I have a public key ASC4MIT3C1NsZErilv9lMvhL5h0MKq38b010veHzAu3fEQo

To claim this, I am signing this object:

native-path: BAT0
vendor: SMP
model: 5B10X19049
serial: 2080
power supply: yes
updated: Fri 27 Aug 2021 12:12:37 PM EDT (44 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
# 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)
# 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,
package main
import (
"fmt"
"time"
"math/rand"
)
func randate() time.Time {
min := time.Date(1970, 1, 0, 0, 0, 0, 0, time.UTC).Unix()
# 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
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/sentry-go@v0.10.0/http/sentryhttp.go:117 +0x14e
panic(0x1aba6a0, 0xc0002e0060)
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/sentry-go@v0.10.0/http/sentryhttp.go:117 +0x14e
panic(0x1bbc6e0, 0x25879f0)