Skip to content

Instantly share code, notes, and snippets.

@doitian
doitian / MongoJson.scala
Created May 10, 2013 15:12
Convert play2.0 JsValue to mongodb DBObject provided by casbah
package module.db;
import com.mongodb.casbah.Imports._
import java.text.DateFormat
import java.util.Date
import play.api.data.validation.ValidationError
import play.api.libs.json._
object MongoJson {
def fromJson(json: JsValue) : JsResult[DBObject] = readDBObject.reads(json)
@rjbriody
rjbriody / elasticsearchMongoDBRiver.sh
Last active December 14, 2015 17:28
A one stop shop for how to get, configure, and run mongodb and elasticsearch with the mongodb-river from https://github.com/richardwilly98/elasticsearch-river-mongodb. I am by no means a bash expert and this script is pretty hacky even by my standards, but it is simply meant to illustrate the steps a developer would take to get a "hello world" u…
#!/bin/bash
# Definitely make sure you create a directory to run this in.
# Set this to match the mongodb link for your architecture
# http://www.mongodb.org/downloads
# arch="linux-i686"
# arch="osx-x86_64"
arch="linux-x86_64"
@rktoomey
rktoomey / console.scala
Created July 30, 2012 12:48
Updating with SalatDAO
scala> import model._
import model._
scala> import org.bson.types.ObjectId
import org.bson.types.ObjectId
scala> import com.mongodb.casbah.Imports._
import com.mongodb.casbah.Imports._
scala> val _id = new ObjectId
@varavut
varavut / a.sh
Created April 15, 2012 14:01
testmongo
sudo apt-get update
sudo apt-get install openjdk-6-jre-headless -f
sudo apt-get install curl
sudo apt-get install unzip
sudo apt-get install openssh-server
sudo curl -OL http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.8.zip
sudo unzip elasticsearch-* && rm elasticsearch-*.zip
cd elasticsearch-0.19.8
sudo mkdir /usr/local/elasticsearch
@leon
leon / play.conf
Created March 26, 2012 12:27
Upstart script for Play Framework 2.0
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/play.conf
#
# This could be the foundation for pushing play apps to the server using something like git-deploy
# By calling service play stop in the restart command and play-start in the restart command.
#
# Usage:
# start play
# stop play
# restart play
@THemming
THemming / gist:2173037
Created March 23, 2012 17:31
init.d script to launch Play framework under CentOS/RedHat
#!/bin/bash
# chkconfig: 345 20 80
# description: Play start/shutdown script
# processname: play
#
# Instalation:
# copy file to /etc/init.d
# chmod +x /etc/init.d/play
# chkconfig --add /etc/init.d/play
# chkconfig play on
@Rob-ot
Rob-ot / Draggable.js
Created December 16, 2011 23:46
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
package util
import play.cache.CacheImpl
import models.salatContext._
import scala.collection.JavaConversions.asJavaMap
import com.mongodb.casbah.Imports._
import com.mongodb.WriteResult
import java.io._
import play.jobs.{Every, Job}
import controllers.ErrorReporter