Skip to content

Instantly share code, notes, and snippets.

View maxyudin's full-sized avatar

Max Yudin maxyudin

View GitHub Profile
# Cheatsheet: correct file permissions for WordPress
# During the setup:
cd /wordpress-directory # Change directory
chown www-data:www-data -R * # Let Apache be owner
find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r--
# After the setup you should tighten the access rights:
@maxyudin
maxyudin / current_node_js_version_symlink.md
Created August 21, 2022 12:54
Current Node.js version path
<?php
/**
* Plugin or functions.php
*/
function mxd_csp_nonce() {
// generate nonce here
return 'sha384-7TB/burIFPND3rU7p38KUmP8C6LhM+Ybd8yzSEb1FvUgyJd9TMJ9HqWP3q+sFZOM';
}
@maxyudin
maxyudin / phpcs + WordPress Coding Standards + Sublime Text 3.md
Last active April 4, 2021 08:35
phpcs + WordPress Coding Standards + Sublime Text 3

phpcs + WordPress Coding Standards + Sublime Text 3

phpcs установлен через composer глобально в ~/.config/composer/vendor/squizlabs/php_codesniffer/

Для конкретного проекта:

Создать composer.json в директории проекта:

{

"name": "maxyudin/my-project-name",

[
{ "keys": ["ctrl+й"], "command": "exit" },
{ "keys": ["ctrl+щ"], "command": "prompt_open_file" },
{ "keys": ["ctrl+т"], "command": "new_file" },
{ "keys": ["ctrl+ы"], "command": "save" },
{ "keys": ["ctrl+ц"], "command": "close" },
{ "keys": ["ctrl+я"], "command": "undo" },
{ "keys": ["ctrl+shift+я"], "command": "redo" },
{ "keys": ["ctrl+н"], "command": "redo_or_repeat" },
@maxyudin
maxyudin / doh-esni-firefox.md
Last active March 29, 2024 21:10
DNS-over-HTTPS (DoH) and Encrypted SNI (ESNI) in Firefox

DNS-over-HTTPS (DoH) and Encrypted SNI (ESNI) in Firefox

Simple (no ESNI)

  • Go to Menu ⇒ Prefereces (or visit about:preferences)
    • Scroll down to the Network Settings and press Settings button
    • Check Enable DNS over HTTPS
    • Choose a provider or set a custom one from the publicly available servers list

Test your settings!

@maxyudin
maxyudin / Rīgas Satiksme
Created January 2, 2020 15:09
Rīgas Satiksme
http://www.rigassatiksme.lv/data/stops.txt
http://www.rigassatiksme.lv/data/routes.txt
@maxyudin
maxyudin / wordpress_low-quality-image-placeholders_lqip.md
Created October 5, 2019 10:32 — forked from ctlcltd/wordpress_low-quality-image-placeholders_lqip.md
How to easily generate low quality image placeholders (lqip) in WordPress

How to easily generate low quality image placeholders (lqip) in WordPress

I have made this function using the WP_Image_Editor class and I have filtered through the "wp_generate_attachment_metadata" hook. You can modify the "theme" namespace into function names with your theme name or in anyway you like.

Applying the filter directly to wp_generate_attachment_metadata the image placeholders are auto added into WordPress metadata, so when your add/modify/delete an image (or regenerate it via a plugin), it accomplishes to modify also to the image placeholders.

The use of the native theme support can prevent the generation of lqip or target specific image sizes to generate.

It contains an hook filter lqip_quality to modify the quality without have to modify the function.

@maxyudin
maxyudin / custom_menu_admin.php
Created September 29, 2019 12:44 — forked from carlodaniele/custom_menu_admin.php
A basic plugin showing how to add menu metaboxes to admin menu page
<?php
/**
* @package Custom_menu_admin
* @version 1.0
*/
/*
Plugin Name: Custom menu admin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}