Skip to content

Instantly share code, notes, and snippets.

View Alex-Just's full-sized avatar

AlekseiK Alex-Just

  • Europe
View GitHub Profile
"""
The script fetches and prints the average CPU utilization for a given AWS RDS instance ID for the past specified months
"""
from datetime import datetime, timedelta
import boto3
# Configuration
INSTANCE_ID = '...'
"""
This script retrieves and displays the top five AWS service costs for each of the past six months.
It uses the AWS Cost Explorer API through the AWS CLI to fetch cost data, then processes and
sorts this data to find the most significant service costs. The costs are displayed in USD format,
showing the service name and the incurred cost over each month's period.
Note: AWS CLI must be configured with the appropriate permissions for this script to run successfully.
Sample output:
@Alex-Just
Alex-Just / strip_emoji.py
Last active June 29, 2023 18:12
Python regex to strip emoji from a string
import re
# http://stackoverflow.com/a/13752628/6762004
RE_EMOJI = re.compile('[\U00010000-\U0010ffff]', flags=re.UNICODE)
def strip_emoji(text):
return RE_EMOJI.sub(r'', text)
print(strip_emoji('🙄🤔'))
@Alex-Just
Alex-Just / simple_encrypt_decrypt.py
Last active June 8, 2022 14:57
Simple encrypt/decrypt algorithm (Vigenere cipher)
#!/usr/bin/env python3
import base64
"""
Simple obfuscation that will obscure things from the very casual observer.
It is one of the strongest of the simple ancient ciphers.
https://en.wikipedia.org/wiki/Vigenère_cipher
"""
@Alex-Just
Alex-Just / Main.sublime-menu
Last active September 9, 2021 14:04
Sublime Text plugin "Count Duplicates". Adds command in the Edit main menu that counts number of duplicate rows in a file and prints it in the first left column.
[
{
"id": "edit",
"children":
[
{ "command": "count_duplicates" }
]
}
]
cd /tmp
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/lib
export PATH=/usr/bin:$PATH
export LDFLAGS=-L/usr/lib64:/usr/lib
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib:/usr/local/lib/
export CPPFLAGS=-I/usr/include
sudo yum groupinstall "Development Tools" -y
sudo yum install pango-devel.x86_64 giflib-devel libjpeg-devel cairo-devel cairo-gobject-devel libXi-devel cups-libs dbus-glib libXrandr libXcursor libXinerama libXt.{i686,x86_64} -y
# Get all keys from the DB
redis-cli -n 8 --scan
# Get all keys and values from the DB
echo 'keys *' | redis-cli -n 8 | sed 's/^/get \"/' | sed 's/$/\" /' | redis-cli -n 8 | jq .
AWS_ACCESS_KEY_ID=X AWS_SECRET_ACCESS_KEY=X aws dynamodb list-tables --endpoint-url http://localhost:8000 --region x
AWS_ACCESS_KEY_ID=X AWS_SECRET_ACCESS_KEY=X aws dynamodb scan --table-name smpl_auth --endpoint-url http://localhost:8000 --region x
@Alex-Just
Alex-Just / bash.sh
Last active November 11, 2019 16:38
Bash programming
# Infinite Loop
while true; do echo 'Hit CTRL+C'; sleep 1; done
# Video to GIF
ffmpeg -i video.mov -ss 00:00:00.000 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 > video.gif
# find by name
find . -name 'MYTEXT*'
# find text in files
grep -r "MYTEXT" .
# find dir by name
find . -name "MYTEXT" -type d
# free space