Skip to content

Instantly share code, notes, and snippets.

View ymnk's full-sized avatar

Atsuhiko Yamanaka ymnk

View GitHub Profile
@ymnk
ymnk / README
Created January 29, 2009 02:22 — forked from hsak/beep.scala
This program is a 2D shooting game written in Scala by
@h_sakurai(http://twitter.com/h_sakurai),
and has been originally hosted at https://gist.github.com/46448 .
@ymnk(http://twitter.com/ymnk) has slightly modified that code
to run it on scala 2.8 with sbt.
$ sbt
> run
import scala.io.Source
/**
* http://www.facebook.com/jobs_puzzles/index.php?puzzle_id=7
*/
object HoppityHop{
def main(arg:Array[String]){
val line = Source.fromFile(arg(0)).getLine(1)
// val Array(n) = line.split(" ").filter(_.length!=0)
/**
Copyright (c) 2009 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
object RomanNumerals{
class RomanNumeralsException extends Exception
private val rn="IVXLCDM ".toList
def apply(n:Int):String={
type LS = List[String]
def n2ivx(n:Int, i:String, v:String, x:String):String = n match{
case 4 => i+v
/**
Copyright (c) 2009 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
/**
* This trait is the Packrat parser[1] library based on kmizu[2]'s parser
* combinators[3] for PEG[4].
*
* [1] http://pdos.csail.mit.edu/~baford/packrat/
* [2] http://d.hatena.ne.jp/kmizushima/
* [3] http://d.hatena.ne.jp/kmizushima/20090226/1235619468
* [4] http://en.wikipedia.org/wiki/Parsing_expression_grammar
**/
trait PackratParser[+A]{
import java.io.{ByteArrayOutputStream, IOException, OutputStream, File}
import java.io.{File, FileInputStream, DataInputStream}
import java.net.{URL, URLConnection, HttpURLConnection}
import java.util.Random
abstract sealed class Param
case class FieldParam(key:String, value:String) extends Param
case class DataParam(key:String, filename:String,
data:Array[Byte], typ:Option[String]) extends Param
case class FileParam(key:String, file:File, typ:Option[String]) extends Param
import scala.actors._
import scala.actors.Actor._
object ActorInSingleThread {
class MyActor(n:Int, single:Boolean) extends Actor{
override def scheduler: IScheduler =
if(single) new SingleThreadedScheduler else super.scheduler
def act = {
package net.liftweb.example.model
import javax.persistence._
import com.google.appengine.api.datastore.Key
@Entity
class Author {
@Id
@GeneratedValue(){val strategy = GenerationType.IDENTITY}
var id : Key = _
/**
* This program has come from http://gist.github.com/18268 .
*/
import java.net.{Authenticator, PasswordAuthentication}
import java.net.{URL, HttpURLConnection}
import scala.xml.{XML, Node}
import scala.collection.mutable.Map
class FriendOrFollow (screen_name:String) {