Tutorial by Examples: ect

db.posts.find().forEach(function(doc){ db.posts.update({_id: doc._id}, {$set:{'version':'v1.0'}}, false, true); });
db.posts.find().forEach(function(doc){ if(doc.arrayOfObjects){ // the false, true at the end refers to $upsert, and $multi, respectively db.accounts.update({_id: doc._id}, {$unset: {'arrayOfObjects': "" }}, false, true); } });
db.originalName.renameCollection("newName" );
db.posts.find().forEach(function(doc){ if(doc.commenters){ var firstCommenter = db.users.findOne({'_id': doc.commenters[0]._id }); db.clients.update({_id: doc._id}, {$set:{'firstPost': firstCommenter }}, false, true); var firstCommenter = db.users.findOne({'_id': do...
db.posts.find().forEach(function(doc){ if(doc.commentsBlobId){ var commentsBlob = db.comments.findOne({'_id': commentsBlobId }); db.posts.update({_id: doc._id}, {$set:{'comments': commentsBlob }}, false, true); } });
db.posts.find().forEach(function(doc){ db.accounts.update({_id: doc._id}, {$set: {'_id': doc._id.str }}, false, true); });
db.posts.find().forEach(function(doc){ if(doc._id){ db.posts.update({_id: doc._id}, {$set:{ timestamp: new Date(parseInt(doc._id.str.slice(0,8), 16) *1000) }}, false, true); } });
var timestamp = Math.floor(new Date(1974, 6, 25).getTime() / 1000); var hex = ('00000000' + timestamp.toString(16)).substr(-8); // zero padding var objectId = new ObjectId(hex + new ObjectId().str.substring(8));
Feature detection of classes can partly be done with the property_exists and method_exists functions. class MyClass { public $public_field; protected $protected_field; private $private_field; static $static_field; const CONSTANT = 0; public function public_function() {...
Dependency Injection (DI) in the context of using a Dependency Injection Container (DIC) can be seen as a superset of constructor injection. A DIC will typically analyze a class constructor's typehints and resolve its needs, effectively injecting the dependencies needed for the instance execution. ...
If you want to add all the JARs in directory to the classpath, you can do this concisely using classpath wildcard syntax; for example: someFolder/* This tells the JVM to add all JAR and ZIP files in the someFolder directory to the classpath. This syntax can be used in a -cp argument, a CLASSPA...
The content mode property of a view tells how its content should be laid out. In the Interface Builder, the various modes can be selected in the Attributes Inspector. Let's use two image views to see how the various modes work. Scale to Fill The image heights and widths are stretched to mat...
Create a new project It can be just a Single View Application. Add the code Create a new Cocoa Touch Class file (File > New > File... > iOS > Cocoa Touch Class). Name it MyCollectionViewCell. This class will hold the outlets for the views that you add to your cell in the storyboard. ...
The following might have undefined behavior due to incorrect pointer alignment: char *memory_block = calloc(sizeof(uint32_t) + 1, 1); uint32_t *intptr = (uint32_t*)(memory_block + 1); /* possible undefined behavior */ uint32_t mvalue = *intptr; The undefined behavior happens as the pointer...
for /r command can be used to recursively visit all the directories in a directory tree and perform a command. @echo off rem start at the top of the tree to visit and loop though each directory for /r %%a in (.) do ( rem enter the directory pushd %%a echo In directory: cd rem leave...
The following uses a variable with a for loop to rename a group of files. SetLocal EnableDelayedExpansion for %%j in (*.*) do ( set filename=%%~nj set filename=!filename:old=new! set filename=Prefix !filename! set filename=!filename! Suffix ren "%%j" "!filename!%%~x...
$ git show dae86e1950b1277e545cee180551750029cfe735 $ git show dae86e19 You can specify revision (or in truth any object: tag, tree i.e. directory contents, blob i.e. file contents) using SHA-1 object name, either full 40-byte hexadecimal string, or a substring that is unique to the repository. ...
Instead of linking to an external file, you can also include the JS code as-is in your HTML: <script> // JavaScript code </script>
Time series data can be stored as a ts object. ts objects contain information about seasonal frequency that is used by ARIMA functions. It also allows for calling of elements in the series by date using the window command. #Create a dummy dataset of 100 observations x <- rnorm(100) #Convert ...
Add below entries in pom.xml. <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springfr...

Page 36 of 99