Skip to content

Instantly share code, notes, and snippets.

View lintaonz's full-sized avatar

Tao L lintaonz

  • New Zealand
View GitHub Profile
@mbonig
mbonig / LogicalIdMapper.ts
Created October 10, 2022 01:35
An AWS CDK LogicalId remapper aspect
import { CfnElement, CfnResource, IAspect, Stack } from 'aws-cdk-lib';
import { IConstruct } from 'constructs';
export interface IdMap {
[key: string]: string;
}
export class LogicalIdMapper implements IAspect {
constructor(private idMap: IdMap) {
}
@avendasora
avendasora / form-to-dynamodb-json.template
Last active September 20, 2022 05:00
AWS API Gateway body mapping template to convert "application/x-www-form-urlencoded" into "application/json" for DynamoDB
#set ($keyValues = {})
#set($prarametersString = $input.body)
#set($parameters = $prarametersString.split("&"))
#foreach($parameter in $parameters)
#set($keyValue = $parameter.split("="))
$keyValues.put($util.urlDecode($keyValue[0]),$util.urlDecode($keyValue[1]))
#end
{
"TableName": "table_name",
"Item": {
@keeth
keeth / api.tf
Last active January 13, 2021 14:34
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
resource "aws_api_gateway_rest_api" "myApi" {
name = "myApi-${var.env}"
description = "My awesome API (${var.env} environment)"
}
resource "aws_api_gateway_deployment" "myApi" {
depends_on = [
"aws_api_gateway_integration.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post_400",
@maxclaus
maxclaus / curl-get-status-code-and-response-body.sh
Created November 24, 2015 17:52
Curl - Get status code and response body
URL="http://stackoverflow.com/"
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $URL)
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
@emiller
emiller / git-mv-with-history
Last active January 11, 2026 20:22
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@technoweenie
technoweenie / gist:1072829
Created July 8, 2011 21:12
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET