Skip to content

Instantly share code, notes, and snippets.

View michalkortas's full-sized avatar
:octocat:
Working hard

Michal Kortas michalkortas

:octocat:
Working hard
View GitHub Profile
@michalkortas
michalkortas / gist:12adafb5404bd3a5b5831119d7bd9b17
Last active August 31, 2023 06:59
plesk laravel + vite deploy actions
/opt/plesk/php/8.2/bin/php artisan down
/opt/plesk/php/8.2/bin/php /usr/lib64/plesk-9.0/composer.phar install --no-interaction --no-dev
/opt/plesk/php/8.2/bin/php artisan migrate --force
/opt/plesk/php/8.2/bin/php artisan db:seed --force
export PATH=$PATH:/opt/plesk/node/16/bin/
/opt/plesk/node/16/bin/npm install &> npm_install.log
/opt/plesk/node/16/bin/npm run build &> npm_build.log
/opt/plesk/php/8.2/bin/php artisan optimize:clear
/opt/plesk/php/8.2/bin/php artisan view:cache
/opt/plesk/php/8.2/bin/php artisan route:cache
@michalkortas
michalkortas / migrate Laravel project to Docker
Last active November 16, 2021 08:26
migrate Laravel project to Docker
##### GIT clone
git clone project from github
##### update .env to:
APP_URL=http://localhost
APP_SERVICE="image.name"
APP_PORT=80
FORWARD_DB_PORT=3306
@michalkortas
michalkortas / slow network connection on WLS2
Last active October 15, 2021 10:03
slow network connection on WLS2
Run this commands on your WSL
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf
@michalkortas
michalkortas / mc midnight commander current dir on exit
Last active October 15, 2021 10:03
mc midnight commander current dir on exit
Put this line into your ~/.profile
alias mc='source /usr/lib/mc/mc-wrapper.sh'
@michalkortas
michalkortas / index.htm
Created December 10, 2020 07:53 — forked from bennadel/index.htm
Checking To See If An Element Has A CSS Pseudo-Class In JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>
Checking To See If An Element Has A CSS Pseudo-Class In JavaScript
</title>
<link rel="stylesheet" type="text/css" href="./demo.css" />
</head>
@michalkortas
michalkortas / deploy.sh
Created December 28, 2019 20:23 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd /home/forge/domain.com
# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master
@michalkortas
michalkortas / sql-delete-table-with-references.sql
Created December 23, 2019 09:01
delete from table with references
delete from files
where files.file_id
in (
select file_id from (select * from files) as removed_files left join addresses on removed_files.addresses_id = addresses.id
where addresses.id is null
)
@michalkortas
michalkortas / download-file-non-ascii-chars-laravel.php
Created December 19, 2019 10:22
The filename fallback must only contain ASCII characters.
<?php
$file = Storage::disk('my_storage_name')->get($originalFileName);
$response = response($file)
->withHeaders([
'Content-type' => 'application/force-download',
'Content-Transfer-Encoding' => 'Binary',
'Content-Disposition' => 'attachment;filename='.$newFileNameWithNonAsciiChars,
]);
return $response;
@michalkortas
michalkortas / convert-any-string-to-utf-8.php
Created December 12, 2019 17:20
Convert any (probably) string to UTF-8
<?php
iconv(mb_detect_encoding($string, mb_detect_order(), true), "UTF-8", $string);
?>
$data = array(
'projectNo'=>$manager->projectDetails->project_no,
'customerName'=>$manager->projectDetails->customer_name,
'projectId'=>$manager->projectDetails->project_id,
'projectAddress'=>$manager->projectDetails->address_id_fk,
);
Mail::send('Mail/firstProjectNote', $data, function($message) use ($manager)
{
$message