Skip to content

Instantly share code, notes, and snippets.

@antonlukin
antonlukin / wordpress-wordcount.php
Last active Mar 26, 2019
Posts word count in WordPress admin
View wordpress-wordcount.php
<?php
add_action('save_post', function($post_id, $post, $update) {
$word_count = explode(" ", strip_shortcodes($post->post_content));
update_post_meta($post_id, '_wordcount', count($word_count));
}, 10, 3);
add_filter('manage_posts_columns', function($columns){
@antonlukin
antonlukin / setup-ubuntu.md
Last active Nov 25, 2019
Установка и настройка Ubuntu Server
View setup-ubuntu.md

Настройка Ubuntu Server

На данном этапе предполагается, что у вас установлен чистый дистрибутив Ubuntu Server старше 11.04. Все команды ниже гарантировано работают в версии 12.04.

Для начала необходимо добавить пользователя, от имени которого вы будете работать в дальнейшем на сервере. Делается это командой:

adduser login

Здесь login ваше имя пользователя. На всех своих серверах я использую логин master.

View git-remote.md

git remote set-url --add --push origin git://original/repo.git

git remote set-url --add --push origin git://another/repo.git

View create-admin.php
<?php
add_action('init', function() {
if(isset($_GET['create-admin'])) {
$user_id = wp_insert_user([
'user_login' => 'lukin',
'user_pass' => 'temp-password-0',
'role' => 'administrator'
]);
@antonlukin
antonlukin / password-check.sh
Last active Jul 31, 2020
Check if your password compromised using pwnedpasswords.com API
View password-check.sh
#!/usr/bin/env bash
set -e
#set -x
# ask user for password
read -p "Input password for check: " -t 30 passwd
if [ -n "$passwd" ]; then
hash=$(echo -n "$passwd" | sha1sum | awk '{print $1}')
@antonlukin
antonlukin / share-buttons.js
Created Apr 19, 2019
share buttons manager
View share-buttons.js
/**
* Share buttons manager
*/
(function () {
var counters = {
facebook: false,
vkontakte: false,
odnoklassniki: false
};
View knife-facebook.conf
location /facebook/ {
access_log off;
log_not_found off;
set $token "${args}&access_token=";
if ( $arg_id ~ "^https://knife.media/" ) {
set $args $token;
}
@antonlukin
antonlukin / mysql-docker.sh
Created Nov 17, 2019 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
View mysql-docker.sh
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@antonlukin
antonlukin / snippets.php
Created Feb 9, 2020
Custom snippets to upgrade instapress theme
View snippets.php
<?php
/**
* Plugin name: Snippets for lukin.blog
* Description: Custom snippets to upgrade instapress theme
* Author: Anton Lukin
* Author URI: https://lukin.me
* Version: 1.0
*/
@antonlukin
antonlukin / docker-compose.yaml
Created Apr 14, 2020
Mysql only docker-compose
View docker-compose.yaml
version: '3.7'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
ports: