Skip to content

Instantly share code, notes, and snippets.

View jeroneemou's full-sized avatar
🌱
I love plants

david.rosa jeroneemou

🌱
I love plants
View GitHub Profile
@jeroneemou
jeroneemou / test-performance.js
Created April 3, 2020 14:44
Testing performance
const getPerfs = () => {
let array = []
const start = (window.performance || Date).now()
for (let i = 0; i < 20000; i++) {
array = Math.pow(Math.sin(Math.random()), 2)
}
const end = (window.performance || Date).now()
return end - start
}
if (timing < 7) PERF = PERF_HIGH
@jeroneemou
jeroneemou / customer.php
Created September 24, 2019 10:47
Calculate Customer points
<?php
protected function calculateLoyaltyPoints($Loyalty_Points, $Loyalty_Participant): int
{
if (!isset($Loyalty_Points->SN_Loyalty_Points)) {
return 0;
}
if (!$Loyalty_Participant) {
return 0;
@jeroneemou
jeroneemou / health.php
Created June 4, 2019 16:30
Health check with memory monitoring of Elastic Beanstalk instance and push to CloudWatch (SDK v2)
<?php
namespace Curved\Health;
use Aws\CloudWatch\CloudWatchClient;
require __DIR__ . '/../vendor/autoload.php';
class HealthInfo
{
@jeroneemou
jeroneemou / backup_restore.sh
Created March 13, 2019 16:56
Backup and restore mysql docker container which has mounted volume for data
# Backup container of mysql
docker run --rm --volumes-from my-mysql-container -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/mysql
# Restore container of mysql
docker run --rm --volumes-from my-mysql-container -v $(pwd):/backup ubuntu bash -c "cd /var && tar xvf /backup/backup.tar --strip 1"
@jeroneemou
jeroneemou / basic.php
Created December 13, 2018 10:08
Get Basic Auth header
<?php
$username = "username";
$password = "password";
echo "Authorization: Basic " . base64_encode($username . ":" . $password);
@jeroneemou
jeroneemou / check_cert.sh
Last active October 9, 2018 14:46
Check details about website certificate from console
#!/bin/bash
if [ "$1" == "-h" ] || [ -z "$1" ]; then
echo "Usage: ./check_cert.sh domain.name"
exit 0
fi
echo "DONE" | openssl s_client -showcerts -connect $1:443
@jeroneemou
jeroneemou / caddy.service
Created April 4, 2018 12:50
/etc/systemd/system/caddy.service
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Restart=on-failure
User=www-data