Skip to content

Instantly share code, notes, and snippets.

@libook
libook / 0_0read-line-and-insert.js
Last active April 28, 2017 09:14
Read file by line and batch insert documents into MongoDB.
'use strict';
const mongoUrl = 'mongodb://my-db-address:27017';// MongoDB connection URL.
const filePath = 'id.list';// This must be Unix/Linux ID list file.
const limit = 100;// Buffer this number of documents. Then do insert.
const dbName = 'myDB';// DB name.
const collectionName = 'myCollection';// Collection name.
const MongoDB = require('mongodb');
const MongoClient = MongoDB.MongoClient, assert = require('assert');
from pymongo import MongoClient
from bson.objectid import ObjectId
from datetime import datetime
db_path = "path/to/db:27017"
conn = MongoClient(db_path)
conquer_track = conn["conquerTrack"]
## 所有表每日全量更新
## DB name: conquerTrack
@shaunwallace
shaunwallace / gist:0c4f0ffd89325612f8ed
Last active April 15, 2016 13:50
Object.create()
/*
Object.create();
creates a new object with the specified prototype object and properties
object.create(proto[, propertiesObject]);
*/
var obj = Object.create({}); // creates an empty object and is equivalent to obj = {} or obj = Object.create(Object.prototype)
var obj1 = {
foo : 1,
@listochkin
listochkin / node-command-line-options.txt
Created April 17, 2014 11:00
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@carlosromero
carlosromero / gist:1283907
Created October 13, 2011 10:16
kill process
ps -A|awk '/searchd/ {print $1}'|xargs kill
#or use: killall process name