About neohope

一直在努力,还没想过要放弃...

从BootCamp中提取HFS驱动

一、说明:
1、如果你是MAC,那直接安装Bootcamp就好了,别瞎折腾

2、如果你只想用这个驱动,来这里下载https://forums.macrumors.com/threads/apple-hfs-windows-driver-download.1368010/

3、即使你折腾成功了,也是只读,无法写入

4、Bootcamp的版本是通过下面的条件划分的
A、MAC硬件版本
B、Windows操作系统版本(win7、win8、win10、x86、x64)
C、发布版本
从而,直接查找Bootcamp,本身就成了一件很痛苦的事情

5、Bootcamp的HFS驱动文件的默认安装位置为
C:\Windows\System32\drivers\AppleHFS.sys
C:\Windows\System32\drivers\AppleMNT.sys
而文件系统驱动是与MAC硬件版本无关的,所以我们只需要考虑B、C两个问题就好了

二、然后说HFS驱动提取的方式:
1、按上面所说的,驱动提取只需要考虑Windows操作系统版本和Bootcamp发布版本就可以了,是不需要考虑MAC硬件版本的
2、下载后,解压文件
3、将AppleHFS.sys、AppleMNT.sys拷贝出来
4、备份注册表(这一步一般来说是可以省掉的)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleHFS
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleMNT

一般来说用下面的文件进行安装和卸载就好了:
Add_AppleHFS.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleHFS]
"Type"=dword:00000002
"ErrorControl"=dword:00000001
"Start"=dword:00000000
"Group"="File System"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleMNT]
"Group"="System Bus Extender"
"Type"=dword:00000001
"ErrorControl"=dword:00000001
"Start"=dword:00000000

Remove_AppleHFS.reg

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleHFS]

[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleMNT]

5、这样驱动提取就完成了

三、HFS驱动的安装方式:
1、一定要核对windows版本与驱动提取的版本信息是一致的才可以(win7、win8、win10、x86、x64)
2、将驱动拷贝到指定路径
C:\Windows\System32\drivers\AppleHFS.sys
C:\Windows\System32\drivers\AppleMNT.sys
3、双击Add_AppleHFS.reg
4、重启即可

四、HFS驱动的卸载方式:
1、双击Remove_AppleHFS.reg
2、重启
3、删除驱动文件
C:\Windows\System32\drivers\AppleHFS.sys
C:\Windows\System32\drivers\AppleMNT.sys

五、兼容Win10方式:
1、按上面的方式安装驱动
2、打开磁盘管理器,从磁盘0的第一个卷,一直数到你想挂在的HFS卷,记录卷的序号,比如我有几块硬盘,我想挂载的卷是第10个卷(要注意,没有挂载的卷也是要计算的)
3、修改注册表

#位置
HKEY_LOCAL_MACHINE/system/CurrentControlSet/Control/Session Manager/DOS Devices/
#新建String类型的键值对
#左边的Key就是你想挂在的盘符,比如
#N:
#右边的Value就是卷的序号
#\Device\HarddiskVolume序号
#比如你是第10个卷,那就是
#\Device\HarddiskVolume10

4、重启,如果卷号错了,就调整一下再重启
5、只是一个临时方案,不太适合移动设备,有些太麻烦了

Prolog101(09)

现在我们使用列表,重写一下room.pl文件。

%swipl -s roomlist.pl
%Hansen

%动态函数声明
:-dynamic here/1.
:-dynamic location_list/2.
:-dynamic bag_list/1.
:-dynamic take_thing/2.
:-dynamic put_thing/2.

%房间定义
room(X):- room_list(List),member(X,List).
room_list([kitchen,office,hall,diningroom,cellar]). 

%门定义
door(X,Y):- door_list(List),member([X,Y],List).
door_list([[office, hall],[kitchen, office],[hall, diningroom],[kitchen, cellar],[diningroom, kitchen]]).

