Skip to content

Instantly share code, notes, and snippets.

View koblas's full-sized avatar

David Koblas koblas

View GitHub Profile
@koblas
koblas / echo.cxx
Created August 15, 2012 22:46
libev c++ echo server
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <ev++.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <resolv.h>
#include <errno.h>
#include <list>
@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 / trie.py
Created June 4, 2012 18:40
Simple Priority Trie implementation in Python
class trie(object):
MAX_SUGGEST = 10
__slots__ = ('children', 'freq', 'name', '_top')
def __init__(self):
self.children = defaultdict(trie)
self.freq = 0
self.name = None
self._top = None
@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
@koblas
koblas / smtp.py
Created November 11, 2011 15:23
SMTP Client for Tornado
from tornado import ioloop
from tornado import iostream
import socket
class Envelope(object):
def __init__(self, sender, rcpt, body, callback):
self.sender = sender
self.rcpt = rcpt[:]
self.body = body
self.callback = callback
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"
)