276篇 Default中的文章

alpine based image to docker compose get error: command 'gcc' failed with exit status 1

Error like this:

Collecting misaka==2.1.1 (from -r requirements.txt (line 12))
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/87/b1020510a00aba1b936477e54180b143df654c565b84936b0b3e85272cf2/misaka-2.1.1.tar.gz (125kB)
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: 
        No working compiler found, or bogus compiler options passed to
        the compiler from Python's standard "distutils" module.  See
        the error messages above.  Likely, the problem is not related
        to CFFI but generic to the setup.py of any Python package that
        tries to compile C code.  (Hints: on OS/X 10.8, for errors about
        -mno-fused-madd see http://stackoverflow.com/questions/22313407/
        Otherwise, see https://wiki.python.org/moin/CompLangPython or
        the IRC channel #python on irc.freenode.net.)
    
        Trying to continue anyway.  If you are trying to install CFFI from
        a build done in a different context, you can ignore this warning.
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/local/lib/python3.7/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/local/lib/python3.7/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/local/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

And my Dockerfile is here:

More ~

PyMongo使用密码连接Mongodb

以前的写法是这样的,

from pymongo import MongoClient
client = MongoClient(host='127.0.0.1')
db = client['dbname']
db.authenticate(user, password)

不过上面的已经废弃

warning:: Starting in MongoDB 3.6, calling :meth:authenticate
invalidates all existing cursors. It may also leave logical sessions
open on the server for up to 30 minutes until they time out.

More ~

就在刚刚,又被面试官的mysql联合索引问题问倒了

MySql经常用,但是通常就是ORM中间件来CRUD操作,很少关注索引问题,可能是我近些年很少用MySQL做大型的系统了。
现在一面试就遇到所有领域的问题来都来一个问一遍,MySQL的复合索引其实也就一知半解。

面试官的问类似于select语句里where a>100 and b=3 and c=1 能否命中创建的(a, b, c)这种索引,还有a>100能否命中这个复合索引。

我想当然就说,a>100 and b=3 and c=1 只能命令(a, b, c)这种索引, a>100不能命中。唉呀,人家笑了。我说我可能说的不对,我下来试试。好吧查资料,建表,亲自实操一把。

More ~

Ubuntu Server 19.04配置静态IP

这个/etc/netplan下默认有个文件50-cloud-init.yaml,直接修改它就行了

sudo vim /etc/netplan/50-cloud-init.yaml

网口名字enp0s3可以通过ip a查到。 这个文件默认已经有网口名字了,将dhcp关闭,填上ip、网关、DNS地址:

network:
    ethernets:
        enp0s3:
            dhcp4: false
            addresses:[192.168.0.201/24]
            gateway4: 192.168.0.1
            nameservers:
                addresses: [192.168.0.1, 8.8.8.8]
    version: 2

保存后,执行 sudo netplan --debug apply 应用更新。
静态IP即可。

More ~

为Ubuntu Server开启SSH

虚拟机安装的Ubuntu Server镜像,向导里需要设置用户账号,没有设置root密码.

1.登陆初始账号,修改root 密码
sudo passwd root

su切换root 试试

2.root 账号下修改配置文件
vi /etc/ssh/sshd_config
找到下面相关配置:

# Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes

更改为:

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

3.重启ssh
sudo service ssh restart

More ~

XCode 10的UI组件库在哪?

我好久不用Xcode,发现以前在右侧边栏的UI组件库不见了,找了半天也没找到,google一搜,还真有不少人我和一样https://stackoverflow.com/questions/51051532/xcode-10-where-are-the-ui-elements

View -> Libraries -> Show Library

Screen Shot 2019-07-24 at 23.35.54.png

或者快捷键 Command + Shift + L

More ~

shell tree in macos

Use find to list the current folder:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Add to ~/.bash_profile or ~/.zshrc
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
  

Or install the tree with brew
brew install tree

More ~

First start ansible on macos

I installed the ansible via pip install, and there are several issues here:

where is the config

Here you should create a file ~/.ansible.cfg

[defaults]
inventory =~/.ansible/hosts
sudo_user=root
remote_port=22
host_key_checking=False
remote_user=root
log_path=~/.ansible/log/ansible.log
module_name=command
private_key_file=~/.ssh/id_rsa
More ~