Skip to content

Instantly share code, notes, and snippets.

View libook's full-sized avatar
🎵
Never Gonna Give You Up~

Daniel Li libook

🎵
Never Gonna Give You Up~
View GitHub Profile
@libook
libook / aliyun-workorder-crawler.js
Last active July 19, 2017 05:30
爬自己阿里云账号中的所有工单记录,再进行分析。
function getQuestionListUrl(index) {
return 'https://workorder.console.aliyun.com/json/page/query_index.json?__preventCache=' + (new Date()).getTime() + '&currentPage=' + index + '&page=' + index + '&pageSize=100&status=';
}
function getQuestions() {
let questions = [];
for (let p = 1; p <= 4; p++) {
let url = getQuestionListUrl(p);
$.ajax({
url,
@libook
libook / 0
Last active December 10, 2020 10:41
@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');
@libook
libook / complement.js
Last active August 29, 2015 14:17 — forked from r3b/complement.js
// returns things in array 'a' that are not in array 'b'
// > ['a','b','c','1', '2', '3'].complement(['b', 'c', 'd', 'e']);
// ['a', '1', '2', '3']
function complement(a, b){
(b)||(b=a, a=this);
return (Array.isArray(a) && Array.isArray(b))
? a.filter(function(x){return b.indexOf(x)===-1;})
: undefined;
}
Array.prototype.complement=complement;
/**
* A helper module for AngularUI Router, which allows you to define your states as an object tree.
* @author Mark Lagendijk <[email protected]>
* @license MIT
*/
+function(){
angular.module('ui.router.stateHelper', [ 'ui.router' ])
.provider('stateHelper',['$stateProvider', function($stateProvider){
var self = this;