2019/12/24

ninson ignore

-ignore='Path .git' 
-ignore='Path .github' 
-ignore='Path docker-compose' 
-ignore='Path .idea' 
-ignore='Name *.gitignore'

docker mac performance

docker use linux kernel almost as native, so performance is well.
in mac or windows, things are different. there is no linux kernel.
so some helper needed.

docker-machine:   a tool to install docker in virtual machine. Dockerized hosts (hosts with Docker Engine on them).

docker for Mac/Windows:  even still run a virtual machine (super hidden ).with its own hypervisor “hyperkit” and shared file system “osxfs”. Unfortunately, “osxfs” wasn’t very fast.

but in many cases, realtime host-virtual consistence is not necessary.
So options come
 host first docker run -v hostDir1:/virtualDir1:cached  
 virtual first docker run -v hostDir1:/virtualDir1:delegated
 realTime run -v hostDir1:/virtualDir1:consistent 

docker run exec

「docker run」コマンドは、コンテナを作成して起動するコマンド。
docker run  -it image_name "/bin/bash"
他のTabでdocker ps
Containerが増える。
実質は:
     docker create image_name
    docker start image_name


「docker exec」コマンドは、起動中のコンテナ内で、指定したコマンドを実行するコマンド。
docker ps
docker exec -it container_id "/bin/bash"




docker-run options image_name init_command
-- name (起動されたContainerに名前)
-- rm (Container終了時削除)
-v  fromHostSrc:toContainerTarget-e   env parameters
-d  run in backend

docker-sync start サンプル:
docker run --rm -v "dir1:/app_sync" -v "dir2:/host_sync" -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=$(basename $(dirname `readlink /etc/localtime`))/$(basename `readlink /etc/localtime`) -e UNISON_SRC="/host_sync" -e UNISON_DEST="/app_sync" -e UNISON_ARGS=" -ignore='Name .git' -ignore='Name .idea' -ignore='Name mysql_data' -prefer /host_sync -numericids -auto -batch" -e UNISON_WATCH_ARGS="-repeat watch"  --name backend-service eugenmayer/unison:2.51.2.1 /usr/local/bin/precopy_appsync

試しに一回起動してすぐ削除されたので、また起動
docker run -d -v "dir1:/app_sync" -v "dir2:/host_sync" -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=$(basename $(dirname `readlink /etc/localtime`))/$(basename `readlink /etc/localtime`) -e UNISON_SRC="/host_sync" -e UNISON_DEST="/app_sync" -e UNISON_ARGS=" -ignore='Name .git' -ignore='Name .idea' -ignore='Name mysql_data' -prefer /host_sync -numericids -auto -batch" -e UNISON_WATCH_ARGS="-repeat watch"  --name backend-service eugenmayer/unison:2.51.2.1



2019/12/20

wechat miniapp login


  • wechat miniApp:  wx.login -> code
  • wechat miniApp: wx.request , send code to server api
  • server request 
    • wechat API,get openId and sesion_key: https://api.weixin.qq.com/sns/jscode2session?appid=a&secret=b&js_code=codegrant_type=authorization_code
    • use openId and session_key to generate access token
    • response access token and openId to miniAPP(token1)
  • wechat miniApp: wx.getSetting check user's authority.if not ,request user's authority.
  • wechat miniApp: wx.getUserInfo can get user info.
  • server request wechat api to get token(token2) :
    • https://api.weixin.qq.com/cgi-bin/token?appid=a&secret=b&grant_type=client_credential
  • server request wetchat api use token 

docker show all container ,delete all



  • docker show all container :     docker container ls -a
  • docker show volume:   docker volume ls 
  • docker show image: docker image ls
  • delete all unused objects:        docker system prune -f --volumes
  • delete all images:  docker image prune -a
  • docker-compose up -d  --remove-orphans
スキリした。普通に30Gぐらい削除した。unusedの基準は曖昧かな


2019/12/18

golang gorm update when record not exist

when record is not exist. update will be success.
have to check RowsAffected .
the same as delte

query := db.Model(r).Updates(something)
if query.Error != nil {
   return query.Error
}
if query.RowsAffected == 0 {
   return gorm.ErrRecordNotFound
}



query := db.Delete(&something{ID: ID})
if query.Error != nil {
   return query.Error
}
if query.RowsAffected == 0 {
   return gorm.ErrRecordNotFound
}

2019/12/16

MacOS bad support on HFS/APFS

 MacOS/OSX has very bad filesystem events support on HFS/APFS, watching the file-system for changes using unox or fswatch was causing a heavy CPU load. This CPU load is very significant, even on modern high-end CPUs (like a i7 4770k / 3.5GHz).


2019/11/24

android app without cm and gms

使う時使ってもらっていいじゃない?
情報を収集してなにをやりたい?

huawei 端末にgmsがないからいいかも
apk market: apk pure
apk manager: xapk manager
mp3 player: plusar
japanese input: Japanese Keyboard

2019/11/19

gorm 问题



  • 多了许多()  query := db.debug.Where(fmt.Sprintf("id in ( %s )", “1,2,3”))=>SELECT * FROM `a`  WHERE `a`.`deleted_at` IS NULL AND ((id in ( 1,2,3 )))
  • preload 时ID一大堆