東川印記

一本東川,笑看爭龍斗虎;寰茫兦者,度橫佰昧人生。

MacBookPro2018x01

2018年9月12日星期三



时隔10载,斥资3万大洋又买了台电脑。。。。

1,安装brew
两种方式
第一种,安装到usr/bin下
SENRSL:tools senrsl$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:

第二种,自定目录安装
SENRSL:tools senrsl$ mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128    0   128    0     0     24      0 --:--:--  0:00:05 --:--:--    31
100 1073k  100 1073k    0     0   5426      0  0:03:22  0:03:22 --:--:--  4606

官网
brew.sh/index_zh-cn
git

官方建议是第一种,能少踩坑。。。。 

试了下第二种,果然,还是第一种吧。。。。

昨天第一种方式一直卡在Downloading Command Line Tools (macOS High Sierra version 10.13) for Xcode,
然后晚上关了机,第二天开机,直接就安成功了。。。。


2,安gpg

SENRSL:~ senrsl$ brew --version
Homebrew 1.7.2
Homebrew/homebrew-core (git revision e633; last commit 2018-08-24)
SENRSL:~ senrsl$ brew install gpg
...
SENRSL:~ senrsl$ gpg --help
gpg (GnuPG) 2.2.9
libgcrypt 1.8.3
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/senrsl/.gnupg
支持的算法:
公钥:RSA, ELG, DSA, ECDH, ECDSA, EDDSA
对称加密:IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256,
     TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
散列:SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
压缩:不压缩, ZIP, ZLIB, BZIP2

Syntax: gpg [options] [files]
Sign, check, encrypt or decrypt
Default operation depends on the input data

指令:
 
 -s, --sign                  make a signature
     --clear-sign            make a clear text signature
 -b, --detach-sign           生成一份分离的签名
 -e, --encrypt               加密数据
 -c, --symmetric             仅使用对称加密
 -d, --decrypt               解密数据(默认)
     --verify                验证签名
 -k, --list-keys             列出密钥
     --list-signatures       列出密钥和签名
     --check-signatures      列出并检查密钥签名
     --fingerprint           列出密钥和指纹
 -K, --list-secret-keys      列出私钥
     --generate-key          生成一副新的密钥对
     --quick-generate-key    quickly generate a new key pair
     --quick-add-uid         quickly add a new user-id
     --quick-revoke-uid      quickly revoke a user-id
     --quick-set-expire      quickly set a new expiration date
     --full-generate-key     full featured key pair generation
     --generate-revocation   生成一份吊销证书
     --delete-keys           从公钥钥匙环里删除密钥
     --delete-secret-keys    从私钥钥匙环里删除密钥
     --quick-sign-key        quickly sign a key
     --quick-lsign-key       quickly sign a key locally
     --sign-key              为某把密钥添加签名
     --lsign-key             为某把密钥添加本地签名
     --edit-key              编辑某把密钥或为其添加签名
     --change-passphrase     change a passphrase
     --export                导出密钥
     --send-keys             把密钥导出到某个公钥服务器上
     --receive-keys          从公钥服务器上导入密钥
     --search-keys           在公钥服务器上搜寻密钥
     --refresh-keys          从公钥服务器更新所有的本地密钥
     --import                导入/合并密钥
     --card-status           打印卡状态
     --edit-card             更改卡上的数据
     --change-pin            更改卡的 PIN
     --update-trustdb        更新信任度数据库
     --print-md              print message digests
     --server                run in server mode
     --tofu-policy VALUE     set the TOFU policy for a key

选项:
 
 -a, --armor                 输出经 ASCII 封装
 -r, --recipient USER-ID     encrypt for USER-ID
 -u, --local-user USER-ID    use USER-ID to sign or decrypt
 -z N                        set compress level to N (0 disables)
     --textmode              使用标准的文本模式
 -o, --output FILE           write output to FILE
 -v, --verbose               详细模式
 -n, --dry-run               不做任何改变
 -i, --interactive           覆盖前先询问
     --openpgp               行为严格遵循 OpenPGP 定义

(请参考在线说明以获得所有命令和选项的完整清单)

Examples:

 -se -r Bob [file]          sign and encrypt for user Bob
 --clear-sign [file]        make a clear text signature
 --detach-sign [file]       make a detached signature
 --list-keys [names]        show keys
 --fingerprint [names]      show fingerprints

请向 <https://bugs.gnupg.org> 报告程序缺陷。
请向 <zuxyhere@eastday.com> 反映简体中文翻译的问题。
SENRSL:~ senrsl$ gpg --list-secret-keys
gpg: directory '/Users/senrsl/.gnupg' created
gpg: keybox '/Users/senrsl/.gnupg/pubring.kbx' created
gpg: /Users/senrsl/.gnupg/trustdb.gpg:建立了信任度数据库
SENRSL:~ senrsl$ gpg --list-secret-keys
SENRSL:~ senrsl$ gpg --full-generate-key
...
SENRSL:~ senrsl$ gpg --list-secret-keys
gpg: 正在检查信任度数据库
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: 深度:0 有效性:  1 已签名:  0 信任度:0-,0q,0n,0m,0f,1u
/Users/senrsl/.gnupg/pubring.kbx
--------------------------------
sec   rsa2048 2018-08-24 [SC]
      0BF03EE2A2A63C77A4625B07156BFD2C9798C375
