Skip to content

Instantly share code, notes, and snippets.

View serguk89's full-sized avatar

Serhii serguk89

  • Kyiv, Ukraine
View GitHub Profile
@serguk89
serguk89 / sync-prod.sh
Created July 5, 2017 07:58 — forked from retlehs/sync-prod.sh
WP-CLI aliases sync example
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
wp @development db reset --yes &&
wp @production db export - > sql-dump-production.sql &&
wp @development db import sql-dump-production.sql &&
wp @development search-replace https://example.com https://example.dev
fi
@serguk89
serguk89 / wp_rewrite_rules.log
Created October 2, 2018 12:26 — forked from thenbrent/wp_rewrite_rules.log
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@serguk89
serguk89 / delete_custom_post_type.php
Created October 27, 2018 12:54 — forked from jazibsawar/delete_custom_post_type.php
WordPress $wpdb: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta) using SQL query & $wpdb
<?php
function delete_custom_posts($post_type = 'post'){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM wp_posts posts
LEFT JOIN wp_term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s
@serguk89
serguk89 / get_meta_values.php
Created October 28, 2018 17:33 — forked from tybruffy/get_meta_values.php
Get all distinct values of a meta field in Wordpress
function _get_all_meta_values($key) {
global $wpdb;
$result = $wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status = 'publish'
ORDER BY pm.meta_value",
$key
@serguk89
serguk89 / october-deployment.sh
Created November 3, 2018 20:21 — forked from khoatran/october-deployment.sh
Bamboo deployment script
export DEPLOYMENT_FOLDER=/deployment-folder
export RELEASE_ROOT_FOLDER=$DEPLOYMENT_FOLDER/releases
export RELEASE_FOLDER=$DEPLOYMENT_FOLDER/releases/intermediate
cd $DEPLOYMENT_FOLDER/build
tar -xvf artifact.tar
rm -rf artifact.tar
cd $DEPLOYMENT_FOLDER
shopt -s dotglob
# Unzip and copy all files in artifact into the release folder
mkdir $RELEASE_FOLDER
@serguk89
serguk89 / rsync-remote.sh
Created November 3, 2018 20:21 — forked from khoatran/rsync-remote.sh
Rsync from remote
rsync -avz --progress -e "ssh -i ssh_key" root@ip_of_the_remote:/folder/* /target-folder
@serguk89
serguk89 / october.conf
Created November 3, 2018 20:21 — forked from khoatran/october.conf
Nginx fast cgi cache for OctoberCMS
#Set the path where the cache is stored; Set the zone name, totalsize (400m),and max life time(60m)
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=AICUNGXINH:400m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
#fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
@serguk89
serguk89 / scaling_php_application.conf
Created November 3, 2018 20:21 — forked from khoatran/scaling_php_application.conf
Configuring Nginx to be a Cache for PHP-FPM
# This is the sample from Scaling PHP applications book
#Set the path where the cache is stored; Set the zone name(my_app), totalsize (100m),and max life time(60m)
fastcgi_cache_path /tmp/cachelevels=1:2keys_zone=my_app:100minactive=60m;
#Set the cache key used,in this case: httpsGETtest.com/somepage.html
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server{
listen 80;
@serguk89
serguk89 / remember-passphrase.sh
Created November 3, 2018 20:21 — forked from khoatran/remember-passphrase.sh
Remember passphrase of your ssh key
ssh-add ~/.ssh/id_rsa &>/dev/null
@serguk89
serguk89 / wget-snapshotpage.md
Created December 28, 2018 15:38 — forked from dannguyen/wget-snapshotpage.md
Use wget to snapshot a page and its necessary visual dependencies

Use wget to mirror a single page and its visible dependencies (images, styles)

Money graphic via State of Florida CFO Vendor Payment Search

Graphic via State of Florida CFO Vendor Payment Search (flair.myfloridacfo.com)

This is a quick command I use to snapshot webpages that have a fun image I want to keep for my own collection of WTFViz. Why not just right-click and save the image? Oftentimes, the webpage in which the image is embedded contains necessary context, such as captions and links to important documentation just incase you forget what exactly that fun graphic was trying to explain.