Skip to content

Instantly share code, notes, and snippets.

@kxbmap
kxbmap / KeyValue.scala
Created March 20, 2011 19:28
ポリモーフィズムで再帰的なXMLを生成する
package com.example.kvxml2
import _root_.scala.xml.{Elem, MetaData, Node, NodeSeq, Null, Text, TopScope, UnprefixedAttribute}
sealed abstract class Value {
def nodes: NodeSeq
}
case class StringValue(str: String) extends Value {
@kxbmap
kxbmap / KeyValue.scala
Created March 20, 2011 19:34
case class + パターンマッチングで再帰的なXMLを生成する
package com.example.kvxml
import _root_.scala.xml.{Elem, MetaData, Node, NodeSeq, Null, Text, TopScope, UnprefixedAttribute}
sealed abstract class Value
case class StringValue(str: String) extends Value
case class ValueSeq(seq: Seq[Value]) extends Value
case class KeyValue(key: String, attributes: Map[String, String], value: Value) extends Value {
def this(key: String, value: Value) = this(key, Map.empty, value)
#!/bin/sh
exec scala -deprecation `cygpath -m $0` "$@"
!#
object CreateProject {
import scala.util.control.Exception._
def usage() {
println("create_project <name> <pkg> [--scala-version <version>] " +
"[--android] " +
@kxbmap
kxbmap / gist:653279
Created October 29, 2010 10:15
NEWT Window
import javax.media.opengl.{ GLAutoDrawable, GLProfile, GLCapabilities, GLEventListener }
import com.jogamp.newt.event.{ WindowAdapter, WindowEvent }
import com.jogamp.newt.opengl.GLWindow
import com.jogamp.opengl.util.FPSAnimator
object NewtSample {
def main(args : Array[String]){
GLProfile.initSingleton()
run()
}
class Matrix extends Function2[Int, Int, Float] {
import Matrix.{ width, height }
private val e = new Array[Float](width * height)
def apply(row : Int, col : Int) = e(row * width + col)
def update(row : Int, col : Int, value : Float) { e(row * width + col) = value }
def initializeWith(f : (Int, Int) => Float) = {
for {
row <- 0 until height
@kxbmap
kxbmap / GoodCodeRed.java
Created October 18, 2014 12:05
IDEA 139.69.2 - good code red
package sample;
import java.util.Map;
/**
*
*/
public class GoodCodeRed<V> {
public <K> Map<K, V> test(K k) {
$ scalac sample.scala
sample.scala:14: error: applyDynamic does not support passing a vararg parameter
new Foo().foo(xs:_*).foobar(new Bar().bar)
^
one error found