uid           [ 绝对 ] senRsl DC (gpg4github) <dong_M@yeah.net>
ssb   rsa2048 2018-08-24 [E]

SENRSL:~ senrsl$ 


然后填给github

SENRSL:~ senrsl$ gpg --list-secret-keys --keyid-format LONG
/Users/senrsl/.gnupg/pubring.kbx
--------------------------------
sec   rsa2048/156BFD2C9798C375 2018-08-24 [SC]
      0BF03EE2A2A63C77A4625B07156BFD2C9798C375
uid                 [ 绝对 ] senRsl DC (gpg4github) <dong_M@yeah.net>
ssb   rsa2048/C6C3FDBF78EA9F90 2018-08-24 [E]

SENRSL:~ senrsl$ gpg --armor --export 156BFD2C9798C375
-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----
SENRSL:~ senrsl$ 

本地把gpg指给git

按上封邮件的,那个方式一直不行,然后看到了help.github.com/articles/telling-git-about-your-gpg-key/

SENRSL:Test senrsl$ gpg --list-secret-keys --keyid-format LONG
/Users/senrsl/.gnupg/pubring.kbx
--------------------------------
sec   rsa2048/156BFD2C9798C375 2018-08-24 [SC]
      0BF03EE2A2A63C77A4625B07156BFD2C9798C375
uid                 [ 绝对 ] senRsl DC (gpg4github) <dong_M@yeah.net>
ssb   rsa2048/C6C3FDBF78EA9F90 2018-08-24 [E]

SENRSL:Test senrsl$ git config --global user.signingkey 156BFD2C9798C375
SENRSL:Test senrsl$ test -r ~/.bash_profile && echo 'export GPG_TTY=$(tty)' >> ~/.bash_profile
SENRSL:Test senrsl$ echo 'export GPG_TTY=$(tty)' >> ~/.profile
SENRSL:Test senrsl$ git comit -S -m "cmt"
git: 'comit' is not a git command. See 'git --help'.

The most similar command is
commit
SENRSL:Test senrsl$ git commit -S -m "cmt"
On branch master
nothing to commit, working tree clean
SENRSL:Test senrsl$ git tag -s t2 -m 't2'
SENRSL:Test senrsl$ git tag
t1
t2
SENRSL:Test senrsl$ git tag -v t2
object fa1e53d35db6c31ee22c5274e726c1f5f9a5e58d
type commit
tag t2
tagger senRsl DC <dong_M@yeah.net> 1535082213 +0800

t2
gpg: 签名建立于 五  8/24 11:43:33 2018 CST
gpg:               使用 RSA 密钥 0BF03EE2A2A63C77A4625B07156BFD2C9798C375
gpg: 完好的签名,来自于"senRsl DC (gpg4github) <dong_M@yeah.net>" [绝对]
SENRSL:Test senrsl$ 


终于可以了。。。。


给bintry的时候需要填私钥:
SENRSL:tech senrsl$ gpg --armor --export 156BFD2C9798C375
-----BEGIN PGP PUBLIC KEY BLOCK-----
。。。。
-----END PGP PUBLIC KEY BLOCK——

SENRSL:tech senrsl$ gpg --armor --export-secret-keys 156BFD2C9798C375
-----BEGIN PGP PRIVATE KEY BLOCK-----

。。。。
-----END PGP PRIVATE KEY BLOCK-----
SENRSL:tech senrsl$ 



3,Charles 抓https

之前以为只能抓http,没想到https也能抓。。。。

1)Proxy—>Proxy Setting 启用


2)手机设置代理

wifi名那设置手动代理到本机

3)给手机安装证书

Help—> SSL Proxy —> Install on Mobile



4)设置抓取的SSL域名

Proxy —> SSL Proxying Setting —> Add 要抓的域名


同一个域名,一个  .domain.后缀,一个  *.domain.后缀,一个 domain.后缀
端口不用填

然后 Start Recording,就可以抓到了。。。。。。。。


4,微信那种一行评论

    @Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
CommentBean bean = mData.get(position);

//初始
int lastLength = 0;
SpannableStringBuilder ssb = new SpannableStringBuilder();

DefaultClickSpan nameClickSpan = new DefaultClickSpan() {
@Override
public void onClick(View widget) {
Logger.w(widget.toString());
listener.onClickReplayUser(widget, position);
}
};
ssbName(ssb, bean.getUserName(), nameClickSpan, position, lastLength);

