Skip to content

Instantly share code, notes, and snippets.

View metasim's full-sized avatar
🇺🇦

Simeon H.K. Fitch metasim

🇺🇦
View GitHub Profile
@metasim
metasim / birthday-greetings.scala
Created November 12, 2015 15:41
Birthday wishes from a colleague.
scala> (1 to 4).map { i => "Happy Birthday " + (if (i == 3) "dear Simeon" else "to You") }.foreach { println }
Happy Birthday to You
Happy Birthday to You
Happy Birthday dear Simeon
Happy Birthday to You
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
Process: java [98221]
Path: /usr/bin/java
Identifier: com.apple.javajdk16.cmd
Version: 1.0 (1.0)
Code Type: X86-64 (Native)
Parent Process: eclipse [8499]
User ID: 224742261
PlugIn Path: /Users/USER/*/libvtkFiltering.5.10.dylib
PlugIn Identifier: libvtkFiltering.5.10.dylib
@metasim
metasim / VTK 6.0.0 Minimal Java Config
Created July 29, 2013 21:03
CMake Config for VTK 6.0 w/Java
# This is the CMakeCache file.
# For build in directory: /CODE/VTK6.0.0
# It was generated by CMake: /usr/local/Cellar/cmake/2.8.10.1/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
@metasim
metasim / on-scala.md
Last active December 22, 2015 07:29
Example reveal.js markdown input, content from in-progress presentation on Scala

What is Scala?

  • A modern, statically typed programming language built upon the Java ecosystem
  • Elegant mix of object orientation and functional programming paradigms
  • Designed to be used by real developers, solving real-world problems
  • Runs on the JVM, providing full interoperability with Java APIs
  • By Martin Odersky, author of the modern `javac` compiler

@metasim
metasim / sbt-jfx-frag.scala
Created September 10, 2013 17:33
Fragment for setting the JDK path for sbt-javafx plugin.
JFX.devKit := {
System.getProperty("os.name").toLowerCase match {
case w if w.startsWith("win") => JFX.jdk("C:/Program Files/Java/jdk1.7.0_25")
case _ => JFX.jdk(javaHome.value.toString)
}
}
@metasim
metasim / repeat-until.scala
Created November 16, 2013 18:31
Example of creating a `repeat { ... } until (...)` like control structure.
import scala.annotation.tailrec
object controls {
def repeat(body: => Unit) = new {
@tailrec
def until(condition: => Boolean) {
body
if (condition) () else until(condition)
}
@metasim
metasim / pom2sbt.sbt
Created January 8, 2016 20:14
Attempt at a command to convert a pom.xml dependency specification into sbt syntax.
/** Utility command to convert in SBT a maven dependency fragment into SBT syntax. */
def Pom2SbtCommand = "pom2sbt"
def Pom2SbtHelp = " <pom.xml>"
import complete.DefaultParsers._
lazy val pomLibs2Sbt = Command(Pom2SbtCommand,
Help((Pom2SbtCommand, Pom2SbtHelp)))(_ ⇒ fileParser(new File("./"))) { (state, file) ⇒
import scala.xml.XML
@metasim
metasim / gremlinUnion.scala
Last active January 25, 2016 16:27
Example of using `union` combinator in gremlin-scala.
val g = TinkerFactory.createModern().asScala
val Age = Key[Vertex]("age")
val Lang = Key[Vertex]("lang")
val trav = g.V(4)
.union(
GremlinScala(__[Vertex]).in().value(Age),
GremlinScala(__[Vertex]).out().value(Lang)
@metasim
metasim / micropublish.sbt
Created March 22, 2016 13:19
M2 publish to a directory in SBT
// Keys to have a submodule publish to a micro-repo.
val publishMicroRepo = taskKey[Unit]("Task to publish artifacts to a local brooklyn micro-repo")
val microRepoTargetDir = settingKey[File]("Directory where to save repository")
val microRepoPublishConfiguration = taskKey[sbt.PublishConfiguration]("Micro-repo publish task config")
val microRepoName = settingKey[String]("Unique sbt repository ID")
// ----------------------------------------------------------------------------
// Support for publishing core libraries to project micro-repo
// ----------------------------------------------------------------------------
lazy val publishSettings = Seq(