Skip to content

Instantly share code, notes, and snippets.

View younthu's full-sized avatar

Andrew Yang younthu

View GitHub Profile
@younthu
younthu / kibana_have_no_access_to_elasticsearch
Created May 16, 2019 15:23
action [indices:data/read/search] is unauthorized for user [kibana]
用docker: https://hub.docker.com/r/sebp/elkx/,
docker-composer内容如下:
在kibana(localhost:5601)console里面运行'GET /indices/index/_search'的时候抛下面的错误
1. action [indices:data/read/search] is unauthorized for user [kibana]
在kibana management->users里面,有下面错误:
1. Kibana: You do not have permission to manage users
@younthu
younthu / gist:2d9ff1810e9207ff8b94be864753a1e7
Created May 13, 2019 13:51
无法从docker host连接到mysql
在mac上刚起mysql docker, 然后安装一个mysql client, 通过 mysql -uroot -p --protocol=tcp连接的时候报错:"connection from ip '172.20.0.2' is not allowed".
折腾半天,搞不定。然后重启Mac, 好了!
人生就是这样,莫名其妙就坏了,莫名其妙就好了!
csv = File.read("./your_csv.csv")
table=CSV.parse(csv, headers:true)
# require 'csv'
MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found
解决办法:
$ mysql -uroot
$ update mysql.user set plugin = 'mysql_native_password';
Query OK, 1 row affected (0.08 sec)
Rows matched: 4 Changed: 1 Warnings: 0
重启mysql, 问题解决,参考:https://taruchan.com/2018/06/22/cant-connect-to-mysql-from-sequel-pro/
@younthu
younthu / gist:ec17988c5419e1b2d811ca92de6e9731
Created March 22, 2019 08:45
docker创建samba可写共享文件服务器
利用docker搭建samba服务器步骤:
1. 先运行docker 创建samba服务器容器
docker run -it --name samba -p 139:139 -p 445:445 -v $PWD/samba_shared:/shared -d dperson/samba -u 'dg;dg123' -u 'admin;admin_123' -s 'public;/shared/public' -s 'users;/shared/users;yes;no;yes;all;all;all'
或者用下面这种展开后的命令:
docker run -it --name samba -p 139:139 -p 445:445 -v $PWD/samba_shared:/shared -d dperson/samba \
-u 'dg; password’ \ #创建用户dg, 密码password
-u 'admin; password’ \ #创建用户admin, 密码password
eq: "等于"
eq_any: "等于任意值"
eq_all: "等于所有值"
not_eq: "不等于"
not_eq_any: "不等于任意值"
not_eq_all: "不等于所有值"
matches: "符合"
matches_any: "符合任意条件"
matches_all: "符合所有条件"
does_not_match: "不符合"
@younthu
younthu / gist:1eeaabe5fe5a1cc3085f0ee16df8b5d4
Created March 19, 2019 03:09
rails console切换到pry
1. 添加gem gem 'pry'
2. 添加gem 'pry-doc', 这是查看源代码用的, $ 命令和?命令要用到
3. gem 'pry-rails'这gem把默认的irb替换为pry
@younthu
younthu / gist:37eccfa17dc019853cc00a2a89222d64
Created March 19, 2019 02:50
ransack search ActsAsTaggableOn
Model:
class People < ActiveRecord
acts_as_taggable_on :genders,:features
end
index.html.erb
<%= search_form_for @q do |f| %>
<%= f.search_field :features_name_cont, class: "form-control", placeholder:type here" %>
@younthu
younthu / gist:7d01bfad6a51f04464e1
Created January 9, 2015 02:17
个人常用Mac 软件
TextMate,
vim,
xvim,
Spectacle
SimHolders
Alfred
iFunBox
The unarchiver
evernote
CoreDataEditor
#import <AppKit/AppKit.h>
@interface NSImage (DrawAttributedString)
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString
backgroundColor:(NSColor *)backgroundColor;
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString;
+ (NSImage *)imageWithString:(NSString *)string;
@end