Skip to content

Instantly share code, notes, and snippets.

@martianyi
martianyi / .eslintrc.js
Last active March 15, 2022 14:50
eslint-plugin-miniprogram
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
@martianyi
martianyi / README.md
Last active May 4, 2020 16:17
Logstash输出到aws elasticsearch service
  1. 在本机安装logstash
  2. 使用rvm安装jruby.
  3. 进入logstash安装目录(如/usr/share/logstash), 运行sudo -E bin/logstash-plugin install --no-verify --version 6.4.0 logstash-output-amazon_es 安装logstash-output-amazon_es插件。如果logstash-plugin安装很慢的话,请安装 haveged 后尝试。见此issue, 此文章
  4. 在aws iam中创建一个用户,赋予编程访问,和AmazonESFullAccess权限,将此用户设为elasticsearch域的主用户,获取access_key和secret(如果已经配置了elasticsearch域的主用户,则用该用户的access_key和secret)
  5. 配置logstash pipeline, 如
input {
  file {
@martianyi
martianyi / README.md
Last active February 16, 2022 13:18
Reverse proxy aws elasticsearch service using nginx
  1. 在elasticsearch域的同一vpc下开一台ec2机器,安装nginx
  2. 准备ssl证书
  3. 配置nginx如下
server {
    listen 443 ssl http2;
    server_name $host;
    rewrite ^/$ https://$host/_plugin/kibana redirect;

    ssl_certificate /path/to/fullchain.pem;
@martianyi
martianyi / readme.md
Last active July 28, 2020 12:05
windows自签发证书

在Powershell中运行以下三个命令.

  1. 创建证书: $cert = New-SelfSignedCertificate -DnsName www.yourwebsite.com -Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My

  2. 设置密码: $CertPassword = ConvertTo-SecureString -String "my_passowrd" -Force –AsPlainText

  3. 导出: Export-PfxCertificate -Cert "cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath "d:\selfsigncert.pfx" -Password $CertPassword

@martianyi
martianyi / readme.md
Created January 15, 2020 04:45
keychain path

~/Library/Preferences/com.apple.security.plist

@martianyi
martianyi / README.md
Last active May 4, 2020 16:19
查看用户是否有访问文件夹的权限
mkdir /var/www
sudo -u www-data stat /var/www
@martianyi
martianyi / .zshrc
Created November 26, 2019 03:29
add username@host for ohmyzsh default theme
PROMPT="%{$fg[green]%}%n@%{$fg[green]%}%m%{$reset_color%} ${PROMPT}"
@martianyi
martianyi / CodeTemplates|tsconfig.json
Last active March 22, 2023 16:19
Visual Studio Code Settings Sync Gist
{{#def.select('MODULE', 'Specify module code generation', ['none','commonjs','amd','system','umd','es6','es2015','esnext'])}}
{{#def.select('TARGET', 'Specify ECMAScript target version', ['es3','es6','es2016','es2017','esnext'])}}
{{#def.confirm('SOURCE_MAP', 'Should generate corresponding .map file?')}}
{
"compilerOptions": {
"module": "{{=$.MODULE}}",
"target": "{{=$.TARGET}}",
"sourceMap": {{=$.SOURCE_MAP}}
},
"exclude": [
@martianyi
martianyi / README.md
Last active October 9, 2019 10:40
Copy a file from one machine to another using Netcat

Server side

nc -l 60000 > qux.txt

Client side

nc bar.example.com 60000 < qux.txt
@martianyi
martianyi / jsbeautify.js
Last active September 10, 2020 18:40
userscript to beautify js and css files
// ==UserScript==
// @name jsbeautify
// @namespace https://gist.github.com/martianyi/ba41ece11e2815bce17fff02793a8197/
// @version 0.1
// @description beautify js and css files
// @author martianyi
// @match *://*/*
// @require https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.7.5/beautify-css.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js