Skip to content

Instantly share code, notes, and snippets.

@switzer
switzer / gist:4208541
Created December 4, 2012 20:53
Stack trace running akka-patterns in the sbt folder
[ERROR] [12/04/2012 15:49:02.611] [specs2.DefaultExecutionStrategy1] [akka://default/user/$$a] None.get
java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:313)
at scala.None$.get(Option.scala:311)
at org.cakesolutions.akkapatterns.domain.Configured$class.configured(configuration.scala:26)
at org.cakesolutions.akkapatterns.core.application.CustomerActor.configured(customer.scala:53)
at org.cakesolutions.akkapatterns.core.application.MongoCollections$class.customers(application.scala:45)
at org.cakesolutions.akkapatterns.core.application.CustomerActor.customers(customer.scala:53)
at org.cakesolutions.akkapatterns.core.application.CustomerOperations$class.getCustomer(customer.scala:37)
at org.cakesolutions.akkapatterns.core.application.CustomerActor.getCustomer(customer.scala:53)
@switzer
switzer / gist:4218389
Created December 5, 2012 18:51
Casbah overflow error
[ERROR] [12/05/2012 13:29:11.490] [default-akka.actor.default-dispatcher-3] [LocalActorRefProvider(akka://default)] guardian failed, shutting down system
java.lang.StackOverflowError
at scala.collection.convert.Wrappers$IteratorWrapper.<init>(Wrappers.scala:28)
at scala.collection.convert.Wrappers$IterableWrapperTrait$class.iterator(Wrappers.scala:24)
at scala.collection.convert.Wrappers$SeqWrapper.iterator(Wrappers.scala:64)
at scala.collection.convert.Wrappers$SeqWrapper.iterator(Wrappers.scala:64)
at org.bson.BasicBSONEncoder.putIterable(BasicBSONEncoder.java:294)
at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:234)
at org.bson.BasicBSONEncoder.putIterable(BasicBSONEncoder.java:295)
at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:234)
@switzer
switzer / gist:4218450
Created December 5, 2012 18:57
Customer Serializer
implicit object CustomerSerializer extends CasbahSerializer[Customer] {
def apply(customer: Customer) = {
val builder = MongoDBObject.newBuilder
System.out.println("CustomerSerializer:::" + customer)
builder += "firstName" -> customer.firstName
builder += "lastName" -> customer.lastName
builder += "email" -> customer.email
builder += "addresses" -> customer.addresses.map(AddressSerializer(_))
builder += "id" -> customer.id
@switzer
switzer / gist:4218526
Created December 5, 2012 19:03
Custom Mongodb Serializer/Deserializer
package com.example.core.application
import com.mongodb.casbah.Imports._
import java.util.UUID
import com.example.domain.{User, Address, Customer}
/**
* Contains type classes that deserialize records from Casbah into "our" types.
*/
trait CasbahDeserializers {
var Post = function(db) {
this.db = db;
};
Post.prototype.get = function(req, res) {
var id = req.params.id;
var org = req.params.org;
var db = this.db;
console.log('Retrieving post: ' + id + ' from org: ' + org);
orgSchema.path('timezone').validate(function(value) {
Timezone.findOne({_id: value}, "_id", function (err, timezone) { return false; });
}, "Please provide a valid timezone");
@switzer
switzer / Login and Get curl requests
Created January 22, 2013 03:38
Cannot get second Passport authentication (when not calling /login) to work.
$ curl -i --data "[email protected]&password=password" http://localhost:3000/login
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 260
Set-Cookie: connect.sid=s%3A9b4c4dMSkSiSEex%2BOgtsXBsu.BUoXyrHk95nvhAfDY3mkOIuk0I8npOhdAzMCc4WHnsA; Path=/; HttpOnly
Date: Tue, 22 Jan 2013 03:32:13 GMT
Connection: keep-alive
{
@switzer
switzer / gist:5612958
Created May 20, 2013 15:28
luuid fail on mac
$ brew list
autoconf automake libtool mongodb node readline
$ brew install luarocks
==> Installing luarocks dependency: lua
==> Downloading http://www.lua.org/ftp/lua-5.1.5.tar.gz
Already downloaded: /Library/Caches/Homebrew/lua-5.1.5.tar.gz
==> Patching
patching file Makefile
init_config:
instances:
- host: localhost
sock: /tmp/redis.sock
password:
tags:
- optional_tag1
- optional_tag2
@switzer
switzer / gist:8792691
Last active August 29, 2015 13:56
Inherited switzer/redis Dockerfile
FROM switzer/redis
MAINTAINER Scott Switzer <[email protected]>
RUN cp /usr/src/redis-$REDIS_VERSION/redis.conf /etc
RUN sed -i "s/port 6379/port 0/" /etc/redis.conf;\
sed -i "s/# unixsocket \/tmp\/redis.sock/unixsocket \/tmp\/redis.sock/" /etc/redis.conf;\
sed -i "s/# unixsocketperm 755/unixsocketperm 777/" /etc/redis.conf;\
sed -i "s/# slaveof <masterip> <masterport>/slaveof admin-cache.internal.sunblock.io 6379/" /etc/redis.conf