Skip to content

Instantly share code, notes, and snippets.

View andela-sjames's full-sized avatar
😎
gentlefella

samuelvarejames andela-sjames

😎
gentlefella
  • Dixa
  • Berlin, Germany
  • 00:34 (UTC +02:00)
View GitHub Profile
// StartConsumerHandler defined
func StartConsumerHandler(w http.ResponseWriter, r *http.Request) {
// to consume messages
// make a new reader that consumes from sampleOne
fmt.Println("Consumer started")
go func() {
reader := kafka.NewReader(kafka.ReaderConfig{
Brokers: []string{"broker:9092", "broker:9093", "broker:9093"},
GroupID: "consumer-Sample-One",
Topic: "sampleOne",
@andela-sjames
andela-sjames / sample-docker-compose.ecs.yml
Created August 23, 2019 14:48
Auto generated docker-compose.ecs.yml file for rainbowtext blog
services:
nginx:
container_name: rainbowtext_proxy
depends_on:
- server
image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/rainbowtext_nginx
logging:
driver: awslogs
options:
awslogs-group: rainbowtext
"""Script defined to create helper functions for graphql schema."""
from graphql_relay.node.node import from_global_id
def get_object(object_name, relayId, otherwise=None):
try:
return object_name.objects.get(pk=from_global_id(relayId)[1])
except:
return otherwise
class CreateBook(relay.ClientIDMutation):
class Input:
# BookCreateInput class used as argument here.
book = graphene.Argument(BookCreateInput)
new_book = graphene.Field(BookNode)
@classmethod
def mutate_and_get_payload(cls, args, context, info):
from graphene_django.views import GraphQLView
urlpatterns = [
...
url(r'^graphql', GraphQLView.as_view(graphiql=True)),
]
INSTALLED_APPS = [
...
'graphene_django',
]
GRAPHENE = {
'SCHEMA': 'bookmeapi.schema.schema', # Where your Graphene schema lives
'MIDDLEWARE': (
'graphene_django.debug.DjangoDebugMiddleware',
)
@andela-sjames
andela-sjames / 1_simple.go
Created July 17, 2017 20:35 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
def pigLatin(word):
"""
Translate a single lowercase word to pig Latin.
if w begins with a consonant,
move the leading consonant to the end of the word
add 'ay' as a suffix
if w begins with a vowel,
add 'yay' as a suffix
def is_consonant(char):
return char not in "aeiouAEIOU"
def pigLatin(word):
"""
Translate a single lowercase word to pig Latin.
if w begins with a consonant,