280篇 Default中的文章

MongoDB: Query fields if not exists

官方文档的解释:
Existence Check

The { item : { $exists: false } } query matches documents that do not contain the item field:

db.inventory.find( { item : { $exists: false } } )

Studio3T里的Query查询条件可以是 {downloaded:{$exists: false}} 即可以查出那些没有这个downloaded字段的数据

More ~

MySQL 启动时报The server quit without updating PID file

在Mac上通过brew安装Mysql后跑想进入数据库报这个
mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

手动启服务 ** mysql.server start ** 报这个
Starting MySQL
...... ERROR! The server quit without updating PID file (/usr/local/var/mysql/pcname.local.pid).

More ~

Python 魔术方法备忘

魔术方法 调用方式 解释
new(cls [,...]) instance = MyClass(arg1, arg2) new 在创建实例的时候被调用
init(self [,...]) instance = MyClass(arg1, arg2) init 在创建实例的时候被调用
cmp(self, other) self == other, self > other, 等。 在比较的时候调用
pos(self) +self 一元加运算符
neg(self) -self 一元减运算符
invert(self) ~self 取反运算符
index(self) x[self] 对象被作为索引使用的时候
nonzero(self) bool(self) 对象的布尔值
getattr(self, name) self.name # name 不存在 访问一个不存在的属性时
setattr(self, name, val) self.name = val 对一个属性赋值时
delattr(self, name) del self.name 删除一个属性时
__getattribute(self, name) self.name 访问任何属性时
getitem(self, key) self[key] 使用索引访问元素时
setitem(self, key, val) self[key] = val 对某个索引值赋值时
delitem(self, key) del self[key] 删除某个索引值时
iter(self) for x in self 迭代时
contains(self, value) value in self, value not in self 使用 in 操作测试关系时
concat(self, value) self + other 连接两个对象时
call(self [,...]) self(args) “调用”对象时
enter(self) with self as x: with 语句环境管理
exit(self, exc, val, trace) with self as x: with 语句环境管理
getstate(self) pickle.dump(pkl_file, self) 序列化
setstate(self) data = pickle.load(pkl_file) 序列化
More ~

pycharm 2017 激活破解license

  1. 打开激活窗口
  2. 选择 Activate new license with: License server (用license server 激活)
  3. 在 License sever address 处填入 https://jetlicense.nss.im/
  4. 点击 Activate 进行认证。
  5. 认证完成就可以使用了。
More ~

swift 访问修饰符

在Swift语言中,访问修饰符有五种,分别为fileprivate,private,internal,public和open。
其中 fileprivate和open是Swift 3新添加的。由于过去 Swift对于访问权限的控制,不是基于类的,而是基于文件的。这样会有问题,所以Swift 3新增了两个修饰符对原来的private、public进行细分。

More ~