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
trait AfterInit extends DelayedInit { | |
def afterInit | |
def afterInitLevel = 1 | |
private var initCount = 0 | |
private def getInitNumber(clazz: Class[_]):Int = | |
if (clazz.getSuperclass == classOf[java.lang.Object]) 0 else getInitNumber(clazz.getSuperclass) + 1 | |
final def delayedInit(x: => Unit) { | |
x | |
initCount += 1 | |
if (getInitNumber(this.getClass) + afterInitLevel == initCount) afterInit |
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
#!/usr/bin/scala | |
!# | |
val activities = Seq( | |
("blogging", "chrome", "^Blogger".r), | |
("games", "chrome", "Game".r), | |
("guake", "python", "^Guake!$".r) | |
) | |
io.Source.fromFile(args(0)).getLines.toList // read the file |
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
assoc .svg=SvgGraphicsFile | |
ftype SvgGraphicsFile=C:\Program Files\Internet Explorer\iexplore.exe "www.someplace.ru/index.html?file=" "%1" |
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
class SlidingWindowMap(keys: Set[String], maxCount: Int, periodMs: Int) { | |
val times = collection.mutable.Map(keys.map(k => (k, Vector[Long]())).toList:_*) | |
def nextKey: Option[String] = { | |
val now = System.currentTimeMillis | |
this.synchronized { | |
val key = times.find(_._2.dropWhile(_ < now - periodMs).size < maxCount).map(_._1) | |
key.foreach { k => times(k) = times(k).dropWhile(_ < now - periodMs) :+ now } | |
key | |
} | |
} |
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 simple | |
package even.simpler | |
import scala.collection._ | |
import scala.util.{Random => Rnd} | |
import scala.collection.mutable.Map | |
object Simple { | |
type TP = Seq[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
git clone git://github.com/scala/scala.git scala-tuplicity | |
cd scala-tuplicity | |
git checkout v2.9.2 | |
export ANT_OPTS="-Xmx8192m -Xss25M -Xms4096M -XX:MaxPermSize=512M" | |
VERS="-Dbuild.release=true -Dversion.number=2.9.2-tuplicity -Dmaven.version.number=2.9.2-tuplicity" | |
ant build | |
sed -i 's/\(val MaxTupleArity, .*\) 22/\1 222/' src/compiler/scala/tools/nsc/symtab/Definitions.scala | |
ant build | |
ant replacelocker | |
sed -i 's/\(MAX_ARITY .*\) 22/\1 222/' src/build/genprod.scala |
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 ZipApply { | |
import shapeless._ | |
import HList._ | |
import Monoid._ | |
implicit def ccMonoid[C, L <: HList](implicit iso : Iso[C, L], ml : Monoid[L]) = new Monoid[C] { | |
def zero = iso.from(ml.zero) | |
def append(a : C, b : C) = iso.from(iso.to(a) |+| iso.to(b)) | |
} |
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
git clone git://github.com/scala/scala.git scala-tuplicity | |
cd scala-tuplicity | |
git checkout v2.10.0 | |
export ANT_OPTS="-Xmx8192m -Xss25M -Xms4096M -XX:MaxPermSize=512M" | |
VERS="-Dbuild.release=true -Dversion.number=2.10.0-tuplicity -Dmaven.version.number=2.10.0-tuplicity" | |
ant build | |
sed -i 's/\(val MaxTupleArity, .*\) 22/\1 55/' src/reflect/scala/reflect/internal/Definitions.scala | |
ant build | |
sed -i 's/22/55/' src/library/scala/runtime/ScalaRunTime.scala |
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> (1 to 50).map(i => s"b$i:Int").mkString("case class A(", ", ", ")") | |
res0: String = case class A(b1:Int, b2:Int, b3:Int, b4:Int, b5:Int, b6:Int, b7:Int, b8:Int, b9:Int, b10:Int, b11:Int, b12:Int, b13:Int, b14:Int, b15:Int, b16:Int, b17:Int, b18:Int, b19:Int, b20:Int, b21:Int, b22:Int, b23:Int, b24:Int, b25:Int, b26:Int, b27:Int, b28:Int, b29:Int, b30:Int, b31:Int, b32:Int, b33:Int, b34:Int, b35:Int, b36:Int, b37:Int, b38:Int, b39:Int, b40:Int, b41:Int, b42:Int, b43:Int, b44:Int, b45:Int, b46:Int, b47:Int, b48:Int, b49:Int, b50:Int) | |
scala> case class A(b1:Int, b2:Int, b3:Int, b4:Int, b5:Int, b6:Int, b7:Int, b8:Int, b9:Int, b10:Int, b11:Int, b12:Int, b13:Int, b14:Int, b15:Int, b16:Int, b17:Int, b18:Int, b19:Int, b20:Int, b21:Int, b22:Int, b23:Int, b24:Int, b25:Int, b26:Int, b27:Int, b28:Int, b29:Int, b30:Int, b31:Int, b32:Int, b33:Int, b34:Int, b35:Int, b36:Int, b37:Int, b38:Int, b39:Int, b40:Int, b41:Int, b42:Int, b43:Int, b44:Int, b45:Int, b46:Int, b47:Int, b48:Int, b49:Int, b50:Int) | |
defined class A | |
s |
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 qualified Data.Map as Map | |
import qualified Data.Set as Set | |
import Data.List | |
import Text.Regex | |
import Control.Monad.State | |
import Control.Applicative | |
-- some setup for the types | |
type Graph a = Map.Map a [a] | |
data Tree a = Tree |