markdown SCMP DB导入步骤

scmp db一步一步导入

drush.md
```
drush en devel
```

```
drush en dblog
```
db-import.md
### How to import DB

Please run the following commands:

#### Stopping services that may interfere the import process:
````
sudo /var/www/scmp_outage/start-outage.sh
sudo /usr/bin/supervisorctl stop all
sudo /etc/init.d/php5-fpm stop
````

Sometimes database import failed with 'DUPLICATE PRIMARY KEY' error, which is probably because the cron process is still running during the import.

To stop the cronjob - stop supervisor

````
sudo service supervisor stop
````

To make sure no emails are sent from dev during prod db restore

````
sudo service postfix stop
````

To make sure no residual drush commands still running (after supervisord stopped)

````
sudo killall drush
````

#### Starting the import:
````
drush @standalone sql-drop -y
bunzip2 -c db.sql.bz2 | drush @standalone sqlc
````

#### Clearing cache, update DB and resume services:
````
sudo /etc/init.d/memcached restart
drush @standalone env-switch development
sudo /etc/init.d/rabbitmq-server restart
drush @standalone updb -y
drush @standalone cc css+js -y
sudo /etc/init.d/php5-fpm start
sudo service supervisor start
sudo /usr/bin/supervisorctl start all
sudo /var/www/scmp_outage/stop-outage.sh
sudo service postfix start
````

#### Confirm the imported DB version:
````
drush @standalone vget dpkg_version
````

markdown NodeJs multimedia webpack build命令

nodejs-multimedia webpack build

build.md
#### build
````
npm run build
````

markdown PM2命令

nodejs pm2命令列表

pm2-command.md
#### pm2 command
  - `pm2 list` list the app status
  - `pm2 stop all` stop the app
  - `pm2 delete process.json` delete the app
  - `pm2 start process.json` start the app
  - `pm2 restart process.json` restart the app
  - `pm2 logs` log the app

markdown Nginx重启,启用选项rquest

Nginx启用选项rquest,重启nginx

robots.md
#### restart nginx
```
sudo /etc/init.d/nginx restart
```


````
/etc/nginx/includes/external/server-common.conf
````

```
location /robots.txt {
  try_files /sites/default/files/robots.txt $uri;
}
```
request.md
````
/etc/nginx/includes/external/server-common.conf
````
````
if ($request_method !~ ^(GET|HEAD|POST|OPTIONS)$ ) {
    ....
}
````

markdown 更新使用APT的基于debian-linux的计算机。

更新使用APT的基于debian-linux的计算机。

update.sh
#!/bin/bash

ask_for_sudo() {

    # Ask for the administrator password upfront.

    sudo -v &> /dev/null

    # Update existing `sudo` time stamp
    # until this script has finished.
    #
    # https://gist.github.com/cowboy/3118588

    while true; do
        sudo -n true
        sleep 60
        kill -0 "$$" || exit
    done &> /dev/null &

}

