Skip to content

Instantly share code, notes, and snippets.

View bensie's full-sized avatar

James Miller bensie

View GitHub Profile
@jjb
jjb / file.md
Last active May 9, 2024 06:26
Using Jemalloc 5 with Ruby.md

For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.

Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.

Ubuntu/Debian

FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
@thomashartm
thomashartm / aws-sam-colima.md
Last active May 7, 2024 21:58
Enable AWS SAM local to run without Docker Desktop but Colima + Docker Daemon on MacOs

AWS SAM local commands without Docker Desktop

AWS SAM local commands check for the existance of DOCKER_HOST. If the variable is not present, it will fail with the following error message

Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?

Replace it with Colima

Point DOCKER_HOST to unix socket of the Docker Daemon.

@schacon
schacon / docker-compose.yml
Created August 15, 2021 19:15
Docker Compose file for ruby, postgres and redis
version: '3'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: 2.6
NODE_VERSION: "lts/*"
volumes:
@rts-rob
rts-rob / main.go
Last active March 17, 2020 21:50
Setting DynamoDB timeout to 100ms
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"time"
"github.com/aws/aws-lambda-go/events"
# An example of calculating least-squares linear regression fit in Ruby
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
@maatthc
maatthc / aws-websockets-api-gw-mock.yaml
Last active April 30, 2024 18:13
Basic WebSocket mock in AWS ApiGateway using CloudFormation in AWS
AWSTemplateFormatVersion: '2010-09-09'
Description: |
AWS CloudFormation template for Mock WebSocket API Gateway. When deploying this stack please remember to check the option:
- I acknowledge that AWS CloudFormation might create IAM resources.
This template can help you to solve issues like:
- CloudWatch Logs role ARN must be set in account settings to enable logging
- Execution failed due to configuration error: statusCode should be an integer which defined in request template
- This custom domain name cannot map to WEBSOCKET protocol APIs
- Error during WebSocket handshake: Unexpected response code: 500
@cgoering
cgoering / template.yaml
Created April 26, 2019 18:28
AWS Lambda memory usage metric in CloudFormation
CustomMetric:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Sub /aws/lambda/${AWS::StackName}
FilterPattern: '[str="REPORT", ..., str="Max", str="Memory", str="Used:", MaxMemoryUsed, str="MB"]'
MetricTransformations:
- MetricNamespace: Organization/Project/Service
MetricName: MaxMemoryUsed
MetricValue: $MaxMemoryUsed
@adrianhall
adrianhall / AppSync-Example.yaml
Created April 13, 2018 16:01
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@carelvwyk
carelvwyk / email.go
Created February 22, 2018 12:40
Building an email in Golang to be delivered using Amazon SES
func buildEmailInput(source, destination, subject, message string,
csvFile []byte) (*ses.SendRawEmailInput, error) {
buf := new(bytes.Buffer)
writer := multipart.NewWriter(buf)
// email main header:
h := make(textproto.MIMEHeader)
h.Set("From", source)
@jed
jed / deploy.sh
Last active April 24, 2024 15:45
Using AWS CloudFormation to deploy an edge lambda
#!/bin/sh
aws cloudformation deploy \
--template-file stack.yaml \
--stack-name edge-lambda-test \
--capabilities CAPABILITY_IAM \
--parameter-overrides Nonce=$RANDOM