Skip to content

Instantly share code, notes, and snippets.

View Dzhuneyt's full-sized avatar
🔥
Putting out fires in software projects and infrastructure

Dzhuneyt Dzhuneyt

🔥
Putting out fires in software projects and infrastructure
View GitHub Profile
@Dzhuneyt
Dzhuneyt / shelly_auto_reboot_script.js
Created November 12, 2023 10:46
Shelly Auto Reboot if no Internet Connection
let CONFIG = {
endpoints: [
"https://global.gcping.com/ping",
"https://us-central1-5tkroniexa-uc.a.run.app/ping",
],
//number of failures that trigger the reset
numberOfFails: 5,
//time in seconds after which the http request is considered failed
httpTimeout: 10,
//time in seconds for the relay to be off
@Dzhuneyt
Dzhuneyt / dynamodb-recursive-scan.ts
Created June 21, 2022 07:28
(TypeScript) Recursively scan a DynamoDB table until all documents are returned
import {DynamoDB} from 'aws-sdk';
import {Key} from 'aws-sdk/clients/dynamodb';
async function dynamodbRecursiveScan(tableName: string, startFromKey?: Key) {
const results: DynamoDB.ItemList = [];
const dynamodb = new DynamoDB();
const items = await dynamodb
.scan({
TableName: tableName,
@Dzhuneyt
Dzhuneyt / delete-all-stripe-customers.js
Last active June 1, 2022 14:37
Delete all Customers in a Stripe account - through the Stripe SDK for JS
import {Stripe} from 'stripe';
const STRIPE_API_KEY = process.env.STRIPE_API_KEY;
const s = new Stripe(STRIPE_API_KEY, {
apiVersion: "2020-08-27",
});
const deletePage = async () => {
const customers = await s.customers.list();
@Dzhuneyt
Dzhuneyt / cleanup-s3-buckets-detached-from-cloudformation-stacks.ts
Created October 12, 2020 18:41
A CLI script to cleanup S3 buckets that are detached from any CloudFormation stacks
import S3 = require("aws-sdk/clients/s3");
import CloudFormation = require("aws-sdk/clients/cloudformation");
import {StackResourceSummaries, StackSummaries} from "aws-sdk/clients/cloudformation";
import {ObjectVersion} from "aws-sdk/clients/s3";
const s3 = new S3();
const cf = new CloudFormation();
export const emptyBucket = async (bucketName: string) => {
// delete bucket contents
@Dzhuneyt
Dzhuneyt / wordpress-ecs-fargate-with-efs-and-aurora.ts
Created January 13, 2021 15:34 — forked from phillippbertram/wordpress-ecs-fargate-with-efs-and-aurora.ts
Example of a production ready, high available containerized wordpress aws infrastructure using AWS-Fargate, AWS-Aurora, EFS via aws-cdk
/*
* Copyright (c) 2020 Phillipp Bertram
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH T
@Dzhuneyt
Dzhuneyt / Cognito.ts
Created December 10, 2020 09:38
Create a Cognito User Pool and the first user, programmatically, using AWS CDK and Custom Resources
import {UserPool} from '@aws-cdk/aws-cognito';
import {Construct, Duration} from '@aws-cdk/core';
import {AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId} from '@aws-cdk/custom-resources';
export class Cognito extends Construct {
public userPool: UserPool;
constructor(scope: Construct, id: string) {
super(scope, id);
@Dzhuneyt
Dzhuneyt / README.md
Created May 3, 2020 10:25
Webpack configuration that allows bundling and compyling TypeScript files into JavaScript files. Useful for AWS Lambda deployment

Requirements:

npm i webpack webpack-cli ts-loader aws-sdk @types/node

@Dzhuneyt
Dzhuneyt / docker-stack-logs-tail.sh
Created January 5, 2020 16:01
Tail log of a Docker Swarm stack
#!/bin/bash -e
stack=$1
if [ -z "${stack}" ]; then
echo 'Usage:'
echo "$0 <stack>"
exit 1
fi
# Get a list of the service names
services=$(docker stack services --format {{.Name}} ${stack})
# Sort the service names
@Dzhuneyt
Dzhuneyt / docker-shell.sh
Created September 1, 2019 12:14 — forked from falvarez/docker-shell.sh
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp DOCKER_IMAGE /bin/bash
docker stack deploy -c <(docker-compose config) stack-name-here