Skip to content

Instantly share code, notes, and snippets.

View dwijnand's full-sized avatar

Dale Wijnand dwijnand

View GitHub Profile

how many args and which types does this class take?

without "dangling parens"

  private[this] class ChangeOwnerAndModuleClassTraverser(
      oldowner: global.Symbol,
      newowner: global.Symbol)
      extends global.ChangeOwnerTraverser(oldowner, newowner) {
    override def traverse(tree: global.Tree): Unit = {
diff --git a/Main$.class b/Main$.class
index cb3a2d6..06067c6 100644
--- a/Main$.class
+++ b/Main$.class
@@ -28,23 +28,12 @@ public final class Main$ {
##: aload_3
##: instanceof ### // class Recovered2
##: ifeq ##
-##: aload_3
-##: checkcast ### // class Recovered2
package t
import sbt._
object Main {
def simpleFileFilterFnClass(ff: FileFilter) = ff.asInstanceOf[SimpleFileFilter].acceptFunction.getClass
def simpleFilterFnClass(ff: FileFilter) = ff.asInstanceOf[SimpleFilter].acceptFunction.getClass
sealed abstract class Extractor {
def fnClass: Class[_ <: (Nothing => Boolean)]
@dwijnand
dwijnand / reload.sbt
Last active October 6, 2017 07:25
Stick it in ~/.sbt/0.13/reload.sbt
def buildFiles(b: File) = ((b * "*.sbt") +++ ((b / "project") ** ("*.scala" | "*.sbt")) filter (_.isFile))
def genBuildFilesHashesAt(base: File) = buildFiles(base).get.map(f => f -> (Hash toHex Hash(f))).toMap
def genBuildFilesHashes(units: Map[URI, LoadedBuildUnit]) =
(units.values flatMap (_.defined) map (_._2.base) flatMap genBuildFilesHashesAt).toMap.##
val buildFilesHashes = settingKey[Int]("") in Global
buildFilesHashes := genBuildFilesHashes(loadedBuild.value.units)
shellPrompt in Global := (s =>
@dwijnand
dwijnand / build.sbt
Last active May 4, 2017 21:02 — forked from paulp/build.sbt
/** Your task is to reason your way to which compiler
* options which will be passed for each of
* 1) sbt root/compile
* 2) sbt p1/compile
*/
scalacOptions in Global += "-D1"
scalacOptions in ThisBuild += "-D0"
scalacOptions := Seq("-DSBT")
@dwijnand
dwijnand / localArtifactRepo.sbt
Last active April 16, 2017 03:46
Local Artifactory & Nexus sbt setup
def buildTimestampSuffix = ";build.timestamp=" + new java.util.Date().getTime
val localArtifactoryRelease = "local-artifactory-release" at "http://localhost:8081/artifactory/libs-release"
val localArtifactorySnapshot = "local-artifactory-snapshot" at "http://localhost:8081/artifactory/libs-snapshot"
val localArtifactoryReleaseLocal = "local-artifactory-release-local" at "http://localhost:8081/artifactory/libs-release-local"
def localArtifactorySnapshotLocal = "local-artifactory-snapshot-local" at "http://localhost:8081/artifactory/libs-snapshot-local" + buildTimestampSuffix
val localArtifactoryCreds = Credentials("Artifactory Realm", "localhost", "admin", "password")
// credentials += localArtifactoryCreds
@dwijnand
dwijnand / dependencyList.sbt
Last active December 5, 2016 01:44
Semi-port of "mvn dependency:list -Dsort=true -DoutputFile=deps.mvn.txt" to sbt
val dependencyList = taskKey[File]("")
val dependencyListDef = Def.task {
val f = baseDirectory.value / "deps.sbt.txt"
streams.value.log.info(s"Writing to $f")
IO.write(f, "\n")
IO.append(f, "The following files have been resolved:\n")
val cp = (managedClasspath in Test).value
val lines = cp map { att =>
val md = att.metadata
@dwijnand
dwijnand / .profile
Created October 19, 2016 23:53 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@dwijnand
dwijnand / NowIso8601.scala
Last active September 7, 2016 22:43
nowIso8601 without JodaTime
def nowIso8601() = {
val df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
df setTimeZone (java.util.TimeZone getTimeZone "UTC")
df format new java.util.Date()
}
package p
/** Decodes strings into Ts */
trait Decoder[T] {
def decode(s: String): Either[String, T]
}
object Decoder {
def apply[T](f: String => Either[String, T]): Decoder[T] =
new Decoder[T] { def decode(s: String) = f(s) }