Giter VIP home page Giter VIP logo

free's People

Contributors

ksmt88 avatar

Watchers

 avatar

free's Issues

(ex) simple coding rule

<?php

namespace Vendor\Package;

use BarClass as Bar;
use FooClass as Foo;
use Vendor\OtherPackage\BazClass;

class SampleClass extends FooBaseClass implements Bar1, Bar2, Bar3
{
    /**
     * 基本事項.
     *
     * - ケースは利用しているFWによる.(CamelCase, snake_caseなど)
     * - インデントはタブではなくスペース4つ
     * - 1行はなるべく80文字以内に抑える
     */

    // 修飾子なども含め、位置を揃える
    var    $numbers = array("one", "two", "three", "four", "five", "six");
    var    $v       = 0;
    public $path    = "root";

    const FIRST  = 'first';
    const SECOND = 0;
    const Z      = -1;

    /**
     * 関数の説明.
     * 追加で説明がある場合はここに書いていく.
     *
     * @param string $v 変数の説明
     * @param string $w 変数の説明
     *
     * @return int 返り値の説明
     */
    public function bar($v, $w = "a")
    {
        // 引数が長くなり、見づらくなる場合などは改行する
        $this->fOne("argA", "argB", "argC", "argD",
            "argE", "argF", "argG", "argH");

        // 配列定義するときも揃える
        $x = array(
            "apple"  => 1,
            "banana" => 24,
            "add"    => array(
                "apple"  => 3,
                "banana" => 45,
            ),
        );

        // {}の省略はしない。判定はわかりやすく。(if ($a !== false)などと書かないように。)
        if (true) {
            $x = 10;
        }

        // breakしない場合はコメントを記載.
        // defaultは必須.
        switch ($v) {
            case 0:
            case 1:
                echo '1';
                break;

            case 2:
                echo '2';
                break;

            case 3:
                echo '3';
            // no break

            default:
                $result = 10;
                break;
        }

        return $result;
    }

    /**
     * .....
     */
    public static function fOne($argA, $argB, $argC, $argD,
                                $argE, $argF, $argG, $argH)
    {
        $colors = array("red", "green", "blue", "black", "white", "gray");
        $count  = count($colors);

        for ($i = 0; $i < $count; $i++) {
            // body
        }

        foreach ($colors as $key => $color) {
            // body
        }

        while ($expr) {
            // body
        }
    }

    /**
     * .....
     */
    private function fTwo($strA, $strB, $strC, $strD)
    {
        // 文字列判定は厳密に行う
        if ($strA === "one" || $strB === "two" || $strC === "three") {
            return $strA + $strB + $strC;
        }

        // 長くなる場合は改行を行う
        $x = $foo->one("a", "b")
            ->two("c", "d", "e")
            ->three("fg")->four();
        $y = a()->b()->c();

        return $strD;
    }

    /**
     * .....
     */
    private function fThree($strA, $strB, $strC, $strD, $strE)
    {
        try {
            // body
        } catch (Exception $e) {
            // error
        } finally {
            // do something
        }

        return $strA + $strB + $strC + $strD + $strE;
    }
}

How to use docker

How to use docker

get an image

# docker pull {repository}
docker pull localhost:5000/test:1.0

create an image from container

# docker commit -m "{comment}" {container ID} test:1.0
docker commit -m "test" fbe9f9e05780 test:1.1

create container

# docker run -it -d {image ID}
docker run -it -d 16508e5c265d

login to container

# docker exec -it {container ID} bash
docker exec -it fbe9f9e05780 bash

add a tag

# docker image tag {image ID} {repository}
docker image tag 16508e5c265d localhost:5000/test:1.0

register docker registry

# docker push {repository}
docker push localhost:5000/test:1.0

copy

# to container
# docker cp {path} {container ID}:{path}
docker cp /tmp fbe9f9e05780:/tmp
# to host
# docker cp {container ID}:{path} {path}
docker cp fbe9f9e05780:/tmp /tmp

mysqldump

ref: https://qiita.com/tentatsu/items/2b163af4a1ac1c897891

backup.sh

#!/bin/bash
BACKUP_PATH="/root/backup/"
S3_PATH="s3://[bucket_name]/"
FILE_NAME="mysql_dump_`date +%Y%m%d`.sql.gz"

cd $BACKUP_PATH
mysqldump --defaults-extra-file=/root/mysql.cnf --single-transaction $DB_DATABASE | gzip > $FILE_NAME
find $BACKUP_PATH -type f -name "mysql_dump_*.sql.gz"  -mtime +31 -daystart | xargs rm -rf
/usr/local/bin/aws s3 sync $BACKUP_PATH $S3_PATH --delete

mysql.cnf

[client]
user = username
password = 'password'

restore.sh

#!/bin/bash
BACKUP_PATH="/root/backup/"
FILE_NAME="mysql_dump_`date +%Y%m%d`.sql.gz"

zcat $BACKUP_PATH$FILE_NAME | mysql --defaults-extra-config=/root/mysql.cnf $DB_DATABASE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.