Friday, January 2, 2015

Amazon -- Deliver docs to PC or MAC

I still do not understand why the option of sending personal docs to PC (or Mac) kindle is disabled, there a couple of workarounds:

Option 1)
PC, right click on the document and open it with Kindle.
Mac, open with Kindle.

Option 2)
Find "My Kindle Content" folder and drop your document there.
Linux command [find / -name 'My Kindle Content']

...

Thursday, December 4, 2014

pymongo.errors.AutoReconnect: not master

Cause:

Our mongo DB hasn't replica set config.

Verify replica set:

Log into mongo shell and do "rs.conf()", if it comes with "null" then do the following:

cfg = {"_id" : "rpls","version" : 1,"members" : [{"_id" : 0,"host" : "127.0.0.1:27017"}]}
This will set your instance as master, as described here:

http://stackoverflow.com/questions/13603096/starting-over-with-replica-configuration-in-mongodb


Wednesday, December 3, 2014

Intellij Import project NoClassDefFoundError: jline/TerminalFactory

sbt --version
sbt launcher version 0.13.5
Play
play 2.2.1 built with Scala 2.10.2 (running Java 1.7.0_51) 
Error
NoClassDefFoundError: jline/TerminalFactory
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:85)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:79)

I just removed "build.properties" file containing"sbt=0.13.0"

Wednesday, October 9, 2013

operator does not exist: character varying = bytea

Check foreign keys have same type as in main table. In my case main table has character(10) and foreign key character (5).

ERROR: operator does not exist: character varying = bytea
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 276

Sunday, August 11, 2013

java.io.StreamCorruptedException: invalid stream header: 32303133

If it is associated to "Caused by: org.hibernate.type.SerializationException: could not deserialize", then check the type of the classes you are importing.

I mistakenly was importing:

  • import java.security.Timestamp;

Instead of
  • import java.sql.Timestamp;


Tuesday, July 23, 2013

git stuff

Automatically rebase on your new branches when you pull...
  • git config --global branch.autosetuprebase always

To set rebase when pulling on an existing branch
  • git config branch.master.rebase true
To check what would happen on a branch when you pull.
  • git remote show origin
Check out a remote branch
  • git checkout -b <branch name> origin/<branch name>
Push to a remote branch
  • git push origin <branch name>
Cherry-pick
  • git cherry-pick <commit id>

Saturday, July 20, 2013

Scala break out for / while loops...

Ok, first of all I have to give credit to the following post since it help me to come out with a solution.

http://stackoverflow.com/questions/2742719/how-do-i-break-out-of-a-loop-in-scala

Let say that in java you have something like this:

public boolean validateObject(Answer anObject) {...}

And inside of another method you have a loop that you want to break when validateObject method returns "true". In Java it would looks like:

public void aLoopMethod() {
   boolean temp = false;
   List[Answer] list = methodGetAnswers();
   int index = 0;
   while (temp == false || index < list.size() ) {
      temp = validateObject(list.get(index));
      index++;
   }
}

Translated to Scala it would be something like this:

val temp = false
(0 to list.size).toStream.takeWhile(_ => !temp).foreach(i => (temp = validateObject(uuid,list.get(i))))

Seems to be easy, but it took some hours to figure out the solution. I hope it helps you...