Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
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
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",
@masahitojp
masahitojp / FileServlet.scala
Created June 22, 2012 16:29
serveletからoctet-streamでファイルダウンロードするサンプルコード。
package com.github.masahitojp
import org.scalatra._
import java.io.File
class BaseServlet extends ScalatraServlet {
// ***************************************
// GLOBAL METHODS
>>> 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()

SEDA: 健全でスケーラブルなインターネットサービス用のアーキテクチャ

概要

@masahitojp
masahitojp / gist:3057885
Created July 6, 2012 03:22
HttpComponent HttpAsyncClient on Scala
/*
* ====================================================================
* 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
*

Play 2.1 Roadmap

Hi all,

こんにちは

We have started to discuss what we want to include into the next Play release.

次のPlay(Play 2.1)のリリースに何を含めるかを議論し始めました。

@masahitojp
masahitojp / a.py
Created August 2, 2012 05:17
Amazonで本のSalesRankのみ抜き出すjQueryスクリプト
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)
@masahitojp
masahitojp / Args4j.scala
Created August 17, 2012 00:43
args4J をScalaから使う
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 {
@masahitojp
masahitojp / ScalatraJsonExampleServlet.scala
Created August 23, 2012 05:27
scalatra-lift-jsonの練習
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)