This file contains hidden or 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
.ui-dialog-titlebar { | |
display: none; | |
} |
This file contains hidden or 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.annotation.tailrec | |
class StringSupport(s: String) { | |
def reverseOrder: String = s.toList.foldLeft(Nil: List[Char])((result, c) => c :: result).mkString | |
def reverseCase: String = s.toList.foldRight(Nil: List[Char])((c, result) => c match { | |
case c if c.isUpper => c.toLower :: result | |
case c if c.isLower => c.toUpper :: result | |
case c => c :: result | |
}).mkString |
This file contains hidden or 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
// *** S-99: Ninety-Nine Scala Problems *** | |
// http://aperiodic.net/phil/scala/s-99/ | |
// | |
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scalatest_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar | |
// scala -cp scalatest-*.jar s99.scala | |
import org.scalatest.matchers.ShouldMatchers._ | |
// P01: Find the last element of a list. | |
def last[T](list: List[T]): T = { // TODO } |
This file contains hidden or 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 akr.emp.service; | |
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; | |
import javax.persistence.EntityManager; | |
import javax.persistence.TypedQuery; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.NoSuchElementException; |
This file contains hidden or 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
// *** S-99: Ninety-Nine Scala Problems *** | |
// http://aperiodic.net/phil/scala/s-99/ | |
// | |
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scal.test_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar | |
// scala -cp scalatest-*.jar s99-21-28.scala | |
import org.scalatest.matchers.ShouldMatchers._ | |
import scala.annotation._ | |
class NotImplementedYet extends RuntimeException |
This file contains hidden or 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
def flatMapSublists[A,B](ls: List[A])(f: (List[A]) => List[B]): List[B] = { | |
def sublists[A](ls: List[A]): List[List[A]] = { | |
ls match { | |
case Nil => List(List()) | |
case x :: xs => ls :: sublists(xs) | |
} | |
} | |
sublists(ls).flatMap(f) | |
} |
This file contains hidden or 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
// simple query | |
db.inTransaction { q => | |
q.select("select * from emp") { row => | |
User(row.id, row.name) | |
} | |
} | |
// many to one | |
dbinTransaction { | |
q => for(p <- q.select("select * from emp limit 3") { r => |
This file contains hidden or 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 s99 | |
object P46 { | |
def and(a: Boolean, b: Boolean): Boolean = a && b | |
def or(a: Boolean, b: Boolean): Boolean = a || b | |
def nand(a: Boolean, b: Boolean): Boolean = ! and(a, b) | |
def xor(a: Boolean, b: Boolean): Boolean = or(a, b) && !and(a, b) | |
def nor(a: Boolean, b: Boolean): Boolean = ! or(a, b) | |
def impl(a: Boolean, b: Boolean): Boolean = a | |
def equ(a: Boolean, b: Boolean): Boolean = a == b |
This file contains hidden or 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.util.parsing.combinator._ | |
/** | |
* <hosts> ::= { <line> } | |
* <line> ::= <entry> | [ <comment> ] <eol> | |
* <entry> ::= <ip-address> <hostnames> [ <comment> ] <eol> | |
* <ip-address> ::= <ipv4-address> | <ipv6-address> | |
* <ipv4-address> ::= "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}" | |
* <ipv6-address> ::= ... | |
* <hostnames> ::= <hostname> { <hostname> } |
This file contains hidden or 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
public class UserAgent { | |
private nl.bitwalker.useragentutils.UserAgent ua; | |
private UserAgent(nl.bitwalker.useragentutils.UserAgent ua) { | |
this.ua = ua; | |
} | |
public boolean isFirefox7Plus() { | |
if (ua.getBrowser().getGroup() == Browser.FIREFOX) { |
OlderNewer