Tutorial by Examples

python-bsonjs does not depend on PyMongo and can offer a nice performance improvement over json_util: bsonjs is roughly 10-15x faster than PyMongo’s json_util at decoding BSON to JSON and encoding JSON to BSON. Note that: to use bsonjs effectively, it is recommended to work directly with Ra...
If all you need is serializing mongo results into json, it is possible to use the json module, provided you define custom handlers to deal with non-serializable fields types. One advantage is that you have full power on how you encode specific fields, like the datetime representation. Here is a ha...
Import a Mongoose Model (See topic "Mongoose Schemas") var User = require("../models/user-schema.js") The findOne method will return the first entry in the database that matches the first parameter. The parameter should be an object where the key is the field to look for and th...
new Vue({ el:"#app", data:{ foo: "bar" }, methods:{ doSomethingAsynchronous(){ setTimeout(function(){ // This is wrong! Inside this function, // "this" refers to the window object. this.foo = "baz"; ...
new Vue({ el:"#star-wars-people", data:{ people: null }, mounted: function(){ $.getJSON("http://swapi.co/api/people/", function(data){ // Again, this is wrong! "this", here, refers to the window. this.people = data.results; }) ...
You can capture the correct this using a closure. new Vue({ el:"#star-wars-people", data:{ people: null }, mounted: function(){ // Before executing the web service call, save this to a local variable var self = this; $.getJSON("http://swapi.co/api/peop...
You can bind the callback function. new Vue({ el:"#star-wars-people", data:{ people: null }, mounted:function(){ $.getJSON("http://swapi.co/api/people/", function(data){ this.people = data.results; }.bind(this)); } })
new Vue({ el:"#star-wars-people", data:{ people: null }, mounted: function(){ $.getJSON("http://swapi.co/api/people/", data => this.people = data.results); } }) Caution! Arrow functions are a syntax introduced in Ecmascript 2015. It is not yet supp...
new Vue({ el:"#app", data:{ foo: "bar" }, methods:{ // This is wrong! Arrow functions capture "this" lexically // and "this" will refer to the window. doSomething: () => this.foo = "baz" } })
new Vue({ el:"#app", data:{ foo: "bar" }, methods:{ doSomething: function(){ this.foo = "baz" } } }) Alternatively, if you are using a javascript compiler or a browser that supports Ecmascript 2015 new Vue({ el:"#app&quo...
Using the move command, you can move files: @echo off cd C:\Foo\Bat\Baz move /Y Meow.bat "Meow Folder" >nul Meow.bat stands for which file to move. The "Meow Folder" moves Meow.bat to the Meow Folder. /Y says to not prompt for confirmation. Replacing that with /-Y makes ...
This example shows how you can install and run WSO2 API Manager in your machine. For this example API Manager 2.1.0 version is used. You can install WSO2 API Manager in two ways. Download the API Manager product from product website. Checkout the source code from GitHub, build the source code ...
The functions save and load allow us to specify the environment where the object will be hosted: save(iris, cars, file = "myIrisAndCarsData.Rdata", envir = foo <- new.env()) load("myIrisAndCarsData.Rdata", envir = foo) foo$cars save(iris, cars, file = "myIrisAndCar...
If a file may contain Windows or Unix-like line endings (or even a mixture of both) then the intended text replacement may not work as expected. Sample: $ echo -e 'Entry 1\nEntry 2.1\tEntry 2.2\r\nEntry 3\r\n\r\n' \ > | awk -F'\t' '$1 != "" { print $1 }' \ > | hexdump -c 0000000...
Opening a stream fopen opens a file stream handle, which can be used with various functions for reading, writing, seeking and other functions on top of it. This value is of resource type, and cannot be passed to other threads persisting its functionality. $f = fopen("errors.log", "a...
Copying files copy copies the source file in the first argument to the destination in the second argument. The resolved destination needs to be in a directory that is already created. if (copy('test.txt', 'dest.txt')) { echo 'File has been copied successfully'; } else { echo 'Failed to ...
Steps: Create Empty .Net Core Web App: Go to wwwroot, and create a normal html page called Index.html: Configure Startup.cs to accept static files (this will require to add "Microsoft.AspNetCore.StaticFiles": "1.0.0" library in the “project.json” file): ...
public class Person { private final String salutation; private final String firstName; private final String middleName; private final String lastName; private final String suffix; private final Address address; private final boolean isFemale; private final boolean isEmployed; private final ...
Another example: a Weapon that shoots out Bullets. The Weapon acts as an object pool for the Bullets it creates. public class Weapon : MonoBehaviour { // The Bullet prefab that the Weapon will create public Bullet bulletPrefab; // This List is our object pool, which starts...
List can contain n number of items. The items in list are separated by comma >> a = [1,2,3] To access an element in the list use the index. The index starts from 0 >> a[0] >> 1 Lists can be nested. >> nested_list = [ [1,2,3], ['a','b','c'] ] >> nested_list...

Page 1175 of 1336