Skip to content

Instantly share code, notes, and snippets.

View mk100120's full-sized avatar
🌞

kenny mk100120

🌞
  • sap
  • shanghai
View GitHub Profile
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
@mk100120
mk100120 / .gitconfig
Created January 16, 2019 15:18 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
@mk100120
mk100120 / gist:cb3c97bfd227d3b2aa58248e0216817e
Created November 6, 2018 10:52 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]: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
@mk100120
mk100120 / gist:d81af77736a92982224360731f1ffcb6
Last active June 5, 2018 16:54
elasticSearch 常见错误整理
1.问题描述,通过java启动elasticSearch时,出现 NoNodeAvailableException 的异常:
造成的原因: 通过Settings的 .put("cluster.name","elasticsearch") 指定集群名称,这个时候系统会在指定的集群中查找响应的IP,
当IP不存在于指定的集群中或者集群的名称本身就不存在时,会出现 NoNodeAvailableException 异常.
(小知识:elasticsearch通过conf/elasticSearch.yml 配置文件启动系统,如果文件为激活,此时系统启动时的cluster.name为elasticsearch;
9200端口对应的是Http和Rest服务[http.port: 9250];9300是默认的java服务端口[可以通过transport.tcp.port: 9350]自定义
)
解决方法:检查是否cluster.name是否正确;[通过浏览器打开localhost:9200可以查看到cluster.name的信息]
1. 如何向脚本传递参数
./script argument
eg:
./show.sh file1.txt
$cat show.sh
#!/bin/bash
echo $1
2.使用脚本中的参数:
第一个参数: $1, 第二个参数 $2
输入重定向: <
输出重定向: >
标准输入: 0
标准输出: 1
错误输出: 2
Linux Shell 环境中的输入输出重定向,用符号<和>来表示。0、1和2分别表示标准输入、标准输出和标准错误。
1.重定向标准输出到文件:
cat foo > foo.txt
2.重定向标准错误到文件
cat foo 2> foo.txt
awk语法:awk是这样操作的,读入有'\n'换行符分割的一条记录,然后将记录按指定的域分隔符划分域,填充域。
$0则表示所有域,
$1表示第一个域,
$n表示第n个域。
默认域分隔符是"空白键" 或 "[tab]键". 也可以通过 -F 指定分隔符
$ awk '{pattern+action}' {filename}
NF:每行的字段数;
$NF:最后一列字段;
NR:总共读了多少行;NR表示从awk开始执行后,按照记录分隔符读取的数据次数,默认的记录分隔符为换行符,
因此默认的就是读取的数据行数,NR可以理解为Number of Record的缩写
@mk100120
mk100120 / gist:2abd677a15a431b7e28b5128022d6d06
Created April 27, 2018 01:49
一道关于约瑟夫环的算法题解法;
http://zhedahht.blog.163.com/blog/static/2541117420072250322938/
[递归方法]:
class Solution {
public:
    int LastRemaining_Solution(unsigned int n, unsigned int m)
    {
        if(n==0)
            return -1;
肥朝: https://www.jianshu.com/p/5f7846d5d072; https://juejin.im/user/592ad6220ce463006b28d8a9
Nutty: https://www.cnblogs.com/ygj0930/p/6542811.html
@mk100120
mk100120 / Linx_command
Created April 10, 2018 03:35
linux shell command
tee 多重输出
eg:
$ cat a.txt|tee copy.txt
// 将 a.txt 的内容输出到标准输出的同时,输出到 copy.txt 文件