2019/12/27

wechat subscribe message 订阅消息

1. 选择权回到用户手中。需要用户主动点击授权之后,小程序才能向其推送服务通知,
2、时长不受限制。「订阅消息」取消了7天内推送消息的时间限制,只要用户没有主动拒收消息推送,开发者就可以随时推送服务通知。



2019/12/25

docker image build Dockerfile

docker-compse.yml 内で定義  go のimage
image:xxx/xxx ->直接pull して使う

imageを調査する
 履歴調査 docker image history image_name
 構成調査 docker image inspect image_name

build a image from dockerfile
 docker build --help 

Dockerfile 原則
 1. container from Dockerfile  is ephemeral
 2. one container one process (easy to scale  horizontally)
 3. minimize container layer ( use one-line command. one command one layer)

   RUN apt-get update && apt-get install -y \
  bzr \
  cvs \
  git \
  mercurial \
  subversion

 4. docker build dockerfile_path (---no-cache=true)
     run commands in dockerfile to create layer.
     but first to search cache (sha256のchecksumがあり)あれば、使う。 

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一大堆



2019/09/25

docker-sync ruby error

xcodeアップデートしますかを聞かれて、アップデートした。
docker-syncがエラー

docker-sync start
mkmf.rb can't find header files 

ruby versionの管理が混乱になっている。
rbenvを導入

 brew update
 brew install rbenv ruby-build
