Skip to content

Instantly share code, notes, and snippets.

View yuroyoro's full-sized avatar
🍣
🍣

しいたけ yuroyoro

🍣
🍣
View GitHub Profile
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 )
package sample;
/**
* http://d.hatena.ne.jp/Aileron/20100310/1268184123の(2)
*/
class A<A>
{
class B<B>
{
public void out()
package sample2;
/**
* http://d.hatena.ne.jp/Aileron/20100310/1268184123 の(3)
*/
class A
{
static interface AA
{
String value();
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>();
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 }
}
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"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; ;;; ;;; ;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
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
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)
def tryo[T]( f: => T )
( implicit onError: Throwable => Option[T] =
{ t:Throwable => None }): Option[T] =
{
try {
Some( f )
} catch {
case c => onError( c )
}
}