Skip to content

Instantly share code, notes, and snippets.

View lovemycodesnippets's full-sized avatar

The New Stack lovemycodesnippets

View GitHub Profile
@lovemycodesnippets
lovemycodesnippets / install-sdk.sh
Created February 27, 2025 19:51
From the article "How To Instrument a React Native App To Send OTel Signals"
npm install @embrace-io/react-native @embrace-io/react-native-otlp
@lovemycodesnippets
lovemycodesnippets / install.sh
Created February 27, 2025 19:43
From the article "How To Instrument a React Native App To Send OTel Signals"
npx @react-native-community/cli init Walkthrough
cd Walkthrough/ios
bundle install
bundle exec pod install
cd ..
npx react-native run-ios
@lovemycodesnippets
lovemycodesnippets / terraform-output.hcl
Created February 13, 2025 19:34
From the article "Can AI Generate Functional Terraform?"
resource "aws_s3_bucket" "notes" {
bucket = "${var.bucket_name}-${random_id.bucket_id.hex}"
}
resource "aws_lambda_function" "handler" {
function_name = "${var.service_name}-${var.stack_id}"
role = aws_iam_role.role.arn
image_uri = "${aws_ecr_repository.repo.repository_url}@${docker_registry_image.push.sha256_digest}"
package_type = "Image"
timeout = var.timeout
@lovemycodesnippets
lovemycodesnippets / application-code.py
Created February 13, 2025 19:33
From the article "Can AI Generate Functional Terraform?"
from nitric.application import Nitric
from nitric.resources import api, bucket
from nitric.context import HttpContext
main = api("main")
notes = bucket("notes").allow("read", "write")
@main.get("/notes/:title")
async def get_note(ctx: HttpContext):
title = ctx.req.params["title"]
@lovemycodesnippets
lovemycodesnippets / function-bucket.hcl
Created February 13, 2025 19:32
From the article "Can AI Generate Functional Terraform?"
resource "aws_s3_bucket" "notes" {
bucket = "notes-bucket"
}
resource "aws_lambda_function" "handler" {
function_name = "notes_handler"
runtime = "python3.9"
handler = "handler.lambda_handler"
role = aws_iam_role.lambda_exec.arn
source_code_hash = filebase64sha256("lambda.zip")
@lovemycodesnippets
lovemycodesnippets / add-iam-hcl
Created February 13, 2025 19:28
From the article "Can AI Generate Functional Terraform?"
resource "aws_iam_policy" "lambda_s3" {
name = "lambda_s3_policy"
policy = jsonencode({
Version = "2012-10-17",
Statement = [{
Effect = "Allow",
Action = ["s3:GetObject", "s3:PutObject"],
Resource = "${aws_s3_bucket.example.arn}/*"
}]
})
@lovemycodesnippets
lovemycodesnippets / process-uploaded-objects.hcl
Created February 13, 2025 19:27
From the article "Can AI Generate Functional Terraform?"
resource "aws_s3_bucket" "example" {
bucket = "example-bucket"
}
resource "aws_lambda_function" "example" {
function_name = "example_lambda"
s3_bucket = aws_s3_bucket.example.bucket
s3_key = "lambda_function.zip"
handler = "index.handler"
runtime = "python3.8"
@lovemycodesnippets
lovemycodesnippets / gist:6f79757a5fa5f067f7a1d107df198978
Created February 10, 2025 15:05
Example: OpenAPI Overlay adds a license to an OpenAPI description:
overlay: 1.0.0
info:
title: Add MIT license
version: 1.0.0
actions:
- target: '$.info'
update:
license:
name: MIT
url: https://opensource.org/licenses/MIT
@lovemycodesnippets
lovemycodesnippets / Result.vue
Created February 7, 2025 17:52
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const props = defineProps({
results: Array,
totalCorrect: Number,
questionsAnswered: Number,
});
const resultIndex = computed(() => {
let index = 0;
props.results.findIndex((e, i) => {
@lovemycodesnippets
lovemycodesnippets / index.vue
Created February 7, 2025 17:51
From the article "Building a Quiz App with Nuxt and Xata"
<template>
<main>
<div class="ctr">
<Result
v-else
:results="results"
:totalCorrect="totalCorrect"