2024 m. sausio 9 d., antradienis

clodflare email worker webook

export default {
async email(message, env, ctx) {
console.log(message.plainBody);
const webhookUrl = 'https://yoururl.com';
const webhookPayload = JSON.stringify({
subject: message.headers.get('subject'),
from: message.from,
to: message.to,
body: message.content
});
try {
const response = await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: webhookPayload,
});
} catch (error) {
console.error('Error sending webhook request:', error);
}
}
}

2023 m. lapkričio 22 d., trečiadienis

mysql top slowest queries by permormance schema

SELECT 

    schema_name, 

    digest_text AS query, 

    COUNT_STAR AS executions, 

    SUM_TIMER_WAIT / 1000000000000 AS total_seconds,

    AVG_TIMER_WAIT / 1000000000000 AS average_seconds,

    MAX_TIMER_WAIT / 1000000000000 AS max_seconds

FROM 

    performance_schema.events_statements_summary_by_digest

WHERE 

    schema_name IS NOT NULL

ORDER BY 

    total_seconds DESC

LIMIT 10;

2023 m. lapkričio 19 d., sekmadienis

mysql memory usage analysis

 SELECT SUBSTRING_INDEX(event_name,'/',2) AS

       code_area, FORMAT_BYTES(SUM(current_alloc))
       AS current_alloc
       FROM sys.x$memory_global_by_current_bytes
       GROUP BY SUBSTRING_INDEX(event_name,'/',2)
       ORDER BY SUM(current_alloc) DESC
code_areacurrent_alloc
memory/innodb4.65 GiB
memory/performance_schema232.48 MiB
memory/sql80.08 MiB
memory/mysys33.07 MiB
memory/temptable2.00 MiB
memory/myisam1.41 MiB
memory/mysqld_openssl152.04 KiB
memory/csv49.84 KiB
memory/blackhole 88 bytes
memory/vio 8 bytes
SELECT CONCAT(FORMAT(A.num * 100.0 / B.num,2),'%') `BufferPool %` FROM
    (SELECT variable_value num FROM performance_schema.global_status
    WHERE variable_name = 'Innodb_buffer_pool_pages_data') A,
    (SELECT variable_value num FROM performance_schema.global_status
    WHERE variable_name = 'Innodb_buffer_pool_pages_total') B
BufferPool %
91.72%

select format_bytes(sum(current_alloc)) from sys.x$memory_global_by_current_bytes;

2023 m. spalio 26 d., ketvirtadienis

mysql block from remote except localhost

sudo iptables -A INPUT -i lo -p tcp --dport 3306 -j ACCEPT

sudo iptables -A INPUT -p tcp --dport 3306 -j DROP 

2023 m. kovo 17 d., penktadienis

komanda, matyti iš kurių IP buvo prisijungta prie ssh

 grep "sshd.*Accepted" /var/log/auth.log | awk '{print $11}' | sort | uniq

 grep "sshd.*Accepted" /var/log/secure | awk '{print $11}' | sort | uniq


2023 m. vasario 7 d., antradienis

php kodas, tikrinantis įmonės registracijos numerį

function validateCompanyRegistrationNumber($number) { if (strlen($number) != 9) { return false; } $weights = [1, 2, 3, 4, 5, 6, 7, 8]; $sum = 0; for ($i = 0; $i < 8; $i++) { $sum += $weights[$i] * (int) $number[$i]; } $checkDigit = $sum % 11; if ($checkDigit == 10) { $checkDigit = 0; } return $checkDigit == (int) $number[8]; } $number = "123456789"; if (validateCompanyRegistrationNumber($number)) { echo "$number is valid."; } else { echo "$number is not valid."

}