Monday, December 30, 2019

English sentences

I've worked hard to make this book as good as I can, but I have no illusions that it's perfect.

But what a man is looking for a woman can be very different from what a woman is looking for in a man.
The saying goes, a woman wants one man to satisfy her every need; a man wants every woman to satisfy his one need.

In American English, the title "Miss" used for single women has become a bit outdated, especially with professional women. "Ms." (pronounced miz) is a safe bet in any situation. It's neutral and doesn't indicate whether the woman is married or not. If the woman prefers "Miss" or "Mrs." (pronounced misiz), she'll probably tell you.
-from Global English
Don't overreact! It's not the end of the world.

Early to bed and early to rise makes a man healthy, wealthy and wise.
I accept all those flaws, why can't you accept me for this?
You ruffled his feathers when you asked him about his income.
She felt put off by his personal questions.
Did you catch the new engineer's name?
I think he needs to use more finesse in certain situations.
Every day I work,I bust my ass so my family can live well.
So I guess what I'm trying to say is that I'm very thankful that all of your Thanksgivings sucked.
You now have a good understanding of... But make sure you don't get complacent.

Have you both got over the jet-lag?
Obviously this is not my call any longer, but it's my 2 cents worth.
marinara


Be confident, be proud of what we’ve achieved together at XXX, but be prepared to change.
The journey is only beginning.

I'll let him know if anything comes up.

English Tips:
1. But the German chancellor Angela Merkel said Berlin needed to be certain that Greece was serious about spending cuts.
2. The precondition however is that Greece will accept an ambitious austerity program so that the trust of the financial  markets can be restored.
3. The British prime minister Golden Brown has said sorry to a woman he had been called on microphone describing as “bigoted” during Campaigning for General election.
4. They highlight a vast gulf between the Prime minister’s behavior and attitude in public and in private. Warm, attentive and concerned on camera, angry dismissive and disdainful when off it.
5. Coroner  concluded that Mrs. McQueen hanged himself after taking a mixture of cocaine tranquilizers and sleeping pills. 
6. The first offshore wind farm in the United States has won government approval after years of opposition from environmentalists and indigenous tribes.


the government ususally covers everyting up, including mental health problems within China.
Yes. You can blame in on corruption, the government or whatever else you would like to.
Most often than not, the widespread corruption goes unnoticed and unpunished.

Triggers for the attacks have included pent-up grivevances over lost jobs, business failures, broken relationships, and a new home that officals had ordered torn down.

China devotes hundred thousand officials to control internet's content. The real question behind this is: why China try to control the internet content so much? what do they want people 
not to know? Is it about China or the foreigner countries?

This was the sixth attack on schoolchildren in China since March -- a succession of attacks that had already prompted calls for more security at schools and worries about social malaise 
that some see underneath China's rapid economic growth.


My thoughts about the school attack
The succession of bloody assaults on schools shocks me heavily. It is belived that triggers for the attacks have included pent-up grivevances over lost jobs, business failures, broken relationships,
and a new home that officals had ordered torn down. The attacks prompted worries about social malaise that some see underneath China's rapid economic growth.



Thursday, December 19, 2019

MongoDB in Action Note 2

MongoDB in Action Note
1.
Indexes in MongoDB are implemented as a B-tree data structure.
With MongoDB, you can create up to 64 indexes per collection. The kinds of
indexes supported include all the ones you’d find in an RDMBS; ascending, descending,
unique, compound-key, hashed, text, and even geospatial indexes4 are supported.
2.
mongoexport and mongoimport—Export and import JSON, CSV, and TSV7 data;
3.
db.users.insert({username: "smith"})
db.users.find()
db.users.find({username: "jones"})
db.users.find().pretty()
db.users.count()
db.users.update({username: "smith"}, {$set: {country: "Canada"}})   --OPERATOR UPDATE
db.users.update({username: "smith"}, {country: "Canada"})           --REPLACEMENT UPDATE
db.foo.remove()
db.users.remove({"favorites.cities": "Cheyenne"})
db.users.drop()
4.
> help
> db.help()
$ mongo --help
5.
> for(i = 0; i < 20000; i++) {
db.numbers.save({num: i});
}
db.numbers.find( {num: {"$gt": 20, "$lt": 25 }} )
db.numbers.find({num: {"$gt": 19995}}).explain("executionStats")
db.numbers.createIndex({num: 1})
db.numbers.getIndexes()
db.numbers.find({num: {"$gt": 19995 }}).explain("executionStats")
> db.stats() (wraps db.runCommand( {dbstats: 1} ) )
you can execute the parentheses-less version and see the internals:
> db.runCommand
6.
In addition to the size limit, MongoDB allows you to specify a maximum number
of documents for a capped collection with the max parameter.
MongoDB also allows you to expire documents from a collection after a certain
amount of time has passed. These are sometimes called time-to-live (TTL) collections.
7.
BSON specifies three numeric types: double, int, and long.
The BSON datetime type is used to store temporal values. Time values are represented
using a signed 64-bit integer marking milliseconds since the Unix epoch.
if you’re creating dates in JavaScript, keep in mind that months in JavaScript dates are 0-based.
8.
db.stockdata.find({code: "SH600050"}).skip(3490).limit(3).sort({'date':1}).pretty()
MongoDB allows you to query using regular expressions
db.users.find({'last_name': /^Ba/})
db.users.find({'first_name': "Smith", birth_year: 1975})
db.reviews.find({
'user_id': ObjectId("4c4b1476238d3b4dd5000001"),
'$where': "(this.rating * .92) > 3"
})
9.
Projections:
db.users.find({}, {'username': 1}) --returns user documents excluding all but two fields: the username and the _id field
db.users.find({}, {'addresses': 0, 'payment_methods': 0})  --returns user documents including all exclude the two fields
To return the first 12 reviews,
or the last 5, you’d use $slice like this:
db.products.find({}, {'reviews': {$slice: 12}})
db.products.find({}, {'reviews': {$slice: -5}})
10.
Aggregation pipeline operations include the following:
$project—Specify fields to be placed in the output document (projected).
$match—Select documents to be processed, similar to find().
$limit—Limit the number of documents to be passed to the next step.
$skip—Skip a specified number of documents.
$unwind—Expand an array, generating one output document for each array entry.
$group—Group documents by a specified key.
$sort—Sort documents.
$out—Write the results of the pipeline to a collection
$redact—Control access to certain data
11.
db.stockdata.aggregate([{$group:{_id:'$code',count:{$sum:1}}}]);
db.stockdata.aggregate([
{$match:{'code':/^SH/}},
{$group:{_id:'$code',count:{$sum:1}}}
]);
db.stockdata.aggregate([
{$match:{'code':/^SH/}},
{$group:{
_id:'$code',
average:{$avg:'$close'},
count:{$sum:1}
}}
]);
db.stockdata.aggregate([
{$match:{'code':/^SH/}},
{$group:{
_id:'$code',
average:{$avg:'$close'},
count:{$sum:1}
}}
]).forEach(function(doc){
var category = db.stockdata.findOne({code:doc._id});
if(category!=null){
doc.code = category.code;
}
else{
doc.code = 'not found';
}
db.mainStockData.insert(doc);
});