Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View benbpyle's full-sized avatar

Benjamen Pyle benbpyle

View GitHub Profile
@benbpyle
benbpyle / company_fetch.go
Created February 25, 2023 15:06
Using BatchGetItem to fetch
func (d *DynamoDBCompanyRepository) GetCompanies(ctx context.Context, companyIds []string) ([]models.Company, error) {
var keys []map[string]*dynamodb.AttributeValue
for _, c := range companyIds {
key := models.GetCompanyKey(c)
m := map[string]*dynamodb.AttributeValue{
"PK": {
S: aws.String(key),
},
"SK": {
@benbpyle
benbpyle / aws_sns_cli.sh
Created February 19, 2023 16:31
AWS SNS CLI Commands
# List topics
aws sns list-topics
# Create topic
aws sns create-topic --name test-topic
# Subscribe
aws sns subscribe --topic-arn arn:aws:sns:us-west-2:123456789012:the-topic --protocol sqs --notification-endpoint http://some-queu-url
# List subscriptions
aws sns list-subscriptions
# Post a message to a Topic
aws sns publish --topic-arn arn:aws:sns:us-west-2:123456789012:topic --message "{\"event\":{\"type\":\"TeamUpdate\",\"id\":1,\"name\":\"New Team Name\"}}"
@benbpyle
benbpyle / user_role.go
Created February 1, 2023 19:30
UserRole go
type UserRole struct {
EntityType string `dynamodbav:"EntityType"`
Roles []Role `dynamodbav:"Roles"`
}
type Role struct {
Id int
Name string
}
@benbpyle
benbpyle / user_role.json
Last active February 1, 2023 19:29
Go unmarshal DynamoDB Map
{
"Roles": {
"1": {
"name": "Role number 1",
"id": 1
},
"2": {
"name": "Role number 2",
"id": 2
}
@benbpyle
benbpyle / logstash-tcp.conf
Created March 23, 2019 14:42
Logstash-TCP
input {
tcp {
port => "5000"
codec => json_lines
}
}
output {
stdout {}
}
@benbpyle
benbpyle / logback-tcp.xml
Created March 23, 2019 14:36
Logback-TCP
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%green(%d{yyyy-MM-dd HH:mm:ss}) %magenta([%thread]) %blue(%-5level) %yellow(%logger{36}) - %msg%n
</Pattern>
</layout>
</appender>
@benbpyle
benbpyle / logging-example.java
Created March 23, 2019 14:18
SLF4J logging example
package com.logging-example
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/logging-example")