Skip to content

Instantly share code, notes, and snippets.

View antonlukin's full-sized avatar

Anton Lukin antonlukin

View GitHub Profile

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

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

@antonlukin
antonlukin / wordpress-wordcount.php
Last active March 26, 2019 20:47
Posts word count in WordPress admin
<?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 / share-buttons.js
Created April 19, 2019 14:43
share buttons manager
/**
* Share buttons manager
*/
(function () {
var counters = {
facebook: false,
vkontakte: false,
odnoklassniki: false
};
@antonlukin
antonlukin / mysql-docker.sh
Created November 17, 2019 16:10 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# 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 / docker-compose.yaml
Created April 14, 2020 08:14
Mysql only docker-compose
version: '3.7'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
ports:
@antonlukin
antonlukin / index.html
Created April 16, 2020 07:52
Pass variable to SSI template with nginx
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test your knowlege!</title>
</head>
<body>
<h1>I answered <!--# echo var="count" --> questions correctly!</h1>
</body>
</html>
@antonlukin
antonlukin / unique-slug.php
Created May 14, 2020 08:26
Prevent to create WordPress posts and pages with custom reserved slug
<?php
add_filter('wp_unique_post_slug_is_bad_flat_slug', function($bad_slug, $slug) {
if($slug === 'social') {
return true;
}
return $bad_slug;
}, 10, 2);
@antonlukin
antonlukin / iptables.sh
Last active June 1, 2020 10:45
iptables common rules
# Drop for eth0 all incoming connections
sudo iptables -A INPUT -i eth0 -p tcp --dport 3000 -j DROP
# Save rules
sudo service netfilter-persistent save
@antonlukin
antonlukin / password-check.sh
Last active July 31, 2020 11:05
Check if your password compromised using pwnedpasswords.com API
#!/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}')
location /facebook/ {
access_log off;
log_not_found off;
set $token "${args}&access_token=";
if ( $arg_id ~ "^https://knife.media/" ) {
set $args $token;
}