Skip to content

Instantly share code, notes, and snippets.

View koblas's full-sized avatar

David Koblas koblas

View GitHub Profile
func natsToHTTP(msg jetstream.Msg) *http.Request {
hdrs := msg.Headers()
request := http.Request{
URL: &url.URL{
Scheme: "queue",
Path: hdrs.Get(jetURLPath),
},
Method: http.MethodPost,
Header: http.Header(hdrs),
Body: io.NopCloser(bytes.NewReader(msg.Data())),
@koblas
koblas / day23.go
Created December 23, 2022 14:23
Advent of Code 2022 Day 23 Solution
package main
import (
"bufio"
"image"
// "errors"
"fmt"
"os"
)
@koblas
koblas / generics.go
Created September 13, 2021 20:20
Sample Generic Summer
package main
import "fmt"
type Number interface {
type int, float32
}
func sum[T any, V Number](items []T, getvalue func(T) V) V {
var acc V
package resolver
import (
"reflect"
"strings"
"github.com/graphql-go/graphql"
"github.com/mitchellh/mapstructure"
"gopkg.in/asaskevich/govalidator.v4"
)
@koblas
koblas / login.ts
Created August 7, 2019 16:03
Login Typescript
export interface AuthTokenResponse {
token?: string;
created?: boolean;
user?: UserType;
errors?: ValidationError[];
}
// tslint:disable:no-multiline-string
const LOGIN_MUTATION = gql`
@koblas
koblas / fail.json
Created August 29, 2018 14:19
failing alexa response
{
"version": "1.0",
"sessionAttributes": {
"Counter": 1,
"QuizAnswer": "Jefferson City",
"QuizItemIndex": 24,
"QuizProperty": "Capital",
"QuizScore": 0,
"State": 1
},
func init() {
mutationConfig.AddFieldConfig("sentimentAnalysis", &graphql.Field{
Type: graphql.NewObject(graphql.ObjectConfig{
Name: "SentimentAnalysisResult",
Description: "Sentiment Analysis Response",
Fields: graphql.Fields{
"score": &graphql.Field{
Type: graphql.Int,
},
},
@koblas
koblas / user_update.go
Created August 3, 2018 14:33
User Update
package nresolver
import (
"context"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/model"
"github.com/koblas/projectx/server-go/pkg/service"
)
@koblas
koblas / schema.go
Created August 3, 2018 14:12
GraphQL Scheme base
package nresolver
import (
"github.com/graphql-go/graphql"
)
var queryConfig = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
// Must initialize to an empty set
Fields: graphql.Fields{},
@koblas
koblas / wrap_isauth.go
Created August 3, 2018 13:39
graphql authentication wrapper
package nresolver
import (
"errors"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/service"
)