Chrome team just released several new official themes

I never use Chrome theme before, not a fan of customized theme because most of them are too stylish for me.

But Chrome team just released sever official themes days ago, they are clean and fresh, most of them seem for programmers. Like Oceanic, High Contrast Colorful.

You can get them from here:  https://chrome.google.com/webstore/category/collection/chrome_themes




How to block HTTPS websites on Router with Merlin

Merlin is a very powerful Router OS.

The best feature I like is its plugin system. there you can install many third-party apps like Adblock, web shell, AppleDNS. Most of the great apps are already in its built-insoftware center you can just install them with 1 click.

It also has a `Firewall`,  here you can add some rules to let the router block some URL or hosts or even IP that you don’t want the users access.  

But as it says, it has some limitations:

So basically, since almost all websites are with HTTPS now, this Firewall has actually been useless now.

Of cause, since it’s a mini Linux system, you can log in to it in shell and edit  hosts, but it’s not that convenient to do things with the shell. 

Here is a killer app, it’s been taken down because of Chinese policy, it’s called shad0w20cks(you know it). 

In it’s DNS Settings, there is a textarea called customize dnsmayou can just add your hosts like rules in it. like if you want to block baidu.com and weibo.com:

address=/baidu.com/127.0.0.1

address=/weibo.com/127.0.0.1

And then save.

works like a charm 😀

End.




How to remove experimentalDecorators warning in VSCode

Problem

Working on a Vue project with VSCode as code editor. Using typescript in the Vue component.

While VSCode keeps warning this message on the declaration of Component class name. Which is very annoying.

Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.

Tried to search a bit, in the VSCode github, they tell you to set experimentalDecorators to true in VSCode settings, and restart, however it’s not working.

Solution

you need to modify the typescript configuration. In tsconfig.json file (if you don’t have one, create it in your project’s root folder). Add this:

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "allowJs": true
    }
}

Both experimentalDecorators and allowJs needs to be set to true

And then restart VSCode.

Done.




zsh 主题 powerlevel9k 安装配置记录

zsh with powerlevel9k theme

安装:

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

启用和配置

编辑 `~/.zshrc`

  • 启用
ZSH_THEME="powerlevel9k/powerlevel9k"
  • 改变配置
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs) #左侧显示全路径和Git状态
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time ram) #右侧显示时间和内存

我本人需要的就这些,显示结果如题图。更多详细配置见:https://github.com/bhilburn/powerlevel9k

遇到乱码在iterm2的配置里面修改字体即可。




Github中国加速hosts列表

因为众所周知的原因,github对很多中国用户来说有些慢。特别在clone的时候。

可以通过修改hosts来解决。最新的hosts列表如下:

# GitHub Start  updated 15-1-2019
192.30.253.112 github.com
192.30.253.118 gist.github.com
151.101.112.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.112.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.112.133 camo.githubusercontent.com
151.101.112.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.12.133 avatars3.githubusercontent.com
151.101.12.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.12.133 avatars8.githubusercontent.com
# GitHub End



iTerm2 + zsh + oh my zsh 安装和配置

https://cdn-images-1.medium.com/max/1600/1*QCDLBTPMt3S7G0JOQbD68A.png

OSX的默认终端terminal功能比较基础,对于普通用户来说不是非常友好,界面也丑丑的。以上是使用iterm2 + zsh + oh my zsh 之后的效果。

除了界面很好看而外,还能实现诸如显示当前路径、系统资源占用、git状态等信息。且拥有丰富的可定制化选项,让你可以打造自己的终端。

接下来就来一步步定制自己的终端吧。

安装 Homebrew

打开终端,粘贴如下代码, 这将在你的机器上安装Homebrew,这是一个包管理工具。类似ubuntu里面的 apt.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装 iTerm2

这是用来替代terminal的工具,既可以去官网下载:https://www.iterm2.com/downloads.html

也可以利用上面安装好的 Homebrew 直接安装:

brew cask install iterm2

安装 zsh

还是直接用 homebrew 来安装:

brew install zsh

安装 oh-my-zsh

如果不安装 oh-my-zsh的话,zsh会比较难用。OMZ 是一个开源的 zsh 配置管理工具,拥有很多丰富的功能、扩展和皮肤来让定制你的zsh。安装代码如下

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

自定义皮肤:

网上有很多的自定义皮肤可以供下载使用。个人比较喜欢现在比较流行的 Material 风格,无论是 vscode 还是其他编辑器,均有这个风格的皮肤,非常清新。预览图如下:

https://github.com/MartinSeeler/iterm2-material-design/blob/master/img/screen-mock-1.jpg

1.下载皮肤,在终端中粘贴以下代码:

$ cd Downloads
$ curl -O https://raw.githubusercontent.com/MartinSeeler/iterm2-material-design/master/material-design-colors.itermcolors

2. 打开 iTerm2, 然后到设置(preferences)—— 用户(profiles)—— 颜色(colors)

3. 点击底部的 预设颜色... (Color Presets...)

4. 点击导入,然后找到下载文件夹里面刚才下载的扩展名为itermcolors的文件

5. 再从下拉菜单中选择刚导入的皮肤文件。

加载皮肤配置

管理扩展

oh-my-zsh 内绑定了不少扩展,这里是列表:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins

绝大多数的扩展都未默认启用,若你想启用某些扩展,需要修改其配置文件。

在 iterm2 中输入以下代码来编辑其配置文件:

nano ~/.zshrc

在文件中找到如下代码:

# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
)

这里就是配置扩展的地方,可以看到其默认启动了git扩展。要添加新扩展只要在括号里加名字即可,要注意的是,扩展越多,终端启动和运行就越慢,所以按需添加,比如我加入python常用工具pip:

plugins=(
  git
  pip
)

这样就差不多配置好了。更多配置见这里:https://github.com/robbyrussell/oh-my-zsh/wiki




Git: 删除本地所有分支并保留其中一个

本地分支多了想删掉一些。(下面所有的命令中运行时均需要把 BRANCH_NAME 换成自己要操作的分支的名字)

常用的命令是

git branch -D `BRANCH_NAME`

可是这样只能一个个删除。批量删除并保留一个分支,比如 master 分支的命令可以用下面这条命令:

git branch | grep -v "BRANCH_NAME" | xargs git branch -D 

如果你要经常这么做的话,还可以给这条命令添加个短名:

alias gdbm="git branch | grep -v "BRANCH_NAME" | xargs git branch -D"

如果要保留多个分支,可以在足命令中添加多个分支的名字:master\|develop\|test_branch。

上面的命令就变成:

git branch | grep -v "master\|develop\|test_branch" | xargs git branch -D 



I won’t reinstall my server again

So I reinstalled my server again.

lost all data.

won’t do this again