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 inverseFizzBuzz(xs: Seq[String]):Int = { | |
def fizzBuzz: Stream[String] = { | |
def f(x:Int): Stream[String] = { | |
def fizz(x: Int) = if (x % 3 == 0) "fizz" else "" | |
def buzz(x: Int) = if (x % 5 == 0) "buzz" else "" | |
Stream.cons(fizz(x) + buzz(x), f(x + 1)) | |
} | |
f(1) | |
} | |
fizzBuzz.indexOfSlice(xs) + 1 |
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
# Specs2 | |
snippet specs2 | |
abbr specs2 snipet | |
prev_word '^' | |
import org.specs2.mutable.Specification | |
import anorm._ | |
import play.api.db.DB | |
import play.api.Play.current | |
import org.specs2.mutable._ | |
import play.api.test.Helpers._ |
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
set nocompatible | |
filetype off | |
set rtp+=~/.vim/vundle.git/ | |
call vundle#rc() | |
Bundle 'tpope/vim-fugitive' | |
Bundle 'neocomplcache' | |
"required make -f mak_mac.mak |
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
object ImageUtil { | |
import java.awt.image.BufferedImage; | |
import javax.imageio.ImageIO; | |
import java.awt.Color | |
import java.io.{File, FileOutputStream, OutputStream} | |
def alpha(x: Int): Int = x >>> 24 | |
def red(x: Int): Int = x >> 16 & 0xff | |
def green(x: Int): Int = x >> 8 & 0xff | |
def blue(x: Int): Int = x & 0xff |
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
val largeDigits = Map('億' -> 100000000, '万' -> 10000) | |
val digits = Map('千' -> 1000, '百' -> 100, '十' -> 10) | |
val nums = Map('一' -> 1, '二' -> 2, '三' -> 3, '四' -> 4, '五' -> 5, '六' -> 6, '七' -> 7, '八' -> 8, '九' -> 9) | |
def slice(xs:String, p:(Char) => Boolean): List[String] = { | |
if (xs.isEmpty) Nil | |
else { | |
val pos = xs indexWhere p | |
xs splitAt(pos + 1) match { | |
case ("", y) => List(y) |
NewerOlder