Skip to content

Instantly share code, notes, and snippets.

SELECT wpp.post_title, wpp.guid, wpp.post_date,
concat('https://www.mydomain.com', REPLACE( REPLACE( REPLACE( REPLACE( wpo.option_value, '%year%', DATE_FORMAT(wpp.post_date,'%Y') ), '%monthnum%', DATE_FORMAT(wpp.post_date, '%m') ), '%day%', DATE_FORMAT(wpp.post_date, '%d') ), '%postname%', wpp.post_name )) AS permalink
FROM wp_posts wpp
JOIN wp_options wpo
ON wpo.option_name = 'permalink_structure'
WHERE wpp.post_type = 'post'
AND wpp.post_status = 'publish'
ORDER BY wpp.post_date DESC;
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
@alanzhaonys
alanzhaonys / batch-cherry-pick.sh
Last active June 29, 2018 21:05
Cherry pick a commit to all other branches in a project, specify --skip-master as 2nd parameter to skip master branch. *** BE CAREFUL: *** this script assumes your branches are clean and there will be no pending merges when it's doing the `git pull` prior to cherry picking. It could fuck up your code, I take no responsibilities.
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo "Enter a commit id (run \`git log\` to see commit history)"
echo "Example: ./batch-cherry-pick.sh [commit id] --skip-master"
exit
fi
# Commmit id parameter
readonly commit=$1
@alanzhaonys
alanzhaonys / create-user.sh
Created June 27, 2018 14:27
Create a new user in Linux
#!/bin/bash
# Make sure only root can run this script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo)" 1>&2
exit 1
fi
if [[ $# -eq 0 ]] ; then
echo Enter a user name