Skip to content

Instantly share code, notes, and snippets.

Dale Wijnand dwijnand

Block or report user

Report or block dwijnand

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dwijnand
dwijnand / sbt-new
Created Mar 8, 2019 — forked from paulp/sbt-new
a less messy sbt new
View sbt-new
#!/usr/bin/env bash
#
# Intercepting the output of 'sbt new' directly fails
# because it asks interactive questions so we can't process
# line by line. An apparent OSX-specific bug in egrep
# fails on lookbehind clauses so we use ag. Capturing
# the interactive output with script succeeds, but script
# uses \r\n to terminate lines so we can't match the
# filename with '.*' or we get
#
@dwijnand
dwijnand / RefOrNull.scala
Created Dec 6, 2018
Playing with typesafe builder patterns
View RefOrNull.scala
object RefOrNull {
type Id[A >: Null <: AnyRef] = A
type No[A >: Null <: AnyRef] = Null
def nullAs[A] = null.asInstanceOf[A]
def sideEffect[A](result: A, exprs: Any*): A = result
def set[A, B](result: A, exprs: Any*): B = result.asInstanceOf[B]
}
import RefOrNull._
final class Data[
@dwijnand
dwijnand / .gitignore
Created Nov 7, 2018 — forked from jboner/OrderManagement.scala
Demo of an Event-driven Architecture in Akka and Scala. Show-casing Events-first DDD, Event Sourced Aggregates, Process Manager, etc.
View dangling-parens.md

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 = {
@dwijnand
dwijnand / .sbtopts
Last active Mar 7, 2019
Rust's From/Into ported to Conversion.scala
View .sbtopts
-sbt-version
1.2.7
View 0.unappy_vs_is_type.diff
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
View FileFilter-toString.scala
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)]
View 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 / reload.sbt
Last active Oct 6, 2017
Stick it in ~/.sbt/0.13/reload.sbt
View 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 / .profile
Created Oct 19, 2016 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
View .profile
# 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
You can’t perform that action at this time.