Skip to content

Instantly share code, notes, and snippets.

@dmaze
dmaze / graphql-from-definition-args.rb
Created October 9, 2019 17:55
graphql-ruby 1.9.8 resolver arguments don't work when schema is built from_definition
#!/usr/bin/env ruby
# frozen_string_literal: true
# This illustrates a bug in graphql-ruby 1.9.8. Prior to this version,
# a resolver function passed in the map to GraphQL::Schema.from_definition
# could access its arguments as methods on the `args` object it gets passed;
# but starting in graphql-ruby 1.9.8 this no longer works.
require 'graphql'
@dmaze
dmaze / app.rb
Created November 26, 2018 16:22
dry-system doesn't memoize auto-registered components
# frozen_string_literal: true
require 'dry/system/container'
class Application < Dry::System::Container
configure do |config|
config.auto_register = ['lib']
end
load_paths!('lib')
end
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'dry/container'
require 'dry/transaction'
require 'dry/transaction/operation'
# Run this as an around step
class First
# Running this transaction step will fail with
#!/usr/bin/env ruby
# frozen_string_literal: true
# With dry-auto_inject 0.4.5, this prints out "a", "b", "c".
# With dry-auto_inject 0.4.6, "b" is lost.
# If you remove Base#initialize then "b" is still there.
require 'dry-auto_inject'
class Container
@dmaze
dmaze / dry-rb-env.rb
Created April 18, 2018 23:45
A dry-system application that uses an environment variable
# frozen_string_literal: true
require 'dry/system/container'
require 'dry/system/components'
require 'dry/types'
module Types
include Dry::Types.module
end
@dmaze
dmaze / k8s-services.yaml
Created January 17, 2018 01:45
Very minimal Kubernetes NodePort/LoadBalancer services
---
apiVersion: v1
kind: ConfigMap
metadata: {name: content}
data:
index.html: '<html><body><h1>Hello world</h1></body></html>'
---
apiVersion: apps/v1beta2
kind: Deployment
metadata: {name: lb}
@dmaze
dmaze / tf.log
Created November 14, 2016 17:20
Terraform plan trace log
2016/11/14 12:14:22 [INFO] Terraform version: 0.7.10 fcf12bc46a34716652a5b9a4d7905361003293e7
2016/11/14 12:14:22 [INFO] CLI args: []string{"/Users/dmaze/.virtualenvs/rollout7/bin/terraform", "plan"}
2016/11/14 12:14:22 [DEBUG] Detected home directory from env var: /Users/dmaze
2016/11/14 12:14:22 [DEBUG] Detected home directory from env var: /Users/dmaze
2016/11/14 12:14:22 [DEBUG] Attempting to open CLI config file: /Users/dmaze/.terraformrc
2016/11/14 12:14:22 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/11/14 12:14:22 [DEBUG] Detected home directory from env var: /Users/dmaze
2016/11/14 12:14:22 [TRACE] Preserving existing state lineage "ac150688-1724-4c02-9ded-8aae6718e098"
2016/11/14 12:14:22 [TRACE] Preserving existing state lineage "ac150688-1724-4c02-9ded-8aae6718e098"
2016/11/14 12:14:22 [TRACE] Graph after step *terraform.ConfigTransformerOld:
@dmaze
dmaze / codec_test.go
Created November 29, 2015 23:40
github.com/ugorji/go/codec decode issue with extension objects
// This file demonstrates an issue decoding nested extension objects.
// The actual extension is a simple wrapper for a Python tuple, which
// is implemented by wrapping a simple CBOR list with CBOR tag 128.
package main
import (
"github.com/ugorji/go/codec"
"reflect"
"testing"