JavaScript メモ
ES2015
- let > const > var
その他
- オブジェクトは参照渡し
- 関数の引数は arguments に入っている
- プロトタイプではなく、そのオブジェクトの property を調べる場合は hasOwnProperty()
- || でのデフォルトの指定
- var test = abc.def || 'unkown'
- オブジェクトリテラル {}
- property 名は必要ならクォートをつければよい
- JSLint --> ESLint
- ブロック {} や for などに label: をつけられる。break label; continue label などが使える。
Firebase のメモ
npm の global の保存先の変更 (ホームディレクトリに置くのが一番トラブルがなかった)
1.) Make a directory for global installations: mkdir ~/.npm-global 2.) Configure npm to use the new directory path: npm config set prefix '~/.npm-global' 3.) Update PATH export PATH=~/.npm-global/bin:$PATH
Firebase (Cloud functions)
- firebase (https://console.firebase.google.com/) でプロジェクト作る
- npm install -g firebase-tools # ツールのインストール
- npm install -g firebase-admin
- firebase init
- firebase deploy
- sudo firebase serve --only functions
Update 作業
- npm install -g firebase-tools # 更新のインストール 何回か実行が必要な場合がある
Code
- index.js
exports.homeAutomation = functions.https.onRequest((request, response) = > { response.send("Hello from Firebase!"); });
- 基本的に Express と同じらしい
会社アカウント等での個人 git への誤 commit 防止
- 下記のシェルスクリプトを ~/.git_tempalte/hooks/pre-commit として保存
#!/bin/bash DIR=$(pwd) EMAIL=$(git config user.email) if [[ "$DIR" =~ ^/home/hogehoge/private/ ]] then if [[ ! "$EMAIL" =~ @users.noreply.github.com$ ]] then echo "Error: git config user.email = $EMAIL" exit 1 fi fi
- ファイル実行権限をつける (chmod 755)
- git のテンプレートに設定する。git init 等で自動的に .git/hooks にコピーされる。
git config --global init.templatedir '~/.git_template'
- /home/hogehoge/private/ 以下にあるフォルダで git commit する場合、その git の user.email が @users.noreplay.github.com を含んでなければエラーとなる。 (フォルダと email の規則は例です)
TopCoder メモ
Java Applet が Security 警告で起動しない
- Oracle Java 8 Plugin Control Panel –> Security –> Exception Site List に http://www.topcoder.com を追加する
俺スクリプト
#!/bin/bash function make { MAKE=`which make` if [ ! -f Makefile ]; then $MAKE -f ../Makefile -j9 $* else $MAKE -j9 $* fi } wget --backups=1 http://www.topcoder.com/contest/arena/ContestAppletProd.jnlp javaws ContestAppletProd.jnlp