Skip to content

Instantly share code, notes, and snippets.

View aletoropov's full-sized avatar
🏠
Working from home

Alexandr aletoropov

🏠
Working from home
View GitHub Profile
@aletoropov
aletoropov / error_log.php
Created September 29, 2024 20:01
Сохранение PHP ошибок в файл
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 'on');
ini_set('error_log', __DIR__ . DIRECTORY_SEPARATOR . 'error_log.txt');
@aletoropov
aletoropov / ssh-keygen.sh
Created September 20, 2024 06:46
SSH генерация ключей
ssh-keygen -t rsa -C "[email protected]" -f ~/.ssh/id_rsa -P ""
cat ~/.ssh/id_rsa.pub
@aletoropov
aletoropov / update.sh
Created June 22, 2024 15:10
Обновление и очистка системы (Ubuntu, Linux Mint)
#!/bin/bash
echo "Update & clean system..."
sudo apt-get update
sudo apt-get upgrade
sudo apt autoclean
sudo apt clean
sudo apt autoremove
sudo snap set system refresh.retain=2
dpkg -l | awk '/^rc/ {print $2}' | xargs sudo dpkg --purge
@aletoropov
aletoropov / .htaccess
Created February 22, 2024 17:29
Редирект с HTTP на HTTPS
# Редирект с http на https
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# Конец редиректа
@aletoropov
aletoropov / redirect.js
Created February 22, 2024 17:23
Редирект с помощью JavaScript
window.location.replace('https://aletoropov.ru');
@aletoropov
aletoropov / scripts.js
Last active February 22, 2024 17:20
Слушатель события отправки формы
document.querySelector('form').addEventListener('submit', (e) => {
e.preventDefault()
const data = Object.fromEntries(new FormData(e.target).entries());
console.log(data)
});
@aletoropov
aletoropov / functions.php
Created January 5, 2024 15:56
отключить доставку и оплату в Woocommerce
<?php
//отключаем параметры доставки по стране
add_filter( 'woocommerce_cart_needs_shipping', 'woocommerce_disable_shipping' );
function woocommerce_disable_shipping() {
return false;
}
//отключаем параметры оплаты
add_filter( 'woocommerce_cart_needs_payment', 'woocommerce_disabled_payment' );
function woocommerce_disabled_payment() {
return false;
@aletoropov
aletoropov / functions.php
Last active January 5, 2024 15:56
Удаление inline стилей в WordPress
<?php
add_action( 'wp_print_styles', function()
{
wp_styles()->add_data( 'jet-smart-filters-inline-css', 'after', '' );
} );
add_action( 'init', 'remove_my_style_stylesheet', PHP_INT_MAX );
function remove_my_style_stylesheet() {
wp_deregister_style( 'jet-smart-filters-inline-css' );
}
add_action( 'wp_enqueue_scripts', function() {
@aletoropov
aletoropov / adduser.php
Created July 9, 2023 09:04 — forked from eivko/adduser.php
Создание Super User-а для MODX
<?php
$username = 'vasya';
$password = 'qwerty';
$email = '[email protected]';
$sudo = true;
require 'config.core.php';
require MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
if ((!$modx) || (!$modx instanceof modX)) {
@aletoropov
aletoropov / head.modx.html
Created July 9, 2023 09:03 — forked from eivko/head.modx.html
Заголовок в MODX (если не пустой, вставляется longtitle
<title>[[*longtitle:isnot=``:then=`[[*longtitle]]`:else=`[[*pagetitle]]`]]</title>