Skip to content

Instantly share code, notes, and snippets.

View lildata's full-sized avatar

Programming is fun lildata

View GitHub Profile
@lildata
lildata / jgraph.clj
Last active August 29, 2015 14:23 — forked from weissjeffm/jgraph.clj
; nREPL 0.1.7-preview
user> (use 'seesaw.core)
nil
user> (def myframe (frame :title "Hello" :on-close :exit))
#'user/myframe
user> (import com.mxgraph.view.mxGraph)
com.mxgraph.view.mxGraph
user> (def mygraph (mxGraph.))
#'user/mygraph
user> (defn display [content]
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@lildata
lildata / companionOf.scala
Last active August 29, 2015 14:21 — forked from piotrga/gist:5928581
Get companion object instance with new Scala reflection API
trait ReflectionSugars{
import scala.reflect.runtime.{universe => ru}
private lazy val universeMirror = ru.runtimeMirror(getClass.getClassLoader)
def companionOf[T](implicit tt: ru.TypeTag[T]) = {
val companionMirror = universeMirror.reflectModule(ru.typeOf[T].typeSymbol.companionSymbol.asModule)
companionMirror.instance
}
}
object x {
// stream a sql query
def sql( str:String ):Stream[ResultSet] = withStatement { s =>
val rs = s executeQuery str
new Iterator[ResultSet] { def hasNext = rs.next ; def next = rs }.toStream
}
// loan a sql statement