Skip to content

Instantly share code, notes, and snippets.

View phainamikaze's full-sized avatar

Witsanu Boonamakam phainamikaze

View GitHub Profile
@phainamikaze
phainamikaze / dockerlog.md
Created July 15, 2024 09:12
docker log limit

docker log limit

method 1 -> docker run example

docker run -d \
  --log-driver json-file \
  --log-opt max-size=5k \
  --log-opt max-file=10 \
 chentex/random-logger:latest
@phainamikaze
phainamikaze / macOS
Created June 30, 2024 05:15
Recover DB password stored in my DBeaver connection
openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in "${HOME}/Library/DBeaverData/workspace6/General/.dbeaver/credentials-config.json" | dd bs=1 skip=16 2>/dev/null
@phainamikaze
phainamikaze / xfs_growfs command
Created June 12, 2024 06:42
sudo xfs_growfs /dev/nvme0n1p1
1
Below worked for me in AWS CENTOS 🦊 - Amazon Linux 2 AMIS( Karoo)
Step 1 : Update the EBS volume from AWS console of attached EC2
Step 2 : Login( SSH ) to EC2 instance in which the volume is attached
@phainamikaze
phainamikaze / lightsail-backup.js
Last active May 23, 2024 11:37
lightsail-backup
const AWS = require('aws-sdk');
exports.handler = async (event, context) => {
console.log(JSON.stringify(event))
// ================================
// Define your backups
// ================================
const instanceName = event.instanceName || process.env['instanceName'];
const backupDaysMax = event.days || process.env['days']; // keep at least 7 daily backups
@phainamikaze
phainamikaze / policy1.json
Last active December 8, 2023 10:04
Challenge Lab: Amazon S3
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": [
"arn:aws:s3:::<bucket-name>/file1.txt",
"arn:aws:s3:::<bucket-name>/file2.txt"
import json
import urllib.parse
import boto3
import os
print('Loading function')
s3 = boto3.client('s3')
TOPIC_ARN = os.environ['topicARN']
def lambda_handler(event, context):
@phainamikaze
phainamikaze / EC2 Instance Connect session
Created November 27, 2023 12:23
EC2 Instance Connect session lab 171
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
#Set the Region
AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone -H "X-aws-ec2-metadata-token: $TOKEN"`
export AWS_DEFAULT_REGION=${AZ::-1}
echo $AWS_DEFAULT_REGION
#Retrieve latest Linux AMI
AMI=$(aws ssm get-parameters --names /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 --query 'Parameters[0].[Value]' --output text)
echo $AMI
create database aws;
use aws;
CREATE TABLE RESTART (
StudentID int not null AUTO_INCREMENT,
StudentName varchar(255),
RestartCity varchar(255),
GraduationDate Datetime,
PRIMARY KEY (StudentID)
);
@phainamikaze
phainamikaze / query.sql
Created November 15, 2023 06:20
Write a query to rank the countries in each region by their population from largest to smallest.
SELECT Region, Name, Population, RANK() over(partition by region ORDER BY population desc) as 'Ranked' FROM world.country ;
def isPrime(num):
flag = False
if num == 1:
return False
elif num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True