Skip to content

Instantly share code, notes, and snippets.

LiJunjie holysoros

View GitHub Profile
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View mysql-use-index-explain.sql
mysql> EXPLAIN SELECT slug FROM products WHERE deleted_at IS NULL AND id IN (36215, 10736, 40594, 14078, 40466, 1566, 4455, 6746, 41690, 3448,
39094, 13363, 15491, 10913, 4291, 41940, 40392, 10013, 33510, 6962);
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
| 1 | SIMPLE | products | NULL | range | PRIMARY,index_deleted_at | PRIMARY | 4 | NULL | 20 | 10.00 | Using where |
+----+-------------+----------+------------+-------+--------------------------+---------+---------+------+------+----------+-------------+
mysql> EXPLAIN SELECT slug FROM product
@holysoros
holysoros / elasticsearch-rolling-restart.yml
Last active Nov 27, 2018
Elasticsearch rolling restart ansible playbook
View elasticsearch-rolling-restart.yml
# Ansible
# Rolling Upgrade of Elasticsearch
# author: Jeff Steinmetz, @jeffsteinmetz; Bin Li, @holysoros
# tested with Ansible 2.4
---
- name: Elasticsearch rolling upgrade
hosts: es
serial: 1
@holysoros
holysoros / split.sh
Created Mar 22, 2019
Split data file into train and valid part.
View split.sh
#!/usr/bin/env bash
shuf $1 >random.txt
linenum=`wc -l random.txt | awk '{print $1}'`
validnum=$(($linenum/10))
trainnum=$(($validnum*9))
head -n $trainnum random.txt > notes.train
head -n $validnum random.txt > notes.valid
rm random.txt
@holysoros
holysoros / sushi.sh
Created Mar 22, 2019
A linux daemon init script
View sushi.sh
#!/bin/sh
set -e
DEPLOY_DIR="$( cd "$( dirname $0 )" && pwd )"
NAME=sushi
PIDFILE=${DEPLOY_DIR}/tmp/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=${DEPLOY_DIR}/${NAME}
You can’t perform that action at this time.