Skip to content

Instantly share code, notes, and snippets.

View mrbitsdcf's full-sized avatar

MrBiTs mrbitsdcf

View GitHub Profile
@mrbitsdcf
mrbitsdcf / kms.tf
Created March 15, 2023 14:14
Snipet Terraform for KMS
resource "aws_kms_key" "kms_key" {
deletion_window_in_days = var.deletion_window_in_days
enable_key_rotation = var.enable_key_rotation
key_usage = var.key_usage
customer_master_key_spec = var.customer_master_key_spec
multi_region = var.multi_region
is_enabled = var.is_enabled
tags = var.vpc_tags
policy = <<POLICY
{
@mrbitsdcf
mrbitsdcf / export.py
Created January 7, 2023 18:00 — forked from ngnmtl/export.py
Export / import AWS dynamodb table from json file with correct data types using python
from __future__ import print_function # Python 2/3 compatibility
import json
import boto3
# AWS_ACCESS = ""
# AWS_SECRET = ""
AWS_REGION = "eu-west-3"
TABLE_NAME = "users"
client = boto3.client(
@mrbitsdcf
mrbitsdcf / ddb_export_import.sh
Last active December 29, 2022 12:01
Dump schema and use it to create AWS DynamoDB tables from one account to another
#!/bin/bash
for TBL in $(aws dynamodb list-tables --profile ABC --query "TableNames[]" --output text) ; do
echo "Doing $TBL"
aws dynamodb describe-table --table-name $TBL --profile ABC > ${TBL}.json
BILLINGMODE=$(grep -e '.*BillingMode"' ${TBL}.json | tr -d " ")
jq < ${TBL}.json ".Table | {TableName, KeySchema, AttributeDefinitions} + (try {LocalSecondaryIndexes: [ .LocalSecondaryIndexes[] | {IndexName, KeySchema, Projection} ]} // {}) + (try {GlobalSecondaryIndexes: [ .GlobalSecondaryIndexes[] | {IndexName, KeySchema, Projection} ]} // {}) + { ${BILLINGMODE} }" > create_${TBL}.json
@mrbitsdcf
mrbitsdcf / test_ses.sh
Created June 9, 2022 11:09
Test AWS SES connection
#!/bin/bash
USER=$(echo -n $1 | base64)
PASS=$(echo -n $2 | base64)
# Connect to AWS SES
openssl s_client -crlf -quiet -connect email-smtp.us-east-1.amazonaws.com:465
openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.us-east-1.amazonaws.com:25
# SMTP commands
@mrbitsdcf
mrbitsdcf / take_pics_kili.ssc
Created November 23, 2019 21:31
Save Stellarium screenshots from a given location and time
core.wait(3);
core.setDate("2010:07:14T17:16:00", "Africa/Tunis");
core.setObserverLocation(37.352013, -3.065653, 5895, 1, "Mt. Kilimanjaro, Tunisia", "Earth");
for (i=0; i<=360; i++)
{
core.setDate("+60 seconds");
core.wait(.1);
core.screenshot("kili_");
}
# CONSTANTES
G = 6.67408 * 10**(-11) # Constante Universal de Gravitação
M = 5.972 * 10**(24) # Massa da Terra
# ----------------------------------------------------------------------------------------------------------------------------
# VARIÁVEIS
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Distances on Globe and Flat Earth
# Instructions:
# - Input each information as asked;
# - Input coordinates in degrees (23.1234);
# - If coordinates are at South or West, use negative numbers (-23.1234);
# - North Pole to Equator based on a Flat Earth with 40.075km equatorial perimeter.
# Earth radius = 6371km rounded, so little diferences are expected if you're considering WGS84 geoid.
FROM node:boron-alpine
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY . /app
#!/usr/bin/env python
import os
u = open('users.txt', 'r')
for user in u.readlines():
user = user[:-1]
path = '/data/users/{0}/'.format(user)
tmp = os.path.isdir(path)
@mrbitsdcf
mrbitsdcf / one_way_cypher.py
Created February 20, 2015 10:59
One way cypher
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#
# implements simple one-way encryption pipe using rsa and keccak-based
# spongewrap
#
# useful at least in the following use-case: you have an untrusted
# host on which plaintext data arrives, which you want to encrypt
# before it is forwarded in a hostile environment to the final
# recipient holding a private key in a safe location. In this one-way