maven class

\MySampleApp1\src\main\java\jp\spring\sample1

package jp.spring.sample1;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>jp.spring.sample1</groupId>
  <artifactId>MySampleApp1</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>MySampleApp1</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Java Springのコア機能

Dependency Injection
あるクラスの処理が、他の特定のクラスに依存している状態を解消することがDIの目的です。

それでは、mavenでプロジェクトを作成していきます。
コマンドプロンプトでmvnコマンドを実行します。

>mvn archetype:generate

Define value for property 'groupId': jp.spring.sample1
Define value for property 'artifactId': MySampleApp1
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' jp.spring.sample1: :
Confirm properties configuration:
groupId: jp.spring.sample1
artifactId: MySampleApp1
version: 1.0-SNAPSHOT
package: jp.spring.sample1
 Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: C:\Users\***\Desktop
[INFO] Parameter: package, Value: jp.spring.sample1
[INFO] Parameter: groupId, Value: jp.spring.sample1
[INFO] Parameter: artifactId, Value: MySampleApp1
[INFO] Parameter: packageName, Value: jp.spring.sample1
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\Users\***\Desktop\MySampleApp1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10:03 min
[INFO] Finished at: 2018-01-17T15:32:23+09:00
[INFO] Final Memory: 14M/75M
[INFO] ------------------------------------------------------------------------

Spring Framework 5.0とMaven

Springは、Apache Software Foundationが開発するJavaプロジェクト管理ツール「Apache Maven」に対応しています。Mavenは、コマンドラインでプロジェクト管理を行えるツールです。

Maven
https://maven.apache.org/

https://maven.apache.org/download.cgi
「Binary zip archive」のLink「apache-maven-3.5.2-bin.zip」からダウンロードします。

適当な場所に保存して、環境変数のpathに追加します。
C:\apache-maven-3.5.2\bin
※「\bin」を忘れずに

コマンドプロンプトで「mvn -v」でバージョンを確認してみましょう。

>mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T16:58:13+09:00)
Maven home: C:\apache-maven-3.5.2\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jre1.8.0_121
Default locale: ja_JP, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

ヴァージョンが表示されれば、正常に動いています。

Spring Framework 5.0とSprint Tool Suiteのダウンロード

Spring5の対応JDKは、JDK8(ver 1.8)で、それ以前のversionは未対応となっています。コマンドラインで確認してください。

>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

続いて、Spring Tool Suite(STS)をダウンロードします。
https://spring.io/tools/sts

DOWNLOAD STSをクリックしてダウンロードします。


– sts-3.9.2.RELEASE がSTS本体フォルダ
– Pivotal-tc-server-develop-3.2.8…. が開発用のJavaサーバープログラム。STS内から起動して使う
– legalフォルダ ライセンス情報など

STSプログラムは、sts-xxxフォルダ内にあるSTS.exeを起動して利用します。

Supervised Classification

Classification
-> regression, ranking, reinforcement learning, detection

Logistic Classifier
WX + b = y
-> a, b, c
p = 0.7, 0.2, 0.1
p = probability which closed to 1.0 – 0
S(yi) = e^yi / Σi e^yj
Any scores turned to probability

Google Cast

Streaming media

Google Cast
-multi device
-android, ios, web

Android TV
-extended android app
-runs on TV

Platform
android -> android TV

Android TV platform
1.declare the TV activity in the manifest
2.Update UI with the leanback library
-BrowseFragment
-DetailsFragment
-SearchFragment
3.Content discovery
-Apps/Games row
-Recomendations
-Search

https://developers.google.com/cast/docs/developers

Getting started
https://cast.google.com/publish/

Parallel Processing

CPU1 CPU2 CPU3

#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>

void* f1(void* arg){
	int whos_better;
	whos_better = 1;
	while(1)
		printf("Thread 1: thread %d is better.\n", whos_better);

		return NULL;
}

void* f2(void* arg){
	int whos_better;
	whos_better = 2;
	while(1)
		printf("Thread 2: thread %d is better.\n", whos_better);

	return NULL;
}

int main(int argc, char **argv){
	pthread_t th1, th2;

	pthread_create(&th1, NULL, f1, NULL);	
	pthread_create(&th2, NULL, f2, NULL);

	pthread_join(th1, NULL);
	pthread_join(th2, NULL);

	pthread_exit(NULL);
}

File System

Key Abstractions
1. file
2. file name
3. Directory Tree

#include 
#include 
#include 
#include 

int main(int argc, char **argv){
	int fd;
	ssize_t len;
	char *filename;
	int key, srch_key, new_value;

	if(argc < 4){
		fprintf(stderr, "usage: sabotage filename key value\n");
		exit(EXIT_FAILURE);
	}

	filename = argv[1];
	srch_key = strtol(argv[2], NULL, 10);
	new_value = strtol(argv[3], NULL, 10);
}