#Docker CheatSheet
sudo docker run -i -t [container_name] /bin/bash
以下のようにポートを指定しておくとホストのポートにマッピングできる。
| diff -r commons-daemon-1.0.10-native-src/NOTICE.txt commons-daemon-1.0.15-native-src/NOTICE.txt | |
| 2c2 | |
| < Copyright 1999-2012 The Apache Software Foundation | |
| --- | |
| > Copyright 1999-2013 The Apache Software Foundation | |
| diff -r commons-daemon-1.0.10-native-src/RELEASE-NOTES.txt commons-daemon-1.0.15-native-src/RELEASE-NOTES.txt | |
| 2c2 | |
| < Version 1.0.10 | |
| --- | |
| > Version 1.0.15 |
| // Add a global menu item to the header | |
| PluginSystem.addGlobalMenu("Google", "http://www.google.co.jp/", "data:image/png;base64,..." | |
| function(context){ | |
| return context.loginAccount.isDefined(); | |
| } | |
| ); | |
| // Add a custom action | |
| PluginSystem.addGlobalAction('/test', function(request, response){ | |
| return "<h1>This is Test Plug-In</h1>"; |
Javaで作ったこんなアノテーションがあるとします。
package jp.sf.amateras.sample;
import java.lang.annotation.*;
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Id {| import plugin._ | |
| val pluginDef = ScalaPlugin.define(id, version, author, url, description) | |
| pluginDef.addRepositoryAction("/issues/export", Security.Member()){ (request, response, repository) => | |
| db.select(s"""SELECT * FROM ISSUE WHERE | |
| USER_NAME = '${repository.owner}' AND | |
| REPOSITORY_NAME = '${repository.name}' AND | |
| PULL_REQUEST = false""").map { issue => | |
| Map( |
| /////////////////////////////////////////////////////////////// | |
| // Elasticsearch4s is a Scala client for Elasticsearch | |
| // https://github.com/bizreach/elasticsearch4s | |
| /////////////////////////////////////////////////////////////// | |
| val config = ESConfig("my_index", "my_type") | |
| // Use AsyncESClient instead of ESClient | |
| AsyncESClient.using("http://localhost:9200"){ client => | |
| val future = client.searchAsync(config){ searcher => | |
| searcher.setQuery(QueryBuilders.matchPhraseQuery("subject", "Hello")) |
2つのWeb APIがあり、1つめのAPIを呼び出して得た結果を使って次のAPIを呼び出す必要があるとします。
ScalaではHTTP通信を行うためのライブラリとしてDispatchというものがあるのですが、このライブラリはノンブロッキングI/Oを使っており、Futureベースのインターフェースを備えています。
例えばGETメソッドでの通信は以下のようにして行うことができます。戻り値はEitherになっており、エラーの場合はLeftでThrowableを返す便利仕様ですが、通信に失敗した場合もonSuccessで処理しなくてはいけないのはやや紛らわしいかもしれません。
import dispatch._, Defaults._