Skip to content

Instantly share code, notes, and snippets.

💭
🕉 Coding...

Daniel Dietrich danieldietrich

💭
🕉 Coding...
Block or report user

Report or block danieldietrich

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
@danieldietrich
danieldietrich / Account.scala
Created Mar 10, 2012
Play w/ Scala: Url Path Binding
View Account.scala
package models
import play.api.mvc.PathBindable
object Account extends Enumeration {
val Company, Sales = Value // create enumerated values
// url path binding (routes)
implicit def bindableAccount = new PathBindable[Account.Value] {
@danieldietrich
danieldietrich / Account.scala
Created Mar 11, 2012
Url Path Binding w/o Boilerplate
View Account.scala
package models
object Account extends BindableEnum {
val Company, Sales = Value // create enumerated values
}
@danieldietrich
danieldietrich / CachedLdapPermissionResolver
Created Mar 20, 2012
Howto abstract an LDAP layer to resolve permissions
View CachedLdapPermissionResolver
/**
* PLEASE AVOID THIS IMPLEMENTATION BECAUSE OF...
* - a cache should be garbage collectable (on low memory)
* (see Soft Reference, Weak Reference etc.)
* - a cache should be thread safe (this is not)
*/
class CachedLdapPermissionResolver extends LdapPermissionResolver {
private static final long MAX_TIME = 1000 * 60 * 10; // = 10 min.
@danieldietrich
danieldietrich / 1 Tree.scala (first shot)
Created May 13, 2012
Treehugger.scala inspired by treehugger.js
View 1 Tree.scala (first shot)
package net.danieldietrich.scala.treehugger
sealed abstract class Tree
case class Node(id: Symbol)(children: Tree*) extends Tree
case class Leaf(id: Symbol)(value: String) extends Tree
object Example {
@danieldietrich
danieldietrich / 1_Sample.java
Created Oct 5, 2012
Extension Methods in Java, Xtend and Scala
View 1_Sample.java
/* JAVA */
public class SampleExtensions {
public static String sort(String s) {
final char[] arr = s.toCharArray();
java.util.Arrays.sort(arr);
return String.valueOf(arr);
}
@danieldietrich
danieldietrich / Classpath.java
Last active Dec 14, 2015
Classpath Resources
View Classpath.java
package net.danieldietrich;
import java.io.File;
import java.net.URI;
import java.net.URL;
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@danieldietrich
danieldietrich / 0_SimpleTest.scala
Last active Dec 15, 2015
Align cascaded String when using Scala 2.10's String interpolation.
View 0_SimpleTest.scala
object SimpleTest extends App {
import StringContextImplicits._
val list = List("Foo", "Bar", "Baz").mkString("\n")
/*-----------
#
test -->
@danieldietrich
danieldietrich / eclipse-current.sh
Last active Dec 23, 2015
Build Eclipse Kepler with support for Java 8 - Eclipse platform branch R4_3_maintenance - JDT branch BETA_JAVA8
View eclipse-current.sh
#!/bin/sh
#
# Compiling eclipse kepler with java 8 support (https://bugs.eclipse.org/bugs/show_bug.cgi?id=380190)
#
export MAVEN_OPTS=-Xmx2048m
BRANCH="R4_3_maintenance"
BRANCH_JAVA8="BETA_JAVA8"
@danieldietrich
danieldietrich / Build.scala
Created Nov 11, 2013
sbt 0.13 project configuration template targeting scala 2.10.3 and eclipse ide
View Build.scala
import sbt._
import Keys._
object ScalaBuild extends Build {
val buildOrganization = "my.group.id"
val buildName = "project-template"
val buildVersion = "1.0-SNAPSHOT"
val buildScalaVersion = "2.10.3"
View mvn release:perform
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Javaslang 1.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.4.2:perform (default-cli) @ javaslang ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd /Users/daniel/git/rocketscience-projects/javaslang/target && git clone --branch javaslang-1.0.0 git@github.com:rocketscience-projects/javaslang.git /Users/daniel/git/rocketscience-projects/javaslang/target/checkout
[INFO] Working directory: /Users/daniel/git/rocketscience-projects/javaslang/target
You can’t perform that action at this time.