Skip to content

Instantly share code, notes, and snippets.

@Swalloow
Swalloow / dynamo_delete_all.py
Created May 18, 2018
Boto3 DynamoDB delete all items
View dynamo_delete_all.py
import boto3
dynamodb = boto3.resource('dynamodb', 'region-name')
table = dynamodb.Table('table-name')
scan = table.scan(
ProjectionExpression='#k',
ExpressionAttributeNames={
'#k': 'name'
}
@mazfreelance
mazfreelance / JS: Calc business days Monday to Friday
Created Dec 26, 2017
Javascript : Calculate business days between two (2) dates, business days (Monday to Friday)
View JS: Calc business days Monday to Friday
function calculateBusinessDays(startDate, endDate){
// Validate input
if (endDate < startDate)
return 0;
// Calculate days between dates
var millisecondsPerDay = 86400 * 1000; // Day in milliseconds
startDate.setHours(0,0,0,1); // Start just after midnight
endDate.setHours(23,59,59,999); // End just before midnight
var diff = endDate - startDate; // Milliseconds between datetime objects
@singledigit
singledigit / cognito.yaml
Last active Nov 11, 2022
Create a Cognito Authentication Backend via CloudFormation
View cognito.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
@pahud
pahud / delete_all_awslogs.sh.md
Last active Sep 20, 2022
delete all aws log groups
View delete_all_awslogs.sh.md

specify the region

export AWS_DEFAULT_REGION=ap-northeast-1
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table | \
awk '{print $2}' | grep -v ^$ | while read x; do  echo "deleting $x" ; aws logs delete-log-group --log-group-name $x; done

only delete loggroup name starting with /aws/lambda

@soheilhy
soheilhy / nginxproxy.md
Last active Feb 3, 2023
How to proxy web apps using nginx?
View nginxproxy.md

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers