Skip to content

Instantly share code, notes, and snippets.

@lasekmiroslaw
lasekmiroslaw / rc.local
Last active May 8, 2020 06:25
Run script after rebot
```
sudo vim /etc/rc.d/rc.local
## paste script inside /\
# mount qnap after reboot
mount -t cifs //192.168.1.152/Backups /qnap -o username=admin,password=pass,vers=2.0
sudo chmod +x /etc/rc.d/rc.local
```
@lasekmiroslaw
lasekmiroslaw / backup-mysql.sh
Created May 4, 2020 11:20
mariabackup backup mariadb
#!/bin/bash
export LC_ALL=C
days_of_backups=2 # Must be less than 7
backup_owner="root"
parent_dir="/backups/mysql"
defaults_file="/etc/my.cnf.d/backup.cnf"
todays_dir="${parent_dir}/$(date +%a)"
log_file="${todays_dir}/backup-progress.log"
@lasekmiroslaw
lasekmiroslaw / backup-mysql.sh
Last active February 24, 2024 15:50
backup mysql percona-xtrabackup xtrabackup
#!/bin/bash
export LC_ALL=C
days_of_backups=2 # Must be less than 7
backup_owner="root"
parent_dir="/backups/mysql"
defaults_file="/etc/my.cnf.d/backup.cnf"
todays_dir="${parent_dir}/$(date +%a)"
log_file="${todays_dir}/backup-progress.log"
@lasekmiroslaw
lasekmiroslaw / delete.php
Created June 18, 2019 06:34
Delete old files command
<?php declare(strict_types=1);
namespace App\Command;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class DeleteOldFilesCommand extends Command
@lasekmiroslaw
lasekmiroslaw / supervisord
Last active November 26, 2019 09:06
supervisor
/etc/supervisord.d
#!/bin/sh
##
## /etc/rc.d/init.d/supervisord
##
## Supervisor is a client/server system that
## allows its users to monitor and control a
## number of processes on UNIX-like operating
## systems.
@lasekmiroslaw
lasekmiroslaw / composer.txt
Last active August 25, 2018 17:46
composer versions and Constraints, update #composer
https://getcomposer.org/doc/articles/versions.md#writing-version-constraints
1.0 - 2.0 is equivalent to >=1.0.0 <2.1
~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0
^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.
pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0
1.2.3 =1.2.3.0-stable
>1.2 >1.2.0.0-stable
@lasekmiroslaw
lasekmiroslaw / files.php
Created July 26, 2018 15:53
php working with files
IMAGES :
<?php<?php
trytry { {
//// Create a new SimpleImage object Create
$image = new \claviska\SimpleImage();
// Magic! ✨
$image
->fromFile('image.jpg') // load image.jpg
@lasekmiroslaw
lasekmiroslaw / datetime.sql
Created July 24, 2018 19:55
mysql course
create column auto update timestamp:
CREATE TABLE comments2 (
content VARCHAR(100),
changed_at TIMESTAMP DEFAULT NOW() ON UPDATE CURRENT_TIMESTAMP
);
Date Math:
SELECT birthdt, birthdt + INTERVAL 15 MONTH + INTERVAL 10 HOUR FROM people;
Date Format
@lasekmiroslaw
lasekmiroslaw / gist:e79bb36a9aa7bb1d8f7ad60698496a7a
Last active June 23, 2019 10:13
linux useful bash alias command
cerate your bash aliases
gedit ~/.bashrc
update it
source ~/.bashrc
# docker-compose
alias dcu='docker-compose up --d'
alias dcub='docker-compose up --build'
alias dcd='docker-compose down'
alias dcb='docker-compose build'
@lasekmiroslaw
lasekmiroslaw / gist:d0298fec67813b0559f3b1f00ee58482
Last active July 24, 2018 19:58
password hash eventlistener symfony doctrine
<?php
namespace App\EventListener;
use Doctrine\ORM\Event\LifecycleEventArgs;
use App\Entity\User;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class PasswordHashListener
{
private $passwordEncoder;
public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{