//存在被回复人
if (bean.getAtUserId() != CandyOpcode.DEFAULT) {
//回复
ssb.append(mContext.getString(R.string.post_replay));
ssb.append(" ");

lastLength = ssb.length();

//回复对象
//复用上面
DefaultClickSpan nameAtClickSpan = new DefaultClickSpan() {
@Override
public void onClick(View widget) {
Logger.w(widget.toString());
listener.onClickReplayUserAt(widget, position);
}
};
ssbName(ssb, bean.getAtUserName(), nameAtClickSpan, position, lastLength);
}

lastLength = ssb.length();

addContent(bean.getContent(), position, ssb, lastLength);


holder.comment.setText(ssb);
holder.comment.setMovementMethod(LinkTextView.LocalLinkMovementMethod.getInstance());
// holder.comment.setMovementMethod(LinkMovementMethod.getInstance());
holder.comment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(v, position);
}
});
holder.comment.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
listener.onItemLongClick(v, position);
return true;
}
});
}

private void addContent(String content, final int position, SpannableStringBuilder ssb, int lastLength) {
//String str = "a b c d e \n f g www.baidu.com hij klm n www.google.com opq rst uvw xyz";
// bean.setContent(str);
if (null == content) return;

ssb.append(content);

Spannable ss = new SpannableString(content);
Linkify.addLinks(ss, Linkify.WEB_URLS);
URLSpan[] spans = ss.getSpans(0, ss.length(), URLSpan.class);
Logger.w(spans.length + " " + ss.length() + " ");

int i = 0;
for (URLSpan span : spans) {
Logger.w(span.getURL());
// TextViewWebUtils.InnerURLSpan urlSpan = new TextViewWebUtils.InnerURLSpan(span.getURL());
int start = ss.getSpanStart(span);
int end = ss.getSpanEnd(span);

if (i < start) {
//WARN: contentClickSpan 必须每次实例化,不可复用引用
DefaultClickSpan contentClickSpan = new DefaultClickSpan() {
@Override
public void onClick(View widget) {
Logger.w(widget.toString());
listener.onClickContent(widget, position);
}
};
//Logger.w("set click: "+ (lastLength+i) +" "+(lastLength+start) + " --"+ssb.subSequence(lastLength+i,lastLength+start));
ssb.setSpan(contentClickSpan, lastLength + i, lastLength + start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}

TextViewWebUtils.InnerURLSpan urlSpan = new TextViewWebUtils(mContext).startInner(span.getURL());
//Logger.w("set url: "+ (lastLength+start) +" "+(lastLength+end)+" ------"+ssb.subSequence(lastLength+start,lastLength+end));
ssb.setSpan(urlSpan, lastLength + start, lastLength + end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

i = end;
}

if (i < ssb.length()) {
//WARN: contentClickSpan 必须每次实例化,不可复用引用
DefaultClickSpan contentClickSpan = new DefaultClickSpan() {
@Override
public void onClick(View widget) {
Logger.w(widget.toString());
listener.onClickContent(widget, position);
}
};
//Logger.w("set click last: "+ (lastLength+i) +" "+(ssb.length()) + " --"+ssb.subSequence(lastLength+i,ssb.length()));
ssb.setSpan(contentClickSpan, lastLength + i, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

private void ssbName(SpannableStringBuilder ssb, String userName, DefaultClickSpan nameClickSpan, int position, int lastLength) {
//名字
String name = (isVeril ? mContext.getString(R.string.veril_name) : null == userName?mContext.getString(R.string.me):userName);
ssb.append(name);

//灰色
ForegroundColorSpan nameColorSpan = new ForegroundColorSpan(mContext.getResources().getColor(R.color.text_color8));
ssb.setSpan(nameColorSpan, lastLength, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

ssb.setSpan(nameClickSpan, lastLength, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

//冒号
ssb.append(mContext.getString(R.string.spacer));
}

@Override
public int getItemCount() {
return mData == null ? 0 : mData.size();
}

public void updateData(List<CommentBean> data) {
this.mData = data;
notifyDataSetChanged();
}

public void setOnItemClickListener(CommentAdapter.OnItemClickListener listener) {
this.listener = listener;
}

public static class ViewHolder extends RecyclerView.ViewHolder {
TextView comment;

public ViewHolder(View itemView) {
super(itemView);
comment = itemView.findViewById(R.id.comment);
}
}

public interface OnItemClickListener {
void onItemClick(View view, int position);

void onItemLongClick(View view, int position);

void onClickReplayUser(View view, int position);

void onClickReplayUserAt(View view, int position);

void onClickContent(View view, int position);
}

public void setVeril(boolean veril) {
isVeril = veril;
}

private class DefaultClickSpan extends ClickableSpan {
@Override
public void onClick(View widget) {
}

@Override
public void updateDrawState(TextPaint ds) {
}
}




5,新电脑
2018年09月12日16:02:44




----
senRsl
2018年09月01日16:13:39

没有评论 :

发表评论