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
require 'zlib' | |
GZIP_CONTENT1 = "\x1f\x8b\x08\x00\x1a\x96\xe0\x4c\x00\x03\xcb\x48\xcd\xc9\xc9\x07\x00\x86\xa6\x10\x36\x05\x00\x00" | |
GZIP_CONTENT2 = "\x00" | |
z = Zlib::Inflate.new(Zlib::MAX_WBITS + 32) | |
p z.inflate(GZIP_CONTENT1) | |
#p z.inflate(GZIP_CONTENT2) | |
z.finish |
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 ForLoop extends Test { | |
final val times = 10 | |
def main(arg: Array[String]) = { | |
test1 | |
test2 | |
} | |
def test1 = { |
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
samples for demonstrating how implicits are searched. |
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
sbt project for testing scala-io |
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.concurrent.stm._ | |
import scala.actors.{Actor, Exit} | |
import scala.actors.Actor.actor | |
import scala.actors.Actor.State.{New, Terminated} | |
import System.currentTimeMillis | |
import java.io.{File, PrintWriter} | |
trait EnsureStartActor { | |
def ensureStart(actor: Actor) { | |
actor.getState match { |
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.concurrent.stm._ | |
import scala.actors.{Actor, Exit} | |
import scala.actors.Actor.State.{New, Terminated} | |
import System.currentTimeMillis | |
trait EnsureStartActor { | |
def ensureStart(actor: Actor) { | |
actor.getState match { | |
case New => actor.start | |
case Terminated => actor.restart |
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
% mvn scala:compile | |
% mvn scala:console | |
scala> LiftJson.json |
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.actors.{Actor, TIMEOUT, Exit} | |
import scala.actors.Actor.State.{New, Terminated} | |
import scala.util.logging.{Logged, ConsoleLogger} | |
import scala.util.control.Exception.allCatch | |
import scala.collection.JavaConversions._ | |
import scala.util.Random | |
import java.net.InetSocketAddress | |
import java.nio.ByteBuffer | |
import java.nio.channels.{SelectionKey, Selector, ServerSocketChannel, SocketChannel} |
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 org.java{ | |
} | |
package org.myproject{ | |
class Bar extends java.net.Socket | |
} |
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 | |
Welcome to Scala version 2.8.0.final (Java HotSpot(TM) Client VM, Java 1.6.0_16). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> "IBM".map(_-1) | |
res0: scala.collection.immutable.IndexedSeq[Int] = Vector(72, 65, 76) | |
scala> "IBM".map(_-1):String | |
<console>:6: error: type mismatch; |