This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def minus(n : Int) = { | |
val strList = n.toString().sortWith(_ < _) | |
strList.reverse.toInt - strList.toInt | |
} | |
def test(a:Int, b: Int):Int = if (b==0) a else test(minus(a), b-1) | |
test(1974,100) | |
// => 6174 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "sbt-project-example" | |
version := "0.0.1-SNAPSHOT" | |
scalaVersion := "2.9.2" | |
libraryDependencies ++= Seq( | |
"org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524", | |
"javax.servlet" % "javax.servlet-api" % "3.0.1", | |
"com.github.scala-incubator.io" %% "scala-io-core" % "0.4.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.masahitojp | |
import org.scalatra._ | |
import java.io.File | |
class BaseServlet extends ScalatraServlet { | |
// *************************************** | |
// GLOBAL METHODS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def test(a=[]): | |
... a.append('A') | |
... return a | |
... | |
>>> import copy | |
>>> z1= copy.copy(test.func_defaults) | |
>>> z2= copy.deepcopy(test.func_defaults) | |
>>> z1 == z2 | |
True | |
>>> test() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ==================================================================== | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
url = "http://www.amazon.co.jp/o/ASIN/4774152439/book042-22/ref=nosim" | |
opener = urllib2.build_opener() | |
opener.addheaders = [('User-agent', 'mozilla 3.6')] | |
txt = opener.open(url).read() | |
print(txt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.masahitojp | |
import org.kohsuke.args4j.CmdLineException | |
import org.kohsuke.args4j.CmdLineParser | |
import org.kohsuke.args4j.Option | |
import grizzled.slf4j.Logger | |
import scala.collection.JavaConversions._ | |
import scala.util.control.Exception._ | |
object Args4j { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.masahitojp.testApp | |
import org.scalatra._ | |
import liftjson.LiftJsonSupport | |
import scalate.ScalateSupport | |
import net.liftweb.json._ | |
case class Person(id: Long, name: String, age: Int) |