Rollerball pen turns doodles into working circuits

Circuit Scribe is a rollerball pen that writes with conductive silver ink. It makes creating circuits as easy as doodling. While the possibilities of the rollerball pen is countless, this will be a great addition to a science teacher’s toolkit.

Rollerball pen turns doodles into working circuits | The Verge.

The .mongorc.js File

The .mongorc.js File

While working in MongoDB shell, if you are frequently wondering about which database you are working on, you can obviously find out typing ‘db’ at the command prompt. But if you are lazy like me, you can change your command prompt to reflect the database name by modifying the prompt function as follows:

[box]

prompt=function () {
 return db+'> ';
 }

[/box]

You can enhance this further to have the prompt display the current timestamp along with the database name to time your queries as follows:

[box]

prompt=function () {
 return db+':'+(new Date())+'> ';
 }

[/box]

If you get used to this and do not want to reprogram the prompt function every time you start your MongoDB shell, you can add a .mongorc.js file in your home directory and add the modified prompt function.

Now, every time you start your MongoDB shell, your prompt will show the database name and the current system time.

MongoDB Supported Data Types

November 23, 2013
MongoDB Supported Data Types

MongoDB adds support for a number of additional data types while keeping JSON’s essential key/value pair nature. Exactly how values of each type are represented varies by language, but this is a list of the commonly supported types and how they are represented as part of a document in the shell. The most common types are:

null

Null can be used to represent both a null value and a nonexistent field:

{“x” : null}

boolean

There is a boolean type, which can be used for the values true and false:

{“x” : true}

number

The shell defaults to using 64-bit floating point numbers. Thus, these numbers look “normal” in the shell:

{“x” : 3.14}

or:

{“x” : 3}

integers

For integers, use the NumberInt or NumberLong classes, which represent 4-byte or 8-byte signed integers, respectively.

{“x” : NumberInt(“3”)}

{“x” : NumberLong(“3”)}

string

Any string of UTF-8 characters can be represented using the string type:

{“x” : “foobar”}

date

Dates are stored as milliseconds since the epoch. The time zone is not stored:

{“x” : new Date()}

regular expression

Queries can use regular expressions using JavaScript’s regular expression syntax:”

“{“x” : /foobar/i}

array

Sets or lists of values can be represented as arrays:

{“x” : [“a”, “b”, “c”]}

embedded document

Documents can contain entire documents embedded as values in a parent document:

{“x” : {“foo” : “bar”}}

object id

An object id is a 12-byte ID for documents. See the section _id and ObjectIds for details:

{“x” : ObjectId()}

There are also a few less common types that you may need, including:

binary data

Binary data is a string of arbitrary bytes. It cannot be manipulated from the shell. Binary data is the only way to save non-UTF-8 strings to the database.

code

Queries and documents can also contain arbitrary JavaScript code:

{“x” : function() { /* … */ }}

Excerpt From

Kristina Chodorow. “MongoDB_ The Definitive Guide, 2nd Edition.epub.” iBooks.

Get Administrative Information regarding your MongoDB Server

November 23, 2013

By default MongoDB listens for socket connections on port 27017. The server will fail to start if the port is not available—the most common cause of this is another instance of MongoDB that is already running.
mongod also sets up a very basic HTTP server that listens on a port 1,000 higher than the main port, in this case 28017. This means that you can get some administrative information about your database by opening a web browser and going to http://localhost:28017.

Excerpt From

Kristina Chodorow. “MongoDB_ The Definitive Guide, 2nd Edition.epub.” iBooks.

MongoDB Subcollections

November 23, 2013

Subcollections
One convention for organizing collections is to use namespaced subcollections separated by the . character. For example, an application containing a blog might have a collection named blog.posts and a separate collection named blog.authors. This is for organizational purposes only—there is no relationship between the blog collection (it doesn’t even have to exist) and its “children.”
Although subcollections do not have any special properties, they are useful and incorporated into many MongoDB tools:
GridFS, a protocol for storing large files, uses subcollections to store file metadata separately from content chunks (see Chapter 6 for more information about GridFS).
Most drivers provide some syntactic sugar for accessing a subcollection of a given collection. For example, in the database shell, db.blog will give you the blog collection, and db.blog.posts will give you the blog.posts collection.
Subcollections are a great way to organize data in MongoDB, and their use is highly recommended.

Excerpt From

Kristina Chodorow. “MongoDB_ The Definitive Guide, 2nd Edition.epub.” iBooks.