Instantly share code, notes, and snippets.

💻
Code is poetry...

Anatoly Yumashev uptimizt

View GitHub Profile
@uptimizt
uptimizt / wordpress-mysql-delete-comments-1-year-ago.sql
Created Oct 29, 2018
WordPress & MySQL. Удаляем комментарии добавленные более года назад
View wordpress-mysql-delete-comments-1-year-ago.sql
-- delete comments 1 year ago
DELETE c
FROM wp_comments as c
WHERE c.comment_date_gmt < DATE_SUB(NOW(),INTERVAL 1 YEAR)
@uptimizt
uptimizt / wordpress-mysql-comments-1-year-ago.sql
Created Oct 29, 2018
WordPress - Комменты более года
View wordpress-mysql-comments-1-year-ago.sql
-- WordPress - Comments 1 year ago
SELECT *
FROM wp_comments as c
WHERE c.comment_date_gmt < DATE_SUB(NOW(),INTERVAL 1 YEAR)
ORDER BY c.comment_date_gmt DESC
LIMIT 50
@uptimizt
uptimizt / delete-commentmeta-without-comments.sql
Created Oct 29, 2018
WordPress & SQL - delete commentmeta without comments
View delete-commentmeta-without-comments.sql
DELETE cm
FROM wp_commentmeta as cm
LEFT JOIN wp_comments as c ON c.comment_ID = cm.comment_id
WHERE c.comment_ID is null
@uptimizt
uptimizt / WP-CLI-Commands
Created Oct 26, 2018 — forked from mizner/WP-CLI-Commands
WP-CLI - Handy Commands
View WP-CLI-Commands
Search and replace
https://wp-cli.org/commands/search-replace/
wp search-replace
wp search-replace 'http://example.dev' 'http://example.com'
Optmize database
https://wp-cli.org/commands/db/optimize/
wp db optimize
Repair database
@uptimizt
uptimizt / sqlgz.sh
Created Oct 24, 2018
Extract Sql.Gz File On Command Line (macos, linux)
View sqlgz.sh
gzip -d backup-20100910164109.sql.gz
@uptimizt
uptimizt / wp-rest-api-wrapper.js
Created Oct 4, 2018
AJAX wrapper for native JavaScript and WordPress REST API
View wp-rest-api-wrapper.js
/**
* AJAX обертка для WordPress REST API
*/
let sb_ajax = function ( ep, success, error, type = 'GET', data = '' ) {
url = wpApiSettings.root + ep;
// Feature detection
if ( !window.XMLHttpRequest ) return;
@uptimizt
uptimizt / index.php
Created Oct 1, 2018
Adminer > 3.6.3 auto login for my Vagrant config
View index.php
<?php
if(empty($_GET['username']) ){
$_GET['username'] = 'vagrant';
}
function adminer_object() {
class AdminerSoftware extends Adminer {
function credentials() {
@uptimizt
uptimizt / ajax-request-native.js
Created Sep 14, 2018
Making AJAX requests with native JavaScript
View ajax-request-native.js
/**
* Get data from a URL
* @param {String} url The URL to get
* @param {Function} success Callback to run on success
* @param {Function} error Callback to run on error
*/
var getURL = function ( url, success, error ) {
// Feature detection
if ( !window.XMLHttpRequest ) return;
@uptimizt
uptimizt / add-crontab-command.sh
Last active Aug 14, 2018
Добавляем команду запуска крона
View add-crontab-command.sh
#!/bin/bash
crontab -l | { cat; echo "*/1 * * * * curl http://site.lcl/wp-cron.php?doing_wp_cron > /dev/null 2>&1"; } | crontab -
@uptimizt
uptimizt / example-nginx.conf
Last active Aug 8, 2018 — forked from gregrickaby/example-nginx.conf
Defer the loading of images to the production/live server if file not exist - NGINX
View example-nginx.conf
server {
# base nginx conf
location ~ ^/wp-content/uploads/(.*) {
try_files $uri @live_uploads;
}
location @live_uploads {