show_spinner() {

	local -r FRAMES='/-\|'

    # shellcheck disable=SC2034
    local -r NUMBER_OR_FRAMES=${#FRAMES}

    local -r CMDS="$2"
    local -r MSG="$3"
    local -r PID="$1"

    local i=0
    local frameText=""

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Note: In order for the Travis CI site to display
    # things correctly, it needs special treatment, hence,
    # the "is Travis CI?" checks.

    if [ "$TRAVIS" != "true" ]; then

        # Provide more space so that the text hopefully
        # doesn't reach the bottom line of the terminal window.
        #
        # This is a workaround for escape sequences not tracking
        # the buffer position (accounting for scrolling).
        #
        # See also: https://unix.stackexchange.com/a/278888

        printf "\n\n\n"
        tput cuu 3

        tput sc

    fi

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Display spinner while the commands are being executed.

    while kill -0 "$PID" &>/dev/null; do

        frameText="   [${FRAMES:i++%NUMBER_OR_FRAMES:1}] $MSG"

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        # Print frame text.

        if [ "$TRAVIS" != "true" ]; then
            printf "%s\n" "$frameText"
        else
            printf "%s" "$frameText"
        fi

        sleep 0.2

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        # Clear frame text.

        if [ "$TRAVIS" != "true" ]; then
            tput rc
        else
            printf "\r"
        fi

    done

}

execute() {

    local -r CMDS="$1"
    local -r MSG="$2"
    local -r TMP_FILE="$(mktemp /tmp/XXXXX)"

    local exitCode=0
    local cmdsPID=""

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # If the current process is ended,
    # also end all its subprocesses.

    set_trap "EXIT" "kill_all_subprocesses"

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Execute commands in background

    eval "$CMDS" \
        &> /dev/null \
        2> "$TMP_FILE" &

    cmdsPID=$!

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Show a spinner if the commands
    # require more time to complete.

    show_spinner "$cmdsPID" "$CMDS" "$MSG"

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Wait for the commands to no longer be executing
    # in the background, and then get their exit code.

    wait "$cmdsPID" &> /dev/null
    exitCode=$?

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Print output based on what happened.

    print_result $exitCode "$MSG"

    if [ $exitCode -ne 0 ]; then
        print_error_stream < "$TMP_FILE"
    fi

    rm -rf "$TMP_FILE"

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    return $exitCode

}

set_trap() {

    trap -p "$1" | grep "$2" &> /dev/null \
        || trap '$2' "$1"

}

print_error_stream() {
    while read -r line; do
        print_error "↳ ERROR: $line"
    done
}

print_error() {
    print_in_red "   [✖] $1 $2\n"
}

print_success() {
    print_in_green "   [✔] $1\n"
}

print_in_green() {
    print_in_color "$1" 2
}

print_in_purple() {
    print_in_color "$1" 5
}

print_in_red() {
    print_in_color "$1" 1
}

print_in_color() {
    printf "%b" \
        "$(tput setaf "$2" 2> /dev/null)" \
        "$1" \
        "$(tput sgr0 2> /dev/null)"
}

print_result() {

    if [ "$1" -eq 0 ]; then
        print_success "$2"
    else
        print_error "$2"
    fi

    return "$1"

}

fix_dpkg() {
    declare -a files=("/var/lib/dpkg/lock" "/var/cache/apt/archives/lock")

    for i in "${files[@]}"
    do
        # If there is a dpkg lock, then remove it.
        if [ -e "$i" ]; then
            sudo rm -rf "$i" &> /dev/null
        fi
    done
}

install_package() {

    declare -r PACKAGE="$2"
    declare -r PACKAGE_READABLE_NAME="$1"

    if ! package_is_installed "$PACKAGE"; then
        fix_dpkg
        execute "sudo apt-get install --allow-unauthenticated -qqy $PACKAGE" "$PACKAGE_READABLE_NAME"
        #                                      suppress output ─┘│
        #            assume "yes" as the answer to all prompts ──┘
    else
        print_success "$PACKAGE_READABLE_NAME"
    fi

}

package_is_installed() {
    dpkg -s "$1" &> /dev/null
}

update() {

	ask_for_sudo

	fix_dpkg

	# Resynchronize the package index files from their sources.

	execute \
		"sudo apt-get update -qqy" \
		"APT (update)"

}

upgrade() {

	ask_for_sudo
	
	fix_dpkg

	# Install the newest versions of all packages installed.

	execute \
		"export DEBIAN_FRONTEND=\"noninteractive\" \
			&& sudo apt-get -o Dpkg::Options::=\"--force-confnew\" upgrade -qqy" \
		"APT (upgrade)"

}


main() {

	print_in_purple "\n   Updating System\n\n"

	update
	upgrade
	
	printf "\n"

}

main
README.md
Linux Updater Script
=======================================

Here's a short shell script to quickly update a debian-linux-based computer that uses APT.

* Run the script, like this: ``bash <(curl -s https://gist.githubusercontent.com/nicholasadamou/5fbde132620829a9c68c94cb04c013c8/raw/b1ab3ffe6f1b1dd425ff89920d88a5d169e2506e/update.sh)``

markdown react / redux工作流程

wofrllow.md
### scaffold

* add .gitignore
* add README
* npm init
* npm add all deps
* create webpack config
* create .env
* create jest globals in package.json
* create .babelrc w/ plugins and presets
* add package.json scripts
* add eslintrc and eslintignore

### boilerplate

* create index.html
* create main.js
* create app/index.js
* create sass tree
* create util.js > log, logError, renderIf, classToggler

## add store

### scaffold

* add .gitignore
* add README
* npm init
* npm add all deps
* create webpack config
* create .env
* create jest globals in package.json
* create .babelrc w/ plugins and presets
* add package.json scripts
* add eslintrc and eslintignore

### boilerplate

* create index.html
* create main.js
* create app/index.js
* create sass tree
* create util.js > log, logError, renderIf, classToggler

## add store

* create app reducer
* create middleware
* create appStoreCreate
* add store to App component

markdown 保持最新的分叉

保持最新的分叉

gistfile1.md
### 1. Clone your fork:

    git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

### 2. Add remote from original repository in your forked repository: 

    cd into/cloned/fork-repo
    git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
    git fetch upstream

### 3. Update the local copy of your fork from the original repo to keep up with their changes:

    git pull upstream master
    
### 4. Push your updated local copy back up to your GitHub fork

    git push origin master

markdown 通过SQL将RAW UUID类型转换为字符串

通过SQL将RAW UUID类型转换为字符串

UUID SQL.md

|Database	  | Storage Type | How to convert |
|:----------|:------------:|:---------------|
|Oracle     |	`RAW(16)` | `REGEXP_REPLACE(binary-guid, '(.{8})(.{4})(.{4})(.{4})(.\*)', '\1-\2-\3-\4-\5')()` |
|SQL Server | `UNIQUEIDENTIFIER` | `CONVERT(CHAR(36), binary-guid)` |
|MySQL | `BINARY(16)` | `CONCAT_WS('-',`<br>`  SUBSTR(HEX(binary-guid), 1, 8),`<br>`  SUBSTR(HEX(binary-guid), 9, 4),`<br>`  SUBSTR(HEX(binary-guid), 13, 4),`<br>`  SUBSTR(HEX(binary-guid), 17, 4),`<br>`  SUBSTR(HEX(binary-guid), 21))`|

markdown WordPress插件列表

我最常用的WordPress插件列表

wp-job-manager.md
## Advanced Custom Fields
Content editing made easy.  
https://www.advancedcustomfields.com/

## Database Browser 
Easily query your data and export it.  
https://wordpress.org/plugins/database-browser/

## Page and Post Clone
Create a replica or clone of a post or page with one click.  
https://wordpress.org/plugins/page-or-post-clone/

## WP Job Manager 
A lightweight, open source job board plugin for WordPress.  
https://wpjobmanager.com/

markdown 欢迎来到Cacher

以下是一些可帮助您开始构建代码段库的提示。

cacher_intro.md
# Getting Started with Cacher

<p align="center">
<img src="http://www.cacher.io/assets/intro-snippet-splash-a90755aca4db13aac1e5140e8d7c2a7c01d9b69a640e51b55093421dff432039.png" width="480" />
</p>


## Use snippets to quickly recall commands

Snippets are the most useful when you want to re-use a shell command or a specific code pattern. Here are a few we have in our library:
- "How to delete a git tag"
- "Nginx configuration for staging server"
- "Crash handler AWS Lambda function"

## Use snippets for customer service

Engineers are often second-line customer agents. Use Cacher to store snippets for performing common support tasks.

## Labels are your friend

Labels are a great way to organize your snippets. A good practice is to have one for every major product feature. We've created the first label for you - **Documentation**.

## Create or join a team to share knowledge

Teams allow you and your colleagues to build a shared knowledge base. Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to write beautifully formatted documentation. (This snippet itself is a Markdown file.)

## Use snippets for onboarding new team members

Let's face it. Having the new engineer decipher a 500 thousand-line codebase might not be an efficient use of her time. Use snippets as examples to help new members get up to speed fast.