[Serverless] How to use Python3 lxml on AWS Lambda

tl;dl Use custom docker image. Error on sls deploy When I used pyquery and lxml through serverless-python-requirements, I got error on sls deploy $ sls deploy Serverless: Installing required Python packages with python3.6… Serverless: Docker Image: lambci/lambda:build-python3.6 Error ————————————————– Command “/var/lang/bin/python3.6 -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-i6bvdeoo/lxml/setup.py’;f=getattr(tokenize, ‘open’, open)(__file__);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, __file__, ‘exec’))” –no-user-cfg install –record /tmp/pip-kscbnc2r-record/install-record.txt –single-version-externally-managed –compile –home=/tmp/tmpslfe9grl” failed with error code 1 in /tmp/pip-build-i6bvdeoo/lxml/ You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the ‘pip install –upgrade pip’ command. For debugging logs, run again after setting the “SLS_DEBUG=*” environment variable. Stack Trace ——————————————– Error: Command “/var/lang/bin/python3.6 -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-i6bvdeoo/lxml/setup.py’;f=getattr(tokenize, ‘open’,…

Read More

[OSX Setup] n (nodejs): Permission denied

tl;dr # error on install n install 8.2.1 mkdir: /usr/local/n/versions/node: Permission denied mkdir: /usr/local/n/versions/io: Permission denied # create dir before install sudo mkdir /usr/local/n sudo chown -R $(whoami) $_ # then success n install 8.2.1 Ref: GitHub: Permission denied before running with sudo #416

Read More

Golang Error: invalid type for composite literal

In my case, the underlying type is not struct. // Device contains strings of the device name type Device string // NativeDevice stands for smartphone app(e.g. iOS/Android) type NativeDevice Device // AppleDevice stands for iOS device. type AppleDevice NativeDevice // Error pattern: using `struct type` for AppleDevice. func NewIPhoneDevice() AppleDevice { return AppleDevice{} // => Error: invalid type for composite literal. } // Corrent pattern: using `string type` for AppleDevice. func NewIPhoneDevice() AppleDevice { return “iphone” // use `string` } https://play.golang.org/p/cLSmvB4bZD2

Read More

Xiaomi Mi A1のSIMカードトレイの交換

旅行先でSIMカードトレイを無くしてしまったため、Parts4Repairで代わりのスペアを注文することにしました。 SIMカードトレイが$2.9, 送料が$3.53で、合計$6.43でした。 めちゃくちゃ安くてビビります。

Read More

How to check/confirm SSH secret key password | SSH用秘密鍵のパスワードを確かめる方法

Answer is from: stackoverfrow | How do I verify/check/test/validate my SSH password? $ ssh-keygen -y -f <key file> $ ssh-keygen -y -f my_key.pem # corrent password Enter passphrase: ssh-rsa AAAABBBBCCCCDDDDEEEEFFFF…. # wrong password Enter passphrase: Load key “/Users/takuma/.ssh/eureka.pem”: incorrect passphrase supplied to decrypt private key ssh-keygen has many feature…

Read More

Command to clean unused Docker container/images/volumes to get disk space | 不要なDockerコンテナ・イメージ・ボリュームを削除するコマンド

# check disk size df -h docker run –rm alpine df -h # remove stopped container, unused images, unused volumes docker rm $(docker ps -q -f ‘status=exited’) docker rmi $(docker images -q -f ‘dangling=true’) docker volume rm $(docker volume ls -q -f ‘dangling=true’) # check disk size again df -h docker run –rm alpine df -h

Read More

Indirect expantion in shellscripit on Alpine – Bash以外での変数の間接展開

tl;dr use eval “echo \${$FOO}” #!/bin/sh VALUE1=”happy!” # target value ENV_VAR=VALUE1 # variable bname echo $VALUE1 # => happy! echo $ENV_VAR # => VALUE1 echo ${ENV_VAR} # => VALUE1 echo \${$ENV_VAR} # => ${VALUE1} #=== ash or other shells ===# eval “echo \${$ENV_VAR}” # => happy! #=== bash supports original indirect expantion, but not ash on Alpine linux ===# echo ${!ENV_VAR} #=== example for “if” “test” conditions ===# test -n $ENV_VAR \ # (1) && test “$(eval “echo \${$ENV_VAR}”)” == “happy!” \ # (2) && echo “I’m Happy!!” # (1) if ENV_VAR is set, # (2) and if $VALUE1 == “happy!”

Read More

pandasメモ(axis, level)

axis=0: 行を対象に処理を実行 axis=1: 列を対象に処理を実行 level=[0,1,2]: groupby() や set_index() で使われるMultiIndexに対して、対象となるIndex(順番)の指定 df.stack // 列を行に旋回(ピボット)する df.unstack // 行を列に旋回(ピボット)する df.replace // データの置換を行う df.rename // 軸の命名を変更する df.drop_duplicated // 重複データの削除 df.qcut // ビニング

Read More