Alex Dai Playground

[Laravel] install

| Comments

install

網頁發生錯誤

  • Whoops, looks like something went wrong
建立 .env
cp .env.example .env
設定.env
...
APP_DEBUG=true
...
  • No supported encrypter found. The cipher and / or key length are invalid.

必須重新產生APP_KEY

php artisan key:generate
.env 結果
...
APP_DEBUG=true
APP_KEY=djouxEpOi5B0STO43AJIf60dWmTfp6tX
...

[Docker] remove volume

| Comments

  • 列出所有 voulme

    docker volume ls
    
  • 列出所有未使用 voulme
    -f = --filter

    docker voulme ls -f dangling=true
    
  • 移除所有未使用的 voulme

    docker volume rm $(docker volume ls -qf dangling=true)
    

[AWS] CLI docker login

| Comments

  • 下載 AWS CLI
  • 新增 IAM 使用者 & 賦予權限 AmazonEC2ContainerRegistryFullAccess & AmazonEC2ContainerServiceFullAccess
  • 記下 AWS Access Key ID & AWS Secret Access Key
  • 設定
    > aws configure
    AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
    AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
    Default region name [None]: us-west-2
    Default output format [None]: ENTER
    
    
    


    • 登入
      aws ecr get-login --region us-east-1
      將產生的 docker login -u AWS -p xxxxx..... 指令 貼到 console 執行

    • tag images
      docker tag myImage:latest xxx.dkr.ecr.us-east-1.amazonaws.com/xxx:latest

    • push images
      docker push xxx.dkr.ecr.us-east-1.amazonaws.com/xxx:latest

    • 發生 no basic auth credentials (Docker for Windows)?
      打開 ~/.docker/config.json 並刪除 "credsStore": "wincred" (auth token 才會寫入 config.json)
      重新執行 aws ecr get-login --region us-east-1 步驟

    • http://stackoverflow.com/a/38774620

[React] component lifecycle

| Comments

React component 的生命週期

第一次執行

  • componentWillMount(元件準備寫入DOM)
  • render
  • componentDidMount(元件已被寫入DOM,此時可以操作DOM元素,整合其他第三方套件、發送AJAX請求)

變更 state or props

  • componentWillReceiveProps
  • shouldComponentUpdate (判斷是否要更新,是才往下執行)
  • componentWillUpdate
  • render
  • componentDidUpdate

http://andyyou.logdown.com/posts/178998-reactjs-assembly-operation-and-life-cycle

[Protructor] google login

| Comments

google.login()

// 彈跳視窗
browser.driver.getAllWindowHandles().then(function (handles) {
  browser.driver.switchTo().window(handles[1]);
  console.log(handles);
});

browser.driver.sleep(1500);

var emailInput = browser.driver.findElement(by.id('Email'));
emailInput.sendKeys(email);

var nextButton = browser.driver.findElement(by.id('next'));
nextButton.click();

browser.driver.sleep(1500);

var passwordInput = browser.driver.findElement(by.id('Passwd'));
passwordInput.sendKeys(passwd);

var signInButton = browser.driver.findElement(by.id('signIn'));
signInButton.click();

// 帳號未設定 2 步驟驗證, 選擇 手機上接收 google 提示
// 帳號設定好 以 手機上接收 google 提示 為驗證後,則不必在執行此動作
//browser.driver.sleep(10000);
//var challengePickerList = browser.driver.findElement(by.css('#challengePickerList > li:nth-child(3) form'));

browser.takeScreenshot().then(function (png) {
  var stream = fs.createWriteStream('images/challenge.png');
  stream.write(new Buffer(png, 'base64'));
  stream.end();
});

challengePickerList.getOuterHtml().then(function(text) {
  console.log(text);
});

challengePickerList.submit();

browser.driver.sleep(1500);

var submitApproveAccess = browser.driver.findElement(by.id('submit_approve_access'));
submitApproveAccess.click();

// 返回視窗
browser.driver.getAllWindowHandles().then(function (handles) {
  console.log(handles);
  browser.driver.switchTo().window(handles[0]);
});

browser.driver.sleep(3000);