Skip to content

Instantly share code, notes, and snippets.

package twentyquestions
import scala.io.StdIn
sealed trait Step
case class Question(text: String, yes: Step, no: Step) extends Step
case class Guess(text: String) extends Step
case class AskYesNo(prompt: String, ifYes: () => Unit, ifNo: () => Unit)
package twentyquestions
import scala.io.StdIn
sealed trait Step
case class Question(text: String, yes: Step, no: Step) extends Step
case class Guess(text: String) extends Step
sealed trait H {
def falsy: Boolean
}
case class A(b: Boolean) extends H {
override def falsy = !b
}
case class C(d: Byte, more: H) extends H {
override def falsy = d == 0 && more.falsy
@nafg
nafg / server.app.App.scala
Last active January 23, 2017 06:21
Failed attempt at nested stacked trait
trait App extends EquipmentLayer with HospitalLayer {
def requestEditApi(user0: Option[Volunteers.KEnt]) = new RequestEditApiImpl with RequestEditApi {
override def user = user0
}
object AutoWireServer extends autowire.Server[String, Reader, Writer] {
override def write[A: Writer](r: A): String = upickle.default.write(r)
override def read[A: Reader](p: String): A = upickle.default.read[A](p)
const e = name => props => (...children) => React.createElement(name, props, ...children);
const div = e('div'), h1 = e('h1'), h2 = e('h2'), table = e('table'), tbody = e('tbody'), tr = e('tr'), td = e('td');
Array.prototype.updated = function (index, value) {
const a2 = this.slice();
a2[index] = value;
return a2;
};
const Range = (a, b) => (a >= b) ? [] : [a, ...Range(a + 1, b)];
Naftoli Gugenheim 🎻 [4:58 PM]
Ok where to begin... how about the title
[4:58]
> You Might Not Need TypeScript (or Static Types)
[4:59]
Who is he addressing? Has anyone argued that you "need" them?
/*
* Zmanim Java API
* Copyright (C) 2011 - 2014 Eliyahu Hershfeld
* Copyright (C) September 2002 Avrom Finkelstien
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied
@nafg
nafg / install.sh
Last active October 20, 2016 23:32 — forked from wdullaer/install.sh
Install latest docker-compose on Ubuntu
# Install docker-compose
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9]+\.[0-9]+$" | tail -n 1`
sudo sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
sudo chmod +x /usr/local/bin/docker-compose
sudo sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
package chesednow.model.common
import scala.concurrent.ExecutionContext
import slick.additions.entity._
import slick.ast.BaseTypedType
import chesednow.shared.common.{ChildItems, GenAggregates, RootAggregates}
import lrbcol.model.DBComponent
import lrbcol.model.SlickDriver.api._
@nafg
nafg / act.sc
Created August 5, 2016 03:56
Ammonite script to scrape available Activator templates
import $ivy.`org.jsoup:jsoup:1.7.2`, org.jsoup._
val doc = Jsoup.connect("https://www.lightbend.com/activator/templates").get()
import collection.JavaConverters._
doc.select("#searchFilterContent h1 > a").asScala.map(_.attr("href").stripPrefix("/activator/template/"))