Skip to content

Instantly share code, notes, and snippets.

Alad commented on 2018-03-28 20:11
Thanks :)
runical commented on 2018-03-27 07:39
I'll probably have some time tomorrow evening. If that isn't a problem,
I'll be happy to apply the patches.
E: Currently updating and testing
@Rogach
Rogach / Test.scala
Created May 25, 2018 03:14
scallop-bug-161 test code
object Test {
def main(args: Array[String]) {
val conf = new TestClass(args)
}
}
import org.rogach.scallop.{ScallopConf, ScallopOption, Serialization, ValueConverter, singleArgConverter}
class TestClass(args: Seq[String]) extends ScallopConf(args) with Serialization {
@Rogach
Rogach / Help output.txt
Created April 4, 2012 20:16
Scallop examples
test 1.2.3 (c) 2012 Mr Placeholder
Usage: test [OPTION]...
test is an awesome program, which does something funny
Options:
-Dkey=value [key=value]...
some key-value pairs
-d, --donkey
use donkey mode
-m, --monkeys <arg>
@Rogach
Rogach / ShowTree.scala
Created September 12, 2013 06:41
Macro to display case class hierarchy as Swing JTree. (now uses quasiquotes)
package dxf.macros
import scala.language.experimental.macros
import scala.reflect.macros.Context
import scala.swing._
import scala.swing.Swing._
import javax.swing._
import javax.swing.tree.DefaultMutableTreeNode
object ShowTree {
@Rogach
Rogach / ShowTree.scala
Created September 10, 2013 04:30
Macro to display case class hierarchy as Swing JTree.
package dxf.macros
import scala.language.experimental.macros
import scala.reflect.macros.Context
import scala.swing._
import scala.swing.Swing._
import javax.swing._
import javax.swing.tree.DefaultMutableTreeNode
object ShowTree {
@Rogach
Rogach / Declutter.scala
Created August 5, 2013 17:04
Phase for Slick, that unboxes wrapped tables
package scala.slick.compiler
import scala.slick.ast._
import scala.collection.mutable.HashMap
class Declutter extends Phase {
val name = "declutter"
def apply(tree: Node, state: CompilationState): Node = {
val replaced = new HashMap[Symbol, Symbol]

Example table definitions & query:

case class House(id: Long, address: String)
case class Metro(id: Long, houseId: Long, name: String)
case class Room(id: Long, houseId: Long, area: Int)

object Houses extends Table[House]("Houses") {
  def id = column[Long]("id", O.AutoInc, O.PrimaryKey)
  def address = column[String]("address")
@Rogach
Rogach / Declutter.scala
Created August 5, 2013 16:33
Phase for Slick, that unboxes wrapped tables
package scala.slick.compiler
import scala.slick.ast._
import scala.collection.mutable.HashMap
class Declutter extends Phase {
val name = "declutter"
def apply(tree: Node, state: CompilationState): Node = {
val replaced = new HashMap[Symbol, Symbol]
@Rogach
Rogach / toTree.hs
Last active December 15, 2015 00:19
Graph.toTree (haskell & scala)
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.List
import Text.Regex
import Control.Monad.State
import Control.Applicative
-- some setup for the types
type Graph a = Map.Map a [a]
data Tree a = Tree
@Rogach
Rogach / gist:4712253
Last active December 12, 2015 04:08
Scala-tuplicity proof :)
scala> (1 to 50).map(i => s"b$i:Int").mkString("case class A(", ", ", ")")
res0: String = case class A(b1:Int, b2:Int, b3:Int, b4:Int, b5:Int, b6:Int, b7:Int, b8:Int, b9:Int, b10:Int, b11:Int, b12:Int, b13:Int, b14:Int, b15:Int, b16:Int, b17:Int, b18:Int, b19:Int, b20:Int, b21:Int, b22:Int, b23:Int, b24:Int, b25:Int, b26:Int, b27:Int, b28:Int, b29:Int, b30:Int, b31:Int, b32:Int, b33:Int, b34:Int, b35:Int, b36:Int, b37:Int, b38:Int, b39:Int, b40:Int, b41:Int, b42:Int, b43:Int, b44:Int, b45:Int, b46:Int, b47:Int, b48:Int, b49:Int, b50:Int)
scala> case class A(b1:Int, b2:Int, b3:Int, b4:Int, b5:Int, b6:Int, b7:Int, b8:Int, b9:Int, b10:Int, b11:Int, b12:Int, b13:Int, b14:Int, b15:Int, b16:Int, b17:Int, b18:Int, b19:Int, b20:Int, b21:Int, b22:Int, b23:Int, b24:Int, b25:Int, b26:Int, b27:Int, b28:Int, b29:Int, b30:Int, b31:Int, b32:Int, b33:Int, b34:Int, b35:Int, b36:Int, b37:Int, b38:Int, b39:Int, b40:Int, b41:Int, b42:Int, b43:Int, b44:Int, b45:Int, b46:Int, b47:Int, b48:Int, b49:Int, b50:Int)
defined class A
s