rbenv install -l
rbenv install 2.6.4
エラー、BUILD FAILED (OS X 10.。。。。
sudo chmod -s /usr/sbin/dtrace
RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install
でrubyをインストールできた。
which gem
which ruby
gem list
gem install docker-compose
gem install docker-sync
でOK

2019/09/02

2019/07/05

E talking 20190703


the statute(法令) of limitations
prescription 処方箋、取得時効
How many year is the statute of limitation in France.

For example, I borrowed 1000 yen from you. and you never  asked me to return your money for ten years. 
then i will not have to return your money because of the statute fo limitations.
you will lose your right.

For example, A man has three sons and He saved  3000 yen. When he die ,How much will   his  each son will get  from him .
That is a problem about  inherence

i dont remember 覚えていない
i cant remember 思い出せない

I will play guitar when i really have other things to do. The priority is low.


estate財産, real estate不動産
certification 資格
By the law ,there must be one employee with certification per 5 employees
employee 従業員
employer 雇用主
supe rior 上長

borrow a book from you. (無料?)
you lend you a book
rent you the book(有料)


They told me that my superior said many bod things about me when they had lunch together.
Then somedays later ,i had a chance to have lunch together with my superior.
And i certified that bad things with my superior , he known nothing about that.
i think they just wanted to make the relationship bad 

in a short term, i met my wife by chance for many times.and we talked a lot .

2019/06/27

delete file with special name

```
find . -name "*conflict*" -type f | xargs -I {} echo  "rm -fv \"{}\"" | tee test.log
sh test.log
```

find->xargs echo ->tee

2019/06/25

gvm change gopath

go env
gvm pkgset list
gvm pkgenv xxx
edit it
gvm pkgset use xxx

e talk 20190619


two situation. which one is better?
organized by the nursery school.

want to retire when i am 40s .forties
you will on your vacation next week?
I dont own a car.
I cant drive a car. (i dont have a drivers license.)
butterfly swimming
they are afraid of me because i  can be be better than them. you know i am an adult,

sports center gym  fitness
korean cheese chicken 

others is hell
hell is other people
other people is troublesome
he has no friend. he lives with his two dogs.
he married with a b-list movie star.
a-list b-list c-list
not famous 
actor 男優
actress 女演
common people
ordinary person
suddenly i found my daughter has become  a child from a baby
leading dancer.
a stage play. 舞台

are you proud of her?
no, everyone will be better a little while.

I think she didnt have a smartphone.
it is difficult to understand the path to the station.
i told her the path
she gave up the asked me an easy position to go to .
at the end she told me she was from Taiwan.
a 70s old woman.

carry the baby
hold her baby because the mother was busy.
i cant image better things.
everyone is friendly. i think that is enough.

2019/06/14

e talk 20190612


one person per family
his patient has limit.more patient please…
he was a doctoral student ,he need money and project to finish his doctoral course.
he is a rich man and maybe an alcoholic(酒精中毒患者) alcoholism 
(be addicted to alcohol)
ladyboy bar 

i think there is nothing  special about that company.

what about your dances review?

is that legal(lawful)

there was a flexible time schedule to go to work
I looked after about 100 servers for 5 smart phone applications.
very large daily active users.

i made many automatic tools to help my job.
a job introduced by my friend
an evil  company(ブランク企業)
bankruptcy—>破綻。。

rent a room
rent his factory to other people
debt借金
claim債権  have a  claim against him.  

what is you most proud project?

developing a system for part time jobber

i will be changing jobs in a year-->In a year 一年以降。。
recruit a teacher.

job seeking ,job hunting   job search.

2019/06/11

trump twitter

america can't afford you.pay your damn(畜生 ) bills
his descendant will be recluses,
is tantamount to doing sth 跟什么什么一样。。。
owe欠钱 own
doubt it 怀疑


e speaking 20190522


immigration
midlife-crisis
i am not in a hurry

permanent residency
president
resident
residency

co-worker. not friend

what is the most convenient spot for you?

plastic garbage 

employment, human resources
accounting
korean tribe

movie ,film
sf—>science fiction

young sister

at the age of fifty

undercover rules

masters lesson

E speaking 20190605

tell me about the last time
  you laughed really hard
  you went on vacation
 you went to movies
 you bought something ridiculously expensive
 you stumbled(躓いた つまづいた 绊倒了) and fell

tell told told
talk talked talked
she say she had told me.
i just looked forward, there are many people at the crosswalk and the fence's color is different from others. i stumbled by the fence and felled over.

ask staff's complaints then quarrel with boss
one hundred thousand

go through your resume

time is up

rid yourself of such troublesome thing


2019/05/30

English talk memo 20180529

selfish
selfless

outgoing
extroverted
introverted

be tired of watermelon,i am sick of it(i am sick of you?)
be tried from my work

have no courage to admit that he is a gay

an honest man

second hand goods ,new goods

confident

i am angry with
be furious with

everyone is stubborn.

fill many application forms

a modest person

a plate with nazi icon

He is a military man

the dragon is like some fighter plane

she has been hurt a lot by her husband

his mother has no vitality.like some plant

the main guy's wife wants to be conquered by someone.

divorce with his wife.

beat someone up for something.

using candid camera

investment exams

her favorite fruit is durian. 榴莲
dragon fruit 火龙果
avocado

schoolmate, alumni 校友

plum wine 梅酒

violent 暴力的

obsessed with something 迷上了什么事情

loose weight

infant 婴儿

miserable 悲惨的な





i am an engineer. i go to work almost everyday.
i am waiting for you.
i have already told you the detail.
i have always been wanting to go there.

i came to japan 11 years ago.
i was doing my homework at that time.
She said she had told you.
she had been wait for three hours when you came.

i will fly to the USA tomorrow.
i will be doing my homework tomorrow 7 am.
i will have finished my homework tomorrow.
i will have been working for an hour when you come to see me tomorrow 7 am.

she said she was going to buy a new car(she would buy a new car).
she said she could not come here because she would be having a meeting.
i would have told you yesterday( but i forgot it.)
what would Jim have been working on after 11 pm yesterday







2019/03/27

gin,appengine,graphql test


gin+GAE+graphql のテスト下記で行けった。


appEngineTestInstance
->instance.NewRequest
gin.Context(request)
context.Set(key value)

```
ins, _ := aetest.NewInstance(nil)
req, _ := ins.NewRequest("", "", nil)

var context *gin.Context
context = &gin.Context{Request: req}
b, _ := json.Marshal(x.y{z: "1"})
context.Set("key", b)
```

2019/03/18

2019/03/05

Removing packages installed with go get

juse delete the source and package
麻烦,要是有一个命令就好了,找一下

It's safe to just delete the source directory and compiled package file. Find the source directory under $GOPATH/src and the package file under $GOPATH/pkg/<architecture>, for example: $GOPATH/pkg/windows_amd64.


example
go get github.com/golang/mock/mockgen


go clean -i github.com/golang/mock/mockgen

The -i flag causes clean to remove the corresponding installed
archive or binary (what 'go install' would create).

The -n flag causes clean to print the remove commands it would execute,
but not run them.

The -r flag causes clean to be applied recursively to all the
dependencies of the packages named by the import paths.


The -x flag causes clean to print remove commands as it executes them.

不知道安装的packagePath的话,找一下$GOPATH/pkg/windows_amd64啥的

2019/03/04

go gin validator omitempty

細かくて面倒

・Pointer推奨、nilとZeroValueを区別するため
・bindingはpointerに対しても有効
・omtiemptyが必須ね。。

type XXXRequest struct {
Adate *time.Time `json:"aDate,omitempty" time_format:"2006-01-02”` 
B *float64`json:"b,omitempty" binding:"omitempty,min=-90,max=90”` 
C *float64 `json:"c,omitempty" binding:"omitempty,min=-180,max=180”`
}

2019/02/25

swagger 更新されない

Swagger.yamlを修正しても、8090をアクセスして変更されない
docker-componseでup ,down変わらない
docker image,containerでrmで変わらない

BrowerのCacheが。。。。
迷惑だから、勝手にCacheしないてを言いたい
(cmd shift r常識の、面倒)

2019/02/21

golang pointer compare

Pointer values are comparable. Two pointer values are equal if they point to the same variable or if both have value nil

2019/02/18

jmeter org.apache.commons.httpclient.NoHttpResponseException

規律的に半分が上記のエラーになった。
良くわからない、
Server側が一方的に拒否した?
HttpHeaderの設定で、KeepAliveをOffして、治った。
今回のテスト対象がnginx + djangoなので、keepaliveの設定が悪い疑惑!
また調べる。
https://road288.hatenablog.com/entry/2017/12/13/095408
https://qiita.com/edward999th/items/bc730faed3ca38760a26
https://www.ibm.com/developerworks/jp/opensource/library/os-django/index.html

2019/02/11

http options

投石问路

   サーバーがサポートするリクエストメソッドを調べるには、curlを使用してOPTIONS要求を発行します。
curl -X OPTIONS http://example.org -i
レスポンスには、許可されたメソッドを持つ Allow ヘッダが含まれています:
HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST
Cache-Control: max-age=604800
Date: Thu, 13 Oct 2016 11:45:00 GMT
Expires: Thu, 20 Oct 2016 11:45:00 GMT
Server: EOS (lax004/2813)
x-ec-custom-error: 1
Content-Length: 0

2019/02/10

gke cloudsql

  • create serviceAccount with cloudsql privelage
  • down cloudsql json key
  • create kubectl secert
    ```
    kubectl create secret generic cloudsql-oauth-credentials --from-file=credentails.json=.json
    ```
  • deployment.yaml
    ```
    volumes:
      - name: cloudsql-oauth-credentials
        secret:
          secretName: cloudsql-oauth-credentials
    
      - name: ssl-certs
        hostPath:
          path: /etc/ssl/certs
    
      - name: cloudsql
        emptyDir: {}
    
    
    - name: cloudsql-proxy
      image: gcr.io/cloudsql-docker/gce-proxy:1.11
      command: ["/cloud_sql_proxy",
                "-instances=projectName:region:instance=tcp:3306",
                "-credential_file=/secrets/cloudsql/credentials.json"]
      ports:
        - containerPort: 3306
          protocol: TCP
      securityContext:
        runAsUser: 2  # non-root user    allowPrivilegeEscalation: false
      volumeMounts:
        - name: cloudsql-oauth-credentials
          mountPath: /secrets/cloudsql
          readOnly: true
    ```

k8s message=Required "container.clusters.get" permission(s) for

circleICIの作業でGCR PUSH、K8S Deployの作業で、権限がない言われた。。
適切にCI のServiceAccountに
```
Kubernetes Engine Admin
Kubernetes Engine Cluster Admin
Storage Admin
Storage Object Viewer
```
を与えが、、それで権限ないで意味がわからない。。。イライラ

で、CI ServiceAccountを削除して、作り直し、だめ。。。
で、違う名前のCI ServiceAccountを作成して、OK
意味がわからない。。。

推測で、検証待ち。。
昔、誰が、権限がない同じ名前のCI用ServiceAccountを作成したことがあるからだめが、、

2019/01/27

k8s show nfs content

kubectl get pods
kubectl describe pod somepod
kubectl exec nfs-server-pod-name -c containerInPod -it -- /bin/bash
   showmount -e localhost
   ls -al

2019/01/25

window10 C drive 謎の容量圧迫

C Diverが50G位の空きがあったが、突然赤くなった。。70Mしか空きがない。。。
各FolderのSizeをCheck、明らかに合わない

怪しい物を探し、
C:¥Windows¥Temp
C:¥Windows¥Temp1
が50G位の大きさで、
削除して解決。。。。

git rebase merge

Mergeを取り消したく、
git rebase -i でしたが、MergeのCommitが出ない

git rebase -i -p commit-number  で解決した。

2019/01/24

golang graphql input parameter Args array

```
func someApi() *graphql.Field {
   return &graphql.Field{
      Type: someType,
      Args: graphql.FieldConfigArgument{
         "a": &graphql.ArgumentConfig{
            Type: graphql.String,
         },
         "b": &graphql.ArgumentConfig{
            Type: graphql.String,
         },
         "c": &graphql.ArgumentConfig{
            Type: graphql.NewList(graphql.Int),
         },
      },
      Resolve: func(p graphql.ResolveParams) (interface{}, error) {
            return someType
      }
```

git change upstream branch

git branch -vv
git branch --set-upstream-to origin/someBranch
(git branch -u origin/someBranch)

2019/01/21

windows10 sleep wakeup taskschdule

・sleep   shutdown.exe /h

・wakeup  shutdown.exe /r
    ー>最上階位特権で実行
 ー>SLeepを解除
 ー>ログオフでも実行
 
・powercfg -h on
  休眠モードを有効に

・電源高級オプション
 TaskScheduleよりSleep解除を有効に

2019/01/06

linux usb iso

#ISOをUSBにする
sudo dd if=./xx.iso of=/dev/sdx

centos mount ntfs

```
su
yum -y --enablerepo=epel install dkms fuse-ntfs-3g

fdisk -l
mkdir /mnt/a
mout -t ntfs-3g /dev/sdb1 /mount/a

NTFS-3G is an open source implementation of NTFS that includes read and write support. NTFS-3G developers use the FUSE file system to facilitate development and to help with portability.

vi /etc/fstab

```