javaserverprogramming markdown memo
ここで使うmarkdownの記法
- コメントアウト: \ (エスケープシーケンス)
- 見出し(強調): # 増えるほど強調できる
- 太字:"*"で囲む(または"__")
- イタリック:"**"で囲む(または"__")
- リンク:表示名
- シンタックスハイライト:
言語
で囲む - 改行:
順序付きリスト: (空行) 1.(空白)リスト1 1.(空白)リスト2 (空行)
順序無し(・)リスト: (空行) +(or-or)(空白)リストA +(or-or)(空白)リストB (空行)
一部だけコードハイライト gccの例:
gcc hello.c
vimの基本操作・忘れやすいもの
- e: go to last character of word on cursor
- b: back to a left word
- o: go to insert mode at new line
- gg: go to begining of file
- G:go to end of file
- 3G: go to line "3"
- dw: delete word to right side
- yy: copy one line
- p: paste buffer
- ctrl+r: redo
- /(スラッシュ)検索したい言葉:検索(まずはenter押す、nで次へ移動)
- :s/old/new : 置換(oldをnewに)
- :s/old/new/g : その一行で全部置換
- :%s/old/new/gc:そのファイル全部で置換(c:一回ずつ確認を求める)
HTMLの基本タグ
link: リンク表示名 ex: リンク表示名 :home directory
java server side programming perfect master memo
chapter 3
3-1 create new project
settings
*java web->webアプリケーション
*GlassFish Server
*java EE 7 web
*コンテキストpathはそのまま
3-2 what occurs when "run"
run means compile and deploy (create .war file and copy this war file to GlassFish server)
3-3 create a servlet file
Do right click on project name and 新規 -> servlet input form, class name: arbitrary class name package: com.example next input form, servlet name; arbitrary servlet name url pattern kind: /arbitrary url pattern(recommend: servlet name)
3-4 what is servlet?
?how to use servlet
servlet instance can dynamically create contents (ex.html code)
JSP&servlet container in application server
it has main() method and other useful method
JSP&servlet container create instance of servlet class
through main() method
servlet instance create contents (ex.html code)
3-5 default servlet
method of default servlet * processReauest(HttpServletRequest, HttpServletResponse) this method create a http page depending on client's request grammer point : out.println("<!DOCTYPE html>"); out.println(""); ... so, this method create html code from below code out.println("html sources")
* doGet(HttpServletRequest, HttpServletResponse)
it work as HTTP GET method
* doPost(HttpServletRequest, HttpServletResponse)
it work as HTTP POST method
4-1 modern client/server model is 3 layer system
3 layer system
* client , server , middle tier(中間層)
* middle tier(java EE)
* presentation layer: appearence of web page
* business logic layer: process data
* datalink layer: save and read data
5-1 MVC on javaEE
view : xhtml + backing bean(managed bean) xhtml is similar to html but tag is not same backing beans preserve values from input on view
model: connect database
controller: jsf(facesServlet)
important: Not only controller(FacesServlet) has action method backing beans also has action method(mainly called by jsf to deal with client's input.)
5-2 set jsf(controller) and API and encoding files
reproduced below as 3-1
settings
* java web -> webアプリケーション
* GlassFish Server
* java EE 7 web
* コンテキストpathはそのまま
* frame work -> check on JavaServer Faces
(finish button)
* add API librar
project window -> (right click)ライブラリ -> ライブラリの追加
-> check on Java EE 7 APIライブラリ
* set character encoding
project window -> (right click)project name -> 新規 -> その他
(category)GlassFish -> GlassFishディスクリプタ
then, create 構成ファイル/glassfish-web.xml
add below code at line 2 from bottom of glassfish-web.xml
<parameter-encoding default-charset="UTF-8"/>
5-3 make table(list)
use jsf in other words, a xhtml file
- <h:form> tag : need to input and send message
xhtml tags for making table(list) (in <h:form> tag) <h:panelGrid> tag example: <h:panelGrid columns ="number of columns" > </h:panelGrid>
set label (in <h:form> tag) <h:outputLabel> tag example: <h:outputLabel value="ISBN : "/>
set textfield (in <h:form> tag) <h:inputText> tag example: <h:inputText value="#{book.isbn}"/>
set button to send input (in <h:form> tag) <h:commandButton> tag example: <h:commandButton value="送信" actionListener="#{book.dispConsole()}" />
draw a line to devide between sections
tag it is used only "
" in other words, Dont use
.
5-4 backing beans, midiator between view and model(database)
backing beans is java file role: midiator between view and model(database) preserve values of client's inputs have action (class)method, it will work if jsf call. view and database use this preserved values(class field)
automatically make getter/setter method 1.at the first time, you add (private) field, 2.go to editor of backing beans file,if right click and select "insert code" 3.select "取得メソッド及び設定メソッド" 4.select field you want to deal with by getter/setter
intantiation of backing beans and CDI CDI(Contexts Dependency Injection) CDI manages instance's relation of dependency and lifecycle of objects
by anotation, CDI create a instance example: (in backing beans file) //import files for annotation of instantiation import javax.enterprise.context.RequestScoped; import javax.inject.Named; //specify(指定する) a rule of instance's name @Named //it manages to autorelease objects @RequestScoped public class Book { private String isbn; }
5-5 setting of environment of FacesServlet(controller)
python100本ノックのメモ用markdown
vimの基本操作・忘れやすいもの
- o: go to insert mode at new line
- gg: go to begining of file
- dw: delete word to right side
- yy: copy one line
- p: paste buffer
- ctrl+r: redo
- /(スラッシュ)検索したい言葉:検索(まずはenter押す、nで次へ移動)
- :s/old/new : 置換(oldをnewに)
- :s/old/new/g : その一行で全部置換
- :%s/old/new/gc:そのファイル全部で置換(c:一回ずつ確認を求める)
ここで使うmarkdownの記法
- 見出し(強調): # 増えるほど強調できる
- 太字:"**"で囲む(または__)
- イタリック:"*"で囲む(または_)
- リンク:表示名
- シンタックスハイライト:
言語
で囲む - 改行:
順序付きリスト: (空行) 1.(空白)リスト1 1.(空白)リスト2 (空行)
順序無し(・)リスト: (空行) +(or-or)(空白)リストA +(or-or)(空白)リストB (空行)
一部だけコードハイライト gccの例:
gcc hello.c
pythonの文法
- コメントアウト
- 単一行:#
- 複数行:'''または"""で囲む
markdown記法を試してみる
ソースコードシンタックスハイライト(見出し#)
Main.java
public class Main{ public static void main(String[] args){ System.out.println("Hello,World!"); } }
リンク(見出し##)
改行(見出し###)
ここに<ビーアール>と二つ書いてあります
この文の前に空白行があれば成功です
リスト(見出し####)
順序付きリスト "1. 2. 3."
- 一つ目
- 二つ目
順序無しリスト"+, -, *"
- A
- B
- C
一部だけコードハイライト(` で囲む)(見出し###)
gccの例:gcc hello.c
pythonの文法
- コメントアウト
- 単一行:#
- 複数行:'''または"""で囲む
Raspberry pi 3 model B買ってセットアップしてみた
こんにちは。
Raspberry pi 3 model B、ついに届きました!
SwiftにRails、javaにPythonといろいろと手を出していますが、ついにハードウェアにも手を出すことに…
いろいろな経験するのは大事ですからね。それに、機械いじりは男のロマン!といことで…
早速OSをインストール…の前に
・必要なもの
iOS provisioning profile is expiring soonの理由
APPLEの無料の開発者プログラムに登録している人向けです。
5月頃から急にこの注意書きが出て、実機にインストールしたアプリが開けなくなったと思ったらプロファイル登録が消えていて、調べても有料の開発者プログラムの例しかなかったのですが、ようやく理由がわかったので書いておきます。
Xcode7でthe provisioning profile is expiring soonと出る理由
APPLEが、2016年5月から個人向け証明書(profile)の有効期限を90日間から7日間に短縮したからです。
背景としては、違法なアプリの配布などが横行するようになり、ユーザーが被害に遭うこともあったからでしょう。
知ればそういうことかということで納得できますね。7日間ごとにxcodeから再インストールすれば、個人向け証明書(profile)でもこれまで通り利用できます。
【iOS】tableViewで配列をリスト表示する
tableViewの使い方(リスト構造との連携編) tableView をstoryBoardにドラッグ
table view の設置
1 ViewController.swiftにプロトコルを追加
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { }
Type ‘ViewController’ does not conform to protocol ‘UITableViewDataSource’とエラーが出る場合
http://mirai-stereo.net/2014/11/07/swift-does-not-conform-to-protocol-uitableviewdatasource/
この場合2つのメソッドをきちんと書け、ってエラー
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
を書けばOK
2 行数を返す関数を作る(引数:UITableView, numberOfRowsInSection section) -> Int
func tableView(tableView: UITableView, numberOfRowsInSection section : Int) -> Int { return 行数 }
3 セルの内容を設定する関数を作る(引数:UITableView, NSindexPath) -> UITableViewCell
func tableView(tableView : UITableView, cellForRowAtIndexPath indexPath : NSIndexPath) -> UITableViewCell { let arrayElement = arrray[indexPath.row] let cell = UITableViewCell(style: .Default, reuseIdentifier: "myCell") cell.textLabel?.text = arrayElement }
2,3の補足 配列要素をtableViewに表示させたい場合
//まず、配列arrayを定義
var array = Array
4 tableViewとdataSource・delegateをつなげる
storyboard上でtableViewをドラッグ、上の左から1番目のアイコンへ。 dataSource・dalefateを選択
これで配列の文字列がtableViewでリスト表示できました!
ポケモンGOを配信するnianticとは
ついにポケモンGOが配信されました!
でも、配信元を見ると...Niantic,Inc?
え?任天堂じゃないの?
また偽アプリかよ、デマ流すなや!!
...と思いましたが、Niantic,Incのアプリを見ると、海外で有名なバーチャルリアリティ(VR)のアプリ、「Ingress」がありました。
そこで「Niantic,IncのポケモンGOは本物」という認識に落ち着きました。
・で、Niantic,Incとは?
どうやら、VRが専門で、VRを利用したアプリなどを開発しているようです。今回のポケモンGOの場合は、任天堂とコラボして、VR技術を提供したわけですね。他には、「Ingress」というゲームがあり、これもスマホでカメラ機能を使うと現実世界にモンスターがいるように見えたりするというもののようです。
・偽物っぽいダウンロード画面
しかし、このポケモンGOアプリ、偽物も出回っていますが、Nianticを知らない日本人からすると本物にも関わらず偽物オーラを出しているように思えてなりません。
アプリ説明のデモ画像なんかたった1枚しかありません。これはちょっと不安にさせますよ。海外アプリで情報を抜き取られる危険性も取り上げられている中で、もう少しなんとかならなかったものか。
(でも画像はこれ1枚だけである。普通のゲームアプリなら4、5枚あるのが普通。安っぽさを出しているように思う)