This file contains 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 scala.util.parsing.combinator._ | |
import scala.util.parsing.input.{Position, NoPosition} | |
sealed abstract class Insn extends ( CED => CED ){ | |
val pos:Position | |
} | |
case class App( m:Int, n:Int, pos:Position ) extends Insn{ | |
override def apply( ced:CED ) = | |
ced.e( m - 1 )( ced.e( n - 1 ), ced ) |
This file contains 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 sample; | |
/** | |
* http://d.hatena.ne.jp/Aileron/20100310/1268184123の(2) | |
*/ | |
class A<A> | |
{ | |
class B<B> | |
{ | |
public void out() |
This file contains 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 sample2; | |
/** | |
* http://d.hatena.ne.jp/Aileron/20100310/1268184123 の(3) | |
*/ | |
class A | |
{ | |
static interface AA | |
{ | |
String value(); |
This file contains 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 java.util.ArrayList; | |
import java.util.List; | |
public class OutOfMemory { | |
public static void main(String[] args) { | |
Runnable r = new Runnable() { | |
@Override | |
public void run() { | |
List<String> l = new ArrayList<String>(); |
This file contains 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
object PrintWithLineNumber{ | |
import scala.io.Source | |
def printWithLineNumber( fileName:String ) = | |
Source.fromFile( fileName ). | |
getLines. | |
zipWithIndex. | |
map{ case ( s, n ) => "%s:%s" format( n, s ) }. | |
foreach{ print } | |
} |
This file contains 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 java.net.{Authenticator, PasswordAuthentication} | |
import scala.Math._ | |
import scala.xml._ | |
import scala.io.Source | |
object TwitterRetweetCrawler { | |
val rtUrl ="http://api.twitter.com/statuses/retweets_of_me.xml" | |
val stUrl ="http://api.twitter.com/1/statuses/retweets/%s.xml" |
This file contains 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;; ;;; ;;; ;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;; |
This file contains 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
object YumaoCrawler extends Application{ | |
import scala.io.Source | |
import java.io.{Writer, OutputStreamWriter, FileOutputStream } | |
val tagr = """<("[^"]*"|'[^']*'|[^'">])*>""".r | |
val sepr1 = """\d+\s*:以下、名無しにかわりましてVIPがお送りします.*""".r | |
val sepr2 = """\d+\s*:以下、VIPにかわりましてパー速民がお送りします.*""".r | |
val title = """<title>(.*)</title>""".r | |
val h1 = """<h1 id="header2">(.*)</h1>""".r |
This file contains 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
scala> class S[A]( val theSeq:Seq[A] ) extends Seq[A]{ | |
| def apply(n:Int ) = theSeq(n) | |
| def length = theSeq.length | |
| override def iterator = theSeq.iterator | |
| override def toString = "hogehoge" | |
| } | |
defined class S | |
scala> new S( List("foo","bar")) | |
res15: S[java.lang.String] = line35(foo, bar) |
This file contains 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 tryo[T]( f: => T ) | |
( implicit onError: Throwable => Option[T] = | |
{ t:Throwable => None }): Option[T] = | |
{ | |
try { | |
Some( f ) | |
} catch { | |
case c => onError( c ) | |
} | |
} |