%规则:有门的两个房间是相通的
connect(X,Y):- door(X,Y).
connect(X,Y):- door(Y,X).

%物品在哪个房间
location(X,Y):- location_list(List, Y), member(X, List).
location_list([apple, broccoli, crackers], kitchen). 
location_list([desk, computer], office).
location_list([flashlight, envelope], desk).
location_list([stamp, key], envelope).
location_list([], hall).
location_list([], diningroom).
location_list([washingmachine], cellar). 
location_list([nani], washingmachine).

%房间减少物品
take_thing(Thing, Place):- 
retract(location_list(List, Place)),
delete(List,Thing,ThingsLeft),
asserta(location_list(ThingsLeft,Place)). 

%房间增加物品
put_thing(Thing, Place):-  
retract(location_list(List, Place)),
asserta(location_list([Thing|List],Place)).

%背包有哪些物品
bag(X):-bag_list(List), member(X, List).
bag_list([tourch]).

%背包增加物品
bag_in(Thing):- 
retract(bag_list(List)),
asserta(bag_list([Thing|List])).

%背包减少物品
bag_out(Thing):-
retract(bag_list(List)),
delete(List,Thing,ThingsLeft),
asserta(bag_list(ThingsLeft)). 

%哪些物品可以吃
edible(X):- 
member(X,[apple,crackers,broccoli]).

%当前位置
here(hall).

%房间之间移动
move(Place):- can_go(Place),retract(here(X)), asserta(here(Place)).
can_go(Place):- here(X), connect(X, Place).
can_go(Place):- write('You can''t go to '),write(Place),write(' from here.'), nl, fail.

%拿起物品
take(X):- can_take(X), here(Place), take_thing(X,Place), bag_in(X), write(X), write(' taken.'), nl.
can_take(Thing):- here(Place), location(Thing, Place).
can_take(Thing):- write('There is no '), write(Thing), write(' here.'), nl, fail.

%放下物品
put(X):- can_put(X), here(Place), bag_out(X), put_thing(X,Place), write(X), write(' put.'), nl.
can_put(Thing):- bag(Thing). 
can_put(Thing):- write('There is no '), write(Thing), write(' in your bag.'), nl, fail. 

%房间物品列表
list_things(Place):- location(X, Place),tab(2),write(X),nl,fail.
list_things(_).

%与Place相连的房间
list_connections(Place):- connect(Place, X),tab(2),write(X),nl,fail.
list_connections(_).

%持有物品列表
list_bag(Thing):- bag(X),tab(2),write(X),nl,fail.
list_bag(_).

%吃东西
eat(Thing):- can_eat(Thing), bag_out(Thing), write(Thing), write(' eaten. Yummy!').
can_eat(Thing):- bag(Thing), edible(Thing).
can_eat(Thing):- not(bag(Thing)), write('There is no '), write(Thing), write(' in your bag.'), nl, fail. 
can_eat(Thing):- bag(Thing), write('You can''t eat the '), write(Thing), write('.'), nl, fail. 

%查看房间情况
look :-
here(Place), write('You are in the '), write(Place), nl,
write('You can see:'),nl,list_things(Place),  
write('You can go to:'), nl, list_connections(Place),
write('You have:'),nl,list_bag(Thing).

%帮助
game :-
write('Look around: look/0'),nl,
write('Move around: move/1'),nl,
write('Take something: take/1'),nl,
write('Eat something: eat/1').

进行查询

%查找与kitchen相连的房间
1 ?- findall(X, connect(kitchen, X), List).
List = [office, cellar, diningroom].

%查找全部食物与位置
2 ?- findall(foodat(X,Y), (location(X,Y) , edible(X)), L).
L = [foodat(broccoli, kitchen), foodat(crackers, kitchen)].

swipl的奇怪报错

在windows下用swipl命令运行prolog脚本时,经常会遇到下面的错误:

