Skip to content

Instantly share code, notes, and snippets.

View micahwalter's full-sized avatar
👋

Micah Walter micahwalter

👋
View GitHub Profile
var fathomSnippet = document.createElement('script');
fathomSnippet.defer = true;
fathomSnippet.setAttribute('data-site', '<your-site-code>');
fathomSnippet.src = 'https://cdn.usefathom.com/script.js';
document.head.appendChild(fathomSnippet);
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"time"
RebuildSiteWebhook:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: RebuildSiteWebhook
CodeUri: cmd/functions/rebuildSiteWebhook
Runtime: provided.al2
package main
import (
"fmt"
"net/http"
"os"
"github.com/aws/aws-lambda-go/lambda"
)
MyDB:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
- name: Build resources
run: |
curl -L https://go.dev/dl/go1.19.linux-arm64.tar.gz | sudo tar -zx -C /usr/local
PATH=$PATH:/usr/local/go/bin:/root/go/bin
GOPROXY=direct
sam build --template ${SAM_TEMPLATE}
env:
PIPELINE_USER_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
PIPELINE_USER_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SAM_TEMPLATE: template.yaml
TESTING_STACK_NAME: go-sam-pipe-dev
TESTING_PIPELINE_EXECUTION_ROLE: ${{ vars.TESTING_PIPELINE_EXECUTION_ROLE }}
TESTING_CLOUDFORMATION_EXECUTION_ROLE: ${{ vars.TESTING_CLOUDFORMATION_EXECUTION_ROLE }}
TESTING_ARTIFACTS_BUCKET: ${{ vars.TESTING_ARTIFACTS_BUCKET }}
TESTING_REGION: us-east-1
PROD_STACK_NAME: go-sam-pipe-prod
package main
import (
"fmt"
"time"
)
func longBlockingProcess(s string) {
fmt.Printf("Starting blocking process for %v\n", s)
time.Sleep(10 * time.Second)
stream := resp.GetStream().Reader
events := stream.Events()
var response bedrock.AnthropicResponse
for {
event := <-events
if event != nil {
if v, ok := event.(*types.ResponseStreamMemberChunk); ok {
// v has fields
resp, err := svc.InvokeModelWithResponseStream(context.TODO(), &bedrockruntime.InvokeModelWithResponseStreamInput{
Accept: &accept,
ModelId: &modelId,
ContentType: &contentType,
Body: []byte(string(payloadBody)),
})