- Introductions
- Name, company, kind of development, etc.
- Discussion
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
| #!/usr/bin/env ruby -wKU | |
| # -*- coding: utf-8 -*- | |
| # Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/) | |
| # Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/) | |
| # Changes: – support for setting the creation date with 'Date:' MMD metadata attribute | |
| # – create only one Evernote note per (Multi)Markdown input passed (instead of one per line) | |
| # – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript) | |
| # – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script) | |
| # – make smart typography processing optional (set SMARTY to 'false' to bypass processing; |
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
| // Comparison of using `null` vs `None` to represetn NAs | |
| val csvtext = "1,4,5,6,,9,12" | |
| val tokens = csvtext.split(",").toList | |
| // Null NA Approach | |
| val nullNAs = tokens.map(t => if(t.isEmpty) null else t) | |
| val numFromNulled = for { | |
| t <- nullNAs | |
| num = if(t == null) null else t.toInt |
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
| // NB: Requires SBT >= 0.13.5 | |
| package pomhelpers | |
| import sbt._ | |
| import Keys._ | |
| import sbt.complete.Parser | |
| import sbt.complete.DefaultParsers._ | |
| object ExtractMvnDependencies extends AutoPlugin { | |
| override def trigger = allRequirements |
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
| import akka.actor._ | |
| import akka.stream.actor.ActorPublisher | |
| import akka.stream.scaladsl._ | |
| import akka.stream.{ FlowMaterializer, MaterializerSettings } | |
| import akka.testkit._ | |
| import org.scalatest.FunSpecLike | |
| import scala.concurrent.Future | |
| import scala.concurrent.duration._ | |
| class FutureMergeTest extends TestKit(ActorSystem()) with FunSpecLike with ImplicitSender { |
Here's one way of brute-force converting a bunch of Java code to Scala without too much concern for correctness.
Hard stuff is done by scalagen.
If the project is Maven-based with an existing pom.xml, all you need to do is run the scalagen Maven plugin:
mvn com.mysema.scalagen:scalagen-maven-plugin_2.10.1:0.3.2:main -DtargetFolder=target/scala
You have to have a pom.xml file for this to work. If your project is configured with sbt (or have no project!), use the sbt makePom task to create one:
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
| import sbt._ | |
| import sbt.Keys.commands | |
| object OpenFolderHere extends AutoPlugin { | |
| override def trigger = allRequirements | |
| override lazy val projectSettings = Seq( | |
| commands += Command.command("openHere") { (state: State) => | |
| "open .".! | |
| state | |
| } | |
| ) |
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
| addCommandAlias("package", "collectPackages") | |
| addCommandAlias("stage", "universal:stage") | |
| enablePlugins(GitBranchPrompt) | |
| enablePlugins(JavaAppPackaging) | |
| // TODO: Need to figure out how to look this up from the outer project | |
| version in ThisBuild := "0.2.1-SNAPSHOT" |
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
| 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 |
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
| /** 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 |
