この記事は、Clojure Contrib Advent Calendar 2013 2日目の記事です。
今日のお題は、clojure.java.jdbc
です。その名の通り、JDBC の
wrapper library で、Clojureから SQL Database へのアクセスを容易にして
くれます。
(ns clj-selenium-test.core | |
(:use [clj-webdriver.taxi])) | |
(defn auto-login [] | |
"http://www.walk-21.com に自動ログインする。REPL にて | |
user=> (use 'clj-selenium-test.core) | |
user=> (auto-login) | |
" | |
;; top 画面を表示 | |
(set-driver! {:browser :firefox} "http://www.walk-21.com/") |
;;; | |
;;; 簡単 grep。のつもりが、あんまりかっこ良くないorz | |
;;; | |
(use '[clojure.java.io :as io]) | |
(defn indexed [coll] | |
(map vector (iterate inc 1) coll)) | |
(defn grep [re file] | |
(with-open [rdr (io/reader file)] |
;; @___otabat___ さんのツイート https://twitter.com/___otabat___/status/230890089218195456 | |
;; より引用 | |
;; 「Clojureでmapリテラルを使うとき、8対目まではarray-map、9対目からhash-mapに変わるなどデータと内部実装が異なるのは注意。」 | |
;; を試してみた。 | |
user=> (class {:a 10 :b 20}) | |
;= clojure.lang.PersistentArrayMap | |
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80}) | |
;= clojure.lang.PersistentArrayMap (:a〜:h 8対まで) | |
user=> (class {:a 10 :b 20 :c 30 :d 40 :e 50 :f 60 :g 70 :h 80 :i 90}) | |
;= clojure.lang.PersistentHashMap (:a〜:i 9対、PersistentHashMap に変わった!!) |
user=> (import 'java.io.File) | |
user=> (File. ".") | |
#<File .> | |
user=> (def curdir (File. ".")) | |
#'user/curdir | |
user=> curdir | |
#<File .> | |
user=> (.list curdir) | |
#<String[] [Ljava.lang.String;@33d6798> | |
user=> (seq (.list curdir)) |
この記事は、Clojure Contrib Advent Calendar 2013 2日目の記事です。
今日のお題は、clojure.java.jdbc
です。その名の通り、JDBC の
wrapper library で、Clojureから SQL Database へのアクセスを容易にして
くれます。
[net.sourceforge.htmlcleaner/htmlcleaner "2.2"] |
bash$ java -jar ../jetty-distribution-9.4.2.v20170220/start.jar --add-to-start=http,deploy,ext,jvm,console-capture,logging-slf4j,slf4j-log4j --create-startd | |
ALERT: There are enabled module(s) with licenses. | |
The following 2 module(s): | |
+ contains software not provided by the Eclipse Foundation! | |
+ contains software not covered by the Eclipse Public License! | |
+ has not been audited for compliance with its license | |
Module: log4j-impl | |
+ Log4j is released under the Apache 2.0 license. |
bash$ system_profiler SPHardwareDataType | |
Hardware: | |
Hardware Overview: | |
Model Name: MacBook | |
Model Identifier: MacBook9,1 | |
Processor Name: Intel Core m5 | |
Processor Speed: 1.2 GHz | |
Number of Processors: 1 |
;; | |
;; keyword with namespace | |
;; | |
(let [{:keys [app/title]} {:app/title "aabb"}] title) | |
;; => "aabb" | |
(let [{:keys [a.p.p/title]} {:a.p.p/title "aabb"}] title) | |
;; => "aabb" |