ERROR: char_code/2: Cannot represent due to `character_code'

解决方法有两种:
1、使用swipl-win命令替代swipl命令
2、在macos下使用swipl命令

应该是一个bug,在读入字符时(如;),处理不当导致的。

MacOS使用Prolog命令行工具

1、看一下SWI-Prolog的安装说明,发现命令行工具在下面的路径

/Applications/SWI-Prolog.app/Contents/MacOS

2、修改PATH变量,添加SWI-Prolog命令行工具在下面的路径

#查看命令行工具
cd /Applications/SWI-Prolog.app/Contents/MacOS
ls

#查看PATH变量
echo "$PATH"

#修改PATH变量
vi $HOME/.bash_profile
#增加一行
export PATH=${PATH}:/Applications/SWI-Prolog.app/Contents/MacOS

3、重启命令行

#查看PATH变量
echo "$PATH"

#测试一下
swipl hello.pl 

MongoDB数据引用(Shell)

1、被引用数据

db.address.insert({"city":"shanghai","street":"huaihai road","no":"101"})
db.address.insert({"city":"beijing","street":"taipingqiao road","no":"102"})

2、引用数据

db.persons.insert({"name":"joe","address":{"$ref":"address","$id": ObjectId("55f522e96811e30fd403e83d"),"$db": "test"},"age":20,"sex":"male"})
db.persons.insert({"name":"leo","address":{"$ref":"address","$id": ObjectId("55f522f46811e30fd403e83e"),"$db": "test"},"age":21,"sex":"male"})

3、查询被引用数据

var user = db.persons.findOne({"name":"joe"})
var addressRef = user.address
db[addressRef.$ref].findOne({"_id":(addressRef.$id)})

远程预诊存在的问题

现在不少公司在推远程预诊,或者视频问诊,但没有一家真正解决了下面的问题:
1、没有足够的专业医疗队伍资源,在我的另一篇博文中已经说明原因,并指出医学院学生及退休医生是可以考虑的资源
2、没有专业设备,可以获取患者的第一手资料。必须有设备的技术变革,例如大白去掉AI功能。(高清视频音频、心率、血压、脉搏、血糖、呼吸等等等等)
3、没有好的盈利模式,单纯靠吸引患者就诊不太可取,单纯靠卖保健品。。。
4、没有解决患者实际问题,预诊后要做什么呢(请到XX医院做进一步治疗?),患者仅仅多排了一次队浪费时间而已
5、患者不信任,不愿意承担风险,需要一个漫长的过程

那现在能做的是什么呢?
1、慢性病的跟踪治疗,比如高血压、糖尿病等
2、私人诊所的个人咨询
3、私人护理的定期巡诊

与上面最大的区别是什么呢?
1、医患之间有过接触,有了信任
2、医生了解患者的病情
3、患者病情不是很紧急
4、医院可以持续盈利

要预防什么呢?
1、高大上的产品变成了产品推销平台
2、打擦边球,因此医疗事故,触犯法律
3、乱烧钱,最后不了了之

MongoDB的ObjectId(Shell)

MongoDB中存储的文档必须有一个”_id”键。这个键的值可以是任何类型的,默认是个ObjectId对象。该_id用来确保集合里面每个文档都能被唯一标识,并用来在多个服务器上同步数据。

ObjectId是一个12字节BSON类型数据,格式如下:
前4个字节表示时间戳
接下来的3个字节是机器标识码
接的两个字节由进程id组成(PID)
最后三个字节是随机数

myObjectId = ObjectId()
myObjectId.getTimestamp()

ACID、BASE与CAP

一、关系型数据库遵循的ACID原则

1、A (Atomicity) 原子性
原子性很容易理解,也就是说事务里的所有操作要么全部做完,要么都不做,事务成功的条件是事务里的所有操作都成功,只要有一个操作失败,整个事务就失败,需要回滚。

比如银行转账,从A账户转100元至B账户,分为两个步骤:1)从A账户取100元;2)存入100元至B账户。这两步要么一起完成,要么一起不完成,如果只完成第一步,第二步失败,钱会莫名其妙少了100元。

2、C (Consistency) 一致性
一致性也比较容易理解,也就是说数据库要一直处于一致的状态,事务的运行不会改变数据库原本的一致性约束。

例如现有完整性约束a+b=10,如果一个事务改变了a,那么必须得改变b,使得事务结束后依然满足a+b=10,否则事务失败。

3、I (Isolation) 独立性
所谓的独立性是指并发的事务之间不会互相影响,如果一个事务要访问的数据正在被另外一个事务修改,只要另外一个事务未提交,它所访问的数据就不受未提交事务的影响。
比如现有有个交易是从A账户转100元至B账户,在这个交易还未完成的情况下,如果此时B查询自己的账户,是看不到新增加的100元的。

4、D (Durability) 持久性
持久性是指一旦事务提交后,它所做的修改将会永久的保存在数据库上,即使出现宕机也不会丢失。

二、非关系型数据库遵循的BASE原则
BASE:Basically Available, Soft-state, Eventually Consistent。 由 Eric Brewer 定义。
1、Basically Availble –基本可用
2、Soft-state –软状态/柔性事务。 “Soft state” 可以理解为”无连接”的, 而 “Hard state” 是”面向连接”的
3、Eventual Consistency –最终一致性 最终一致性, 也是是 ACID 的最终目的。

三、CAP定理(CAP theorem)

在计算机科学中, CAP定理(CAP theorem), 又被称作 布鲁尔定理(Brewer’s theorem), 它指出对于一个分布式计算系统来说,不可能同时满足以下三点:
1、一致性(Consistency) (所有节点在同一时间具有相同的数据)
2、可用性(Availability) (保证每个请求不管成功或者失败都有响应)
3、分隔容忍(Partition tolerance) (系统中任意信息的丢失或失败不会影响系统的继续运作)

CAP理论的核心是:一个分布式系统不可能同时很好的满足一致性,可用性和分区容错性这三个需求,最多只能同时较好的满足两个。
因此,根据 CAP 原理将 NoSQL 数据库分成了满足 CA 原则、满足 CP 原则和满足 AP 原则三 大类:
CA – 单点集群,满足一致性,可用性的系统,通常在可扩展性上不太强大。
CP – 满足一致性,分区容忍必的系统,通常性能不是特别高。
AP – 满足可用性,分区容忍性的系统,通常可能对一致性要求低一些。

CAP理论

举个例子来说,HBase与Cassandra,HBase在CAP中,更偏重于CP,客户端读到的数据是一致的,但性能会差;而Cassandra更偏重于AP,性能好一些,但有时客户端会读到不同的数据。

MongoDB聚合操作(Shell)

0、数据准备

for(var i=0;i<10000;i++){
var patid="pat"+i;
var patname="name"+i;
var sex="M";
var age=parseInt(100*Math.random(i));
db.patient.insert({"patid":patid,"patname":patname,"sex":sex,"age":age,address:{"city":"shanghai","street":"huaihai road"}});
}

1、count

db.patient.count({"age":12})

2、distinct

db.patient.distinct("age")

3、min, max, sum,avg

db.patient.aggregate([{$group:{_id:"$item",maxAge:{$max:"$age"}}}])
db.patient.aggregate([{$group:{_id:"$item",minAge:{$min:"$age"}}}])
db.patient.aggregate([{$group:{_id:"$item",sumAge:{$sum:"$age"}}}])
db.patient.aggregate([{$group:{_id:"$item",avgAge:{$avg:"$age"}}}])

4、group

db.patient.group({
"key":{"age":true},
"initial":{"patids":[]},
"reduce":function(item,out){out.patids.push(item.patid);},
"finalize":function(out){out.count=out.patids.length;},
"condition":{"age":{$lte:18}}
})

5、map reduce

map=function(){emit(this.age,1);}
reduce=function(key,values){return values.length;}
mropt={"out":"mrresult"}
db.patient.mapReduce(map,reduce,mropt).find()