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 l2d = Map('i' -> 1, 'v' -> 5, 'x' -> 10, 'l' -> 50, 'c' -> 100) | |
def compute(ds: Seq[Int]) = ds.foldRight((0, 0)) { | |
case (d, (acc, last)) => if (d < last) (acc - d, last) else (acc + d, d) | |
} | |
def roman(numeral: String) = compute(numeral map l2d)._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
case class Grand(parent: Parent) | |
sealed trait Parent { def x: Int } | |
case class Child1(x: Int) extends Parent | |
case class Child2(x: Int) extends Parent | |
val grand = Grand(Child1(3)) | |
it should "modify a field in a sealed trait" in { | |
modify(grand)(_.parent.x).using(_ + 1) should be (Grand(Child1(4))) | |
} |
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 Utils { | |
val disableCache = respondWithHeaders( | |
`Cache-Control`(`no-cache`, `max-age`(0), `must-revalidate`, `no-store`), | |
`Expires`(DateTime.MinValue) | |
) | |
} | |
object BooksRoutes { | |
val routes = path("books" / Segment) { id => | |
complete(id) |
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 scalatags.JsDom.all._ | |
object ScalaJSExample extends js.JSApp { | |
def main() = { | |
} | |
} |
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
# In ~/.config/fish/config.fish | |
set fish_greeting | |
set __fish_git_prompt_showdirtystate 'yes' |
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
#!/usr/bin/env python3 | |
import os | |
import re | |
import sys | |
import fnmatch | |
entities = {} | |
relations = {} |
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 other android imports here | |
... | |
import android.support.v4.app.{ Fragment, FragmentManager, FragmentPagerAdapter } | |
import android.support.v4.view.ViewPager | |
import com.viewpagerindicator.TitlePageIndicator | |
import macroid._ | |
import macroid.FullDsl._ | |
import macroid.contrib._ | |
import macroid.contrib.Layouts._ |
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
@active | |
class A { | |
// all non-@active locals | |
// will be made private | |
var y = 0 | |
def bar(x: Int) = x + 5 | |
@active // should return Unit | |
def foo(x: Int) = { | |
y = bar(x) |
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 android.content.Context | |
import android.util.Log | |
import android.view.{View, ViewGroup} | |
import macroid.AppContext | |
import macroid.MediaQueries._ | |
object Spec { | |
def apply(size: Int, mode: Int) = | |
View.MeasureSpec.makeMeasureSpec(size, mode) |
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
// -- in the activity: | |
var navSlot = slot[ListView] | |
var drawerSlot = slot[DrawerLayout] | |
// -- in onCreate: | |
// ListView tweaks | |
def checkItem(pos: Int) = Tweak[ListView](_.setItemChecked(pos, true)) | |
val singleNoDivider = Tweak[ListView] { lv ⇒ |