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 | |
object Crap extends App { | |
val BASE = 16 | |
val DIGITS = "0123456789ABCDEF" | |
// Original | |
def encode0(number: BigInt): String = { | |
require(number > 0, "number must not be negative") |
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
trait FrontendRoutes extends ScalatraServlet with ScalateSupport { | |
val db: Database | |
get("/") { | |
contentType = "text/html" | |
ssp("/index") | |
} | |
get("/matches") { | |
db withSession { | |
val q3 = for { |
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
cookie:c rnorris$ cat > foo.scala | |
class Foo(bar: Object) { | |
val milk = bar | |
def water = milk | |
def braun = bar | |
} | |
cookie:c rnorris$ scalac foo.scala |
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
lambda = Lpr + 6.288750 * sin(Mpr) | |
+ 1.274018 * sin(2*D - Mpr) | |
+ 0.658309 * sin(2*D) | |
+ 0.213616 * sin(2*Mpr) | |
- e * 0.185596 * sin(M) | |
- 0.114336 * sin(2*F) | |
+ 0.058793 * sin(2*D - 2*Mpr) | |
+ e * 0.057212 * sin(2*D - M - Mpr) | |
+ 0.053320 * sin(2*D + Mpr) | |
+ e * 0.045874 * sin(2*D - M) |
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 util | |
import scalaz.effect.IO | |
import scalaz._ | |
import Scalaz._ | |
import scala.concurrent.stm.{ retry => stmRetry, _ } | |
object X { | |
type STM[+A] = ReaderT[IO, InTxn, A] |
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
scala> import Ordering.Implicits._ | |
import Ordering.Implicits._ | |
scala> :pa | |
// Entering paste mode (ctrl-D to finish) | |
case class A(n:Int, s:String) | |
object A { | |
implicit val ord = Ordering.by(unapply) | |
} |
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
class A(n:Int) { | |
println(n) | |
} | |
cookie:tmp rnorris$ javap -classpath . A | |
Compiled from "test.scala" | |
public class A extends java.lang.Object{ | |
public A(int); | |
} |
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
// Some thoughts on IO and Futures | |
object Future { | |
// A future must have the option of performing IO during its computation; this | |
// is one of the primary uses of Futures. So we construct with an IO[A]. Construction | |
// is itself an effect because it forks execution of `a`. | |
def ioFuture[A](a: IO[A]): IO[Future[A]] | |
// Unit, but it has to be eager, so not super useful. What if it's not really a monad at all? |
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 Marrrk { | |
trait AccessibilityNodeInfo { | |
def getChildCount: Int | |
def getChild(n: Int): AccessibilityNodeInfo | |
def getClassName: String | |
def performAction(a: Any): Boolean | |
} | |
object AccessibilityNodeInfo { |
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 children(n: AccessibilityNodeInfo): List[AccessibilityNodeInfo] = | |
(0 until n.getChildCount).toList.map(n.getChild) | |
def linearize(n: AccessibilityNodeInfo): List[AccessibilityNodeInfo] = | |
n :: children(n).flatMap(linearize) | |
def getCertainClass(ani: AccessibilityNodeInfo, className: String, occurrence: Int): Option[AccessibilityNodeInfo] = | |
linearize(ani).filter(_.getClassName == className).lift(occurrence) |