Things I am currently tinkering

  1. Can I Improve my efficiency & academic performance? By academic I mean: paper output and scientific thinking.
  2. How can I be less reactive (mentally)? Would meditation work? How can I train meditation consistently? Spiritual books: Rumi / Eckhart Tolle / Tara Brach / Seneca: What do these books teach? And what are the takeout from each off these books?
  3. What are the most effective and efficient way to improve my bench press (loading more weight), without high risk of injury?
  4. How can I be more efficient on time usage?
  5. How can I have better sleep?

These are not necessarily prioritized in order.

Iklan

Fear

This is the touchstone of such a spirit; no prize fighter can go with high spirits into the strife if he has never been beaten black and blue; the only contestant who can confidently enter the lists is the man who has seen his own blood, who has felt his teeth rattle beneath his opponent’s fist, who has been tripped and felt the full force of his adversary’s charge, who has been downed in body but not in spirit, one who, as often as he falls, rises again with greater defiance than ever.”

Seneca – Moral Letters to Lucilius, Letter 13.

Java Driver & MongoDB Aggregation Example

The following snippet is an example of how to query document in Mongo database, using Group By, Count, Limit, Sort, and Match.

This will count top 20 referrers descendingly-sorted, excluding any document with empty value (“”) in _id field.

If you’re not familiar with Aggregation concept, the following article about Aggregation Pipeline might helps.

// get from "Accounts" collection
DBCollection accountsColl = db.getCollection("Accounts");

// create new BasicDBObject that will be used to
// count based on $referrer field
DBObject groupFields = new BasicDBObject( "_id", "$referrer");
// return result as "count" field that based on the sum
// of similar value in $referrer field. Everytime a similar value
// is found, the count is given a $sum operation by 1.
groupFields.put("count", new BasicDBObject( "$sum", 1));
DBObject group = new BasicDBObject("$group", groupFields );

// create new BasicDBObject  that will ne used to filters out
// an empty string in $referrer field
DBObject matchFields = new BasicDBObject();
matchFields.put("_id", new BasicDBObject("$ne",""));
DBObject match = new BasicDBObject("$match", matchFields);

// create new BasicDBObject that limit query result in only 20 rows
DBObject limit = new BasicDBObject("$limit", 20);

// create new BasicDBObject that sort the result
// based on count, descendingly
DBObject sortFields = new BasicDBObject("count", -1);
DBObject sort = new BasicDBObject("$sort", sortFields );

// aggregate all conditions above
AggregationOutput output = accountsColl.aggregate(group, match,
sort, limit);
return output.getCommandResult().toString();