DanielOgbuagu
DanielOgbuagu
Reputation Top 5%
Daniel Ogbuagu
2 Snippets  (246th place)
Published
1 Channel
Created
0 Channels
Following
60 points  (434th place)
Reputation
Junior Code Generator
Junior Publisher
Junior Trend Maker
Junior Influencer
Junior Popular Coder
Junior Autobiographer
Senior Autobiographer
Junior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by DanielOgbuagu

public by DanielOgbuagu  201738  1  5  0

Adding a *.jar file (originating from java-wrapped C++ code) to an SBT project classpath

I thought using unmanaged dependencies in SBT projects was simply dropping a jar file into the lib directory, until I bought an SDK for a biometric device. Both the C++ and the Java packages were provided. I opted for the Java package, copying the provided jar file and the JNI (*.so) files into the appropriate locations and configuring the ja
/**
 * In my <code>build.sbt</code> file, I appended a blank line and then the following:
 */

libraryDependencies += "groupID" % "artifactId" % "revision" from "file:///home/Danogbuagu/Projects/biometric-lib/filename.jar"

// where,
// groupID for example is like: com.zigzagcompany 
// artifactId for example is like: zigzag
// revision for example is like: 1.3.4
// Remember the line befor the code and that after.
;

public by DanielOgbuagu  4161  1  6  4

Creating MongoDb Compound Indexes in Liftweb (i.e. Scala)

// Assuming the following Person class and companion object:
class Person extends MongoRecord[Person] with ObjectIdPk[Person] {
  def meta = Person

  object surname extends StringField(this, 40) 

  object firstName extends StringField(this, 40) 

  object otherNames extends StringField(this, 40) {
    override def optional_? = true
  }
  
  // other fields ...
  
}

object Person extends Person with MongoMetaRecord[Person]
with RogueMetaRecord[Person] with Loggable {

  import mongodb.BsonDSL._

  override def collectionName = "Persons"

// Now, here's the compound index, unique on the combined fields.
  val nameKeys = (surname.name -> 1) ~ (firstName.name -> 1)
  createIndex(nameKeys, unique = true)
}
;