データベースオブジェクトの命名規則

対象は
– テーブル名
– カラム
– インデックス

1.全般 大文字を利用しない
× DOCUMENT
× Document
〇 document

2.複数単語の連携はスネークケース
× tableName
× TableName
× tablename
〇 table_name

3. 略名は利用しない
× start_dt
× maker_cd
〇 start_date
〇 maker_code

4. テーブル名は複数形
× document
〇 documents
× category
〇 categories

5. 複数x複数
× usercategories
× user_categories
〇 users_categories

6. カラム
id, created_at, updated_atは必須

7. 他のテーブルとジョインするカラムはテーブル名(単数)_id
〇 category_id

8. 時間を表すカラムは受動態_on、受動態_at
〇 created_at
〇 crosed_on

なるほど、これは非常に勉強になる。
ありがたや、ありがたや!

Amazon Kinesis

動画とデータストリームをリアルタイムで容易に収集、処理、分析 Amazon Kinesis は、リアルタイムのストリーミングデータを容易に収集、処理、分析できるため、タイムリーな洞察を得て、新しい情報に迅速に対応することができる。

  • Generate streaming data containing stock quote information
  • Send the data to an Amazon Kinesis Firehose delivery stream
  • Amazon Kinesis Firehose will then call an AWS Lambda function to transform the data
  • Amazon Kinesis Firehose will then collect the data into batches and send the batches to an Amazon Elasticsearch service cluster
  • You will use Kibana to visualize the streaming data stored in the Elasticsearch cluster
  • Amazon Kinesis Firehose is a fully managed service that delivers real-time streaming data to destinations such as Amazon Simple Storage Service (Amazon S3), Amazon Elasticsearch Service and Amazon Redshift. With Firehose, you do not need to write any applications or manage any resources. You configure your data producers to send data to Firehose and it automatically delivers the data to the specified destination.

    letの変数は重複させない

    @IBAction func getGoo(_ sender: Any) {
            let results1 = ["Image1","Image2","Image3"]
            let random1 = arc4random_uniform(UInt32(results1.count))
    
            let image1 = UIImage(named: results1[Int(random1)])
            imageView.image = image1
        }
        
    
        @IBAction func getChoki(_ sender: Any) {
            let results2 = ["Image1","Image2","Image3"]
            let random2 = arc4random_uniform(UInt32(results2.count))
            
            let image2 = UIImage(named: results2[Int(random2)])
            imageView.image = image2
        }
        
        @IBAction func getPa(_ sender: Any) {
            let results3 = ["Image1","Image2","Image3"]
            let random3 = arc4random_uniform(UInt32(results3.count))
            let image3 = UIImage(named: results3[Int(random3)])
            imageView.image = image3
        }
    

    let result, let randomを3回書くと、うまく表示されません。varだったら行けるのかもしれませんが。

    最新の日銀金融政策を中国語で自動表示する

    最新バージョンだけなら、難なくいけますね。

    
    $text = $titles[0]."<br><br>";
    
    foreach(glob("file/".$y."/{*.txt}",GLOB_BRACE) as $file){
        if(is_file($file)){
            $files[] = htmlspecialchars($file);
        }
    }
    // var_dump($files);
    
    	$file = fopen($files[0], "r");
    	if($file){
    		while ($line = fgets($file)){
    			$text .= $line;
    		}
    	}
    	fclose($file);
    
    	
    
    	$key = '';
    
    	$host = "https://api.cognitive.microsofttranslator.com";
    	$path = "/translate?api-version=3.0";
    	$params = "&to=zh";
    
    	if(!function_exists('com_create_guid')){
    		function com_create_guid(){
    			return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
    			mt_rand(0, 0xffff), mt_rand(0, 0xffff),
    			mt_rand(0, 0xffff),
    			mt_rand(0, 0x0fff) | 0x4000,
    			mt_rand(0, 0x3fff) | 0x8000,
    			mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
    		}
    	}
    
    	function Translate ($host, $path, $key, $params, $content) {
    	    $headers = "Content-type: application/json\r\n" .
    	        "Content-length: " . strlen($content) . "\r\n" .
    	        "Ocp-Apim-Subscription-Key: $key\r\n" .
    	        "X-ClientTraceId: " . com_create_guid() . "\r\n";
    	    $options = array (
    	        'http' => array (
    	            'header' => $headers,
    	            'method' => 'POST',
    	            'content' => $content
    	        )
    	    );
    	    $context  = stream_context_create($options);
    	    $result = file_get_contents ($host . $path . $params, false, $context);
    	    return $result;
    	}
    
    	$requestBody = array (
    	    array (
    	        'Text' => $text,
    	    ),
    	);
    	$content = json_encode($requestBody);
    	$result = Translate($host, $path, $key, $params, $content);
    
    	$json = json_decode($result);
    	$newtext =  $json[0]->translations[0]->text;
    
    	echo $newtext; 
    

    ガンガンいきたいところだが、アプリ(android・iOS)のタスクがかなり重いので、translatorはひとまずこれをazureに載せるところまでとしたい。

    ファイル名を取得して表示する

    echo $_SERVER['PHP_SELF'];
    

    1文字目~13文字目をslice

    $fname = $_SERVER['PHP_SELF'];
    echo substr($fname, 1, 12);
    

    ファイルを複製する

    $i = 1;
    $copy = '03-3567-000'.$i.'.php';
    copy('03-3567-0003.php', $copy);
    

    03-3567-0001.php の中身のコードも、03-3567-0003.phpと同じものになっています。

    ファイルを複数複製する

    for($i = 0; $i < 10; $i++){
    	$copy = '03-3567-000'.$i.'.php';
    	if(!file_exists($copy)){
    	copy('03-3567-0003.php', $copy);	
    	}
    }
    

    これ、何百万のphpファイルと何百万のmysqlレコードをつくるのか!?

    weather mapのデータをDBに格納する

    テーブル名はcakeを使うので、複数形にします。

    create table weather.marunouchis(
    	id int unsigned auto_increment primary key,
    	forecast varchar(255),
    	main varchar(255),
    	description varchar(255),
    	temp float,
    	humidity int,
    	cloud int,
    	speed float,
    	created datetime default null
    );
    

    PDO::PARAM_INTは、floatやdoubleはないとのこと。指定しないとstrになる。

    $now = date("Y-m-d H:i:s");
    $i = 0;
    foreach($main as $value){
        $stmt->bindParam(':forecast', $time[$i], PDO::PARAM_STR);
        $stmt->bindParam(':main', $value, PDO::PARAM_STR);
        $stmt->bindParam(':description', $description[$i], PDO::PARAM_STR);
        $stmt->bindParam(':temp', $temp[$i], PDO::PARAM_STR);
        $stmt->bindParam(':humidity', $humidity[$i], PDO::PARAM_INT);
        $stmt->bindParam(':cloud', $cloud[$i], PDO::PARAM_INT);
        $stmt->bindParam(':speed', $speed[$i], PDO::PARAM_INT);
        $stmt->bindParam(':created', $now, PDO::PARAM_STR);
        $stmt->execute();
        $i++;
    }
    

    入っていますね。

    weibo 微博 api 登録までの流れ

    まず、Weiboに登録します。
    「weibo english」で検索すると、英語のregistrationページがあるので、スマホの番号を入れ、送られてきたパスコードを入力して完了です。

    次に、ログインした状態で、http://open.weibo.com/ に行き、右上のプルダウンから、「编辑开发者信息」を選択します。「开发者」kaifa zhe が開発者という意味ですね。

    邮编 youbian: 郵便番号
    邮箱 youxiang: e-mail
    联系电话 lianxi dianhua: 連絡先電話番号 81+ :
    聊天工具: チャットツール

    ちょっと待て、チャットがない。「MSN,QQ,Gtalk至少填写一项」
    「聊天工具格式错误,请修改」qing xiugai 修正と出ている。とのことで、QQに登録。

    网站:http://192.168.33.10:8000
    紧急联系人姓名:

    发送验证邮件 Fasong yanzheng youjian:確認メールが飛ぶ

    PDOでデータをupdate

    まずは”?”を使って更新します。

    <?php
    
    $dsn = "mysql:dbname=stock;host=localhost";
    $user = "root";
    $password = "";
    $options = array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET CHARACTER SET 'utf8'");
    try {
    	$dbh = new PDO($dsn, $user, $password, $options);
    } catch (PDOException $e){
    	print('connection failed:'.$e->getMessage());
    }
    
    $sql = "select stoph SET 'price' = ? WHERE id = ?";
    $stmt = $dbh->prepare($sql);
    
    $stmt->execute(array(430, 2929));
    ?>

    Technical Documentation

    OSS, JOB
    documentation for you, coworkers, or your users!

    README
    app, bin, config, db, lib, log, public, test, vendor/assets, gitignore, README, Gemfile, Gemfile.lock

    What happens if I don’t choose a license?
    It’s super important to choose License.

    Choose an open source license
    which of the following best describes your situation?
    https://choosealicense.com/

    -add to README
    known bugs
    frequently asked questions
    table of contents

    Readable READMEs with Markdown
    -> easily readable

    Markdown is a light markup language often used for READMEs. It is fairly straightforward, and much of the syntax is intuitive.

    #Here is your task
    ‘code’
    **Here**
    _there_

    Markdown files should be saved with a .md extension.

    <h1>My Fabulous Recipe</h1>
    <p>This recipe for <strong>cereal and milk</strong> has been passed down my family for months.</p>
    <h2>Ingredients</h2>
    <ul>
    	<li>Cereal (you can find cool cereals <a href="www.example.com/coolcereals">here</a>)</li>
    	<li>Milk</li>
    </ul>
    
    <h2>Directions</h2>
    <p>If I were writing these out as <em>code</em>, it might look something like this:</p>
    
    <pre><code>if bowl is empty:
    	add cereal
    	if bowl only has cereal in it:
    	add milk
    </code></pre>
    </body>