Last active
August 29, 2015 14:19
-
-
Save iximeow/537770a522327358ea73 to your computer and use it in GitHub Desktop.
I'm a bad person
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 net.iximeow | |
| import scala.slick.driver.SQLiteDriver.simple._ | |
| package object slick { | |
| var instanceNum = 0; | |
| def table(args: String*) = { | |
| val xs = args.toSeq | |
| var str = "" | |
| str += s"class T${instanceNum}(tag: Tag) extends Table[(${xs.mkString(", ")})](tag, ${'"'}t${instanceNum}${'"'}) {" | |
| def makeSchema = { | |
| xs.zipWithIndex.map { case (className: String, idx: Int) => | |
| s"column[${className}](${'"'}f${idx}${'"'})" | |
| }.mkString(", ") | |
| } | |
| str += s" def * = (${makeSchema})" | |
| str += s"}" | |
| instanceNum = instanceNum + 1 | |
| str | |
| } | |
| def copy(s: String) = { | |
| import java.awt.event._ | |
| import java.awt.{Toolkit, Robot} | |
| import java.awt.datatransfer.StringSelection | |
| val clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); | |
| val stringSelection = new StringSelection(s) | |
| clipboard.setContents(stringSelection, null) | |
| val robot = new Robot() | |
| robot.keyPress(KeyEvent.VK_CONTROL) | |
| robot.keyPress(KeyEvent.VK_SHIFT) | |
| robot.keyPress(KeyEvent.VK_INSERT) | |
| robot.keyRelease(KeyEvent.VK_INSERT) | |
| robot.keyRelease(KeyEvent.VK_SHIFT) | |
| robot.keyRelease(KeyEvent.VK_CONTROL) | |
| Thread.sleep(400) | |
| robot.keyPress(KeyEvent.VK_ENTER) | |
| robot.keyRelease(KeyEvent.VK_ENTER) | |
| } | |
| def newTable(args: String*) = copy(table(args:_*)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment