Skip to content

Instantly share code, notes, and snippets.

View Happy0's full-sized avatar

Gordon Martin Happy0

  • Glasgow, Scotland
View GitHub Profile
[lila] $ inspect tree compile
[info] lila/compile:compile = Task[sbt.inc.Analysis]
[info] +-lila/compile:incCompileSetup = Task[sbt.Compiler$IncSetup]
[info] | +-*/*:skip = Task[Boolean]
[info] | +-lila/compile:compileAnalysisFilename = Task[java.lang.String]
[info] | | +-*/*:crossPaths = true
[info] | | +-lila/*:scalaBinaryVersion = 2.11
[info] | |
[info] | +-*/*:compilerCache = Task[xsbti.compile.GlobalsCache]
[info] | +-*/*:definesClass = Task[scala.Function1[java.io.File, scala.Function1[java.lang.String, Boolean]]]
vagrant@vagrant:~$ cd /vagrant/
vagrant@vagrant:/vagrant$ sbt run -Dhttp.port=9663
[info] Loading project definition from /vagrant/project
[info] Set current project to lila (in build file:/vagrant/)
MessageCompiler took 305ms
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9663
Might want to add similar for linking to user profiles (via @).:
1. https://github.com/ornicar/lila/blob/4c86f1051b18429c275bf45e23800378a27f1ba0/app/templating/StringHelper.scala#L30
module Move (makeMove, Move (PlaceTiles, Exchange, Pass), GameTransition(MoveTransition, ExchangeTransition, PassTransition)) where
import ScrabbleError
import FormedWord
import Control.Monad
import Control.Applicative
import Data.Maybe
import Game
import Player
import Data.Map as Map
@Happy0
Happy0 / gist:5891733
Created June 29, 2013 16:20
Bad prime finder
object Primes extends App {
val candidates = (Stream from (5, 2))
def isPrime(number: Int, discovered: Stream[Int]): Boolean =
discovered takeWhile (_ < Math.sqrt(number).toInt) forall (x => number % x != 0)
val primes: Stream[Int] = 2 #:: 3 #:: (candidates filter { x => isPrime(x, primes) })
Bag="JEARVINENVO_NILLEWBKONUIEUWEAZBDESIAPAEOOURGOCDSNIADOAACAR_RMYELTUTYTEREOSITNIRFGPHAQLHESOIITXFDMETG"
start
a: JEARVIN
b: ENVO_NI
c: LLEWBKO
d: NUIEUWE
bag: LLEWBKONUIEUWEAZBDESIAPAEOOURGOCDSNIADOAACAR_RMYELTUTYTEREOSITNIRFGPHAQLHESOIITXFDMETG
@Happy0
Happy0 / stepthrough
Created June 16, 2013 00:12
Scrabble game step by step for test case
Bag="JEARVINENVO_NILLEWBKONUIEUWEAZBDESIAPAEOOURGOCDSNIADOAACAR_RMYELTUTYTEREOSITNIRFGPHAQLHESOIITXFDMETG"
start
a: JEARVIN
b: ENVO_NI
c: LLEWBKO
d: NUIEUWE
bag: LLEWBKONUIEUWEAZBDESIAPAEOOURGOCDSNIADOAACAR_RMYELTUTYTEREOSITNIRFGPHAQLHESOIITXFDMETG
Don't expose the Letter / BlankLetter constructors to anything that's not the letterbag...
@Happy0
Happy0 / gist:5327088
Last active December 15, 2015 21:39
Ornicar's remaining suggestions
Don't pattern match an Option. Use fold (available in Scala 2.10)
Don't use Either: Have a look at scalaz's Valid / Try monad. Not sure about this one, feels ugly using exeptions when the behaviour is fully expected. People make invalid moves in scrabble all the time. Threading around 'Either's isn't particularly satisfying either. Hmmm...
- Look into the role of 'flatMap' in Try monads.
Try to avoid the InstanceOf usage.
Include an .sbt file (for building.)