この投稿はScala Advent Calendar 2013の4日目の記事です。
最近Scala勉強会 in 東京 #rpscalaで初心者向けセッションのコーナーが始めたみたいです。それに便乗して自分も初心者向けの記事というかscala習い始めにすごいなと思ったREPLの機能を何個か書いてみたいと思います。
scala> val a = 1 + 2
a: Int = 3
| -- select | |
| -- A.asmst_id, | |
| -- B.email, B.entry_group_cd, | |
| -- C.website_name | |
| select count(*) | |
| from ( | |
| select | |
| a.asmst_id | |
| from ( |
この投稿はScala Advent Calendar 2013の4日目の記事です。
最近Scala勉強会 in 東京 #rpscalaで初心者向けセッションのコーナーが始めたみたいです。それに便乗して自分も初心者向けの記事というかscala習い始めにすごいなと思ったREPLの機能を何個か書いてみたいと思います。
scala> val a = 1 + 2
a: Int = 3
| git diff --cached | |
| git log -p | |
| git log --oneline --graph | |
| git log --after=2013-08-14 --author="t_shinozaki" | |
| git commit --amend | |
| git blame -s | |
| git rebase -i HEAD~ | |
| http://www.backlog.jp/git-guide/stepup/stepup1_1.html |
| // 単純なopen、close | |
| val fileName = "text.txt" | |
| val resource = new BufferedReader(new FileReader(new File(fileName))) | |
| resource.readLine | |
| resource.close |
| import play.api._ | |
| import play.api.libs.concurrent.Akka | |
| import akka.actor._ | |
| import scala.concurrent.duration._ | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.language.postfixOps | |
| actorSystem.scheduler.schedule(0 seconds, 1 minutes, ... |
| import sbt._ | |
| import Keys._ | |
| import play.Project._ | |
| object ApplicationBuild extends Build { | |
| val appName = "aaa" | |
| val appVersion = "1.0-SNAPSHOT" | |
| val appDependencies = Seq( |
| // | |
| // 64文字の文字列を8文字ずつに区切ってリスト化する | |
| // | |
| // 1234567890123456789012345678901234567890123456789012345678901234 | |
| // -> List(12345678, 90123456, 78901234, 56789012, 34567890, ....) | |
| // | |
| def aaa(s: String, l: Int): List[String] = { | |
| def bbb(s: String, e: List[String]): Pair[String, List[String]] = s match { | |
| case s if s.length < l => | |
| (s, e :+ s) |
| require 'logger' | |
| class MyFormatter < Logger::Formatter | |
| def call(severity, timestamp, progname, msg) | |
| if String === msg then | |
| if msg.nil? or msg.empty? then | |
| return "\n" | |
| else | |
| return "%s %s\n" % [timestamp.strftime("%H:%M:%S"), msg] | |
| end |
| <source> | |
| type tail_ex | |
| path /log_dir/postlog/%Y/%m/%d.txt | |
| tag posts | |
| format /^(?<user>.*)\t(?<postid>.*)\t(?<date>.*)\t(?<rk>.*)\t(?<offset>.*)\t(?<count>.*)$/ | |
| pos_file /var/tmp/fluentd_quote.pos | |
| refresh_interval 1800 | |
| </source> | |
| # <match debug.**> |
| path = 'http://api.tumblr.com/v2/blog/%s.tumblr.com/post/edit' % [user] | |
| header = { | |
| 'reblog_key'=> reblog_key, | |
| 'id' => postid, | |
| 'state' => 'published' | |
| } | |
| response = @access_token.post(path, header) |