let writer = new ExcelWriter({
sheets: [{
name: 'Test Sheet',
key: 'tests',
headers: [{
name: 'Test Name',
key: 'name'
}, {
name: 'Test Coverage',
key: 'testValue',
default: 0
}]
}]
});
let dataPromises = inputs.map((input) => {
// 'tests' is the key of the sheet. That is used
// to add data to only the Test Sheet
writer.addData('tests', input);
});
Promise.all(dataPromises)
.then(() => {
return writer.save();
})
.then((stream) => {
stream.pipe(fs.createWriteStream('data.xlsx'));
});
var Database = require('warehouse');
var db = new Database();
var Post = db.model('posts', {
title: String,
created: {type: Date, default: Date.now}
});
Post.insert({
title: 'Hello world'
}).then(function(post){
console.log(post);
});
如果你需要将这些数据保存为一个单独的文件,只需要修改初始化的参数,并执行 save 方法,就可以将 JSON 导出到指定的文件中
var db = new Database({
path: "./test.json", // 将数据存储在 test.json 当中
});
db.save();
类似的,如果数据已经构建好了,也只需要执行 load 方法,就可以加载数据。
var db = new Database({
path: "./test.json", // 将数据存储在 test.json 当中
});
db.load();
function rgbToHsl(r, g, b) {
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b),
min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if (max == min) {
h = s = 0; // achromatic
} else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return [h, s, l];
}
# Use Instant View version 2.0
~version: "2.0"
# Use this template only blog article pages
?exists: /html/head/meta[@property="article:published_time"]
# Get article text in <article>
body: //article
# Get title from <h1>
title: $body//h1[1]
subtitle: $title/next-sibling::h2
author_url: //span[has-class("author")]//@href
# Get article cover image
cover: //img[has-class("wp-post-image")]
# Convert all iframe elements to inline element
@inline: $body//iframe[starts-with(@src, "/media/")]
# Remote header and footer
@remove: //article/header
@remove: //article/footer
# Replace p to figure
@replace_tag(<figure>): $body//p[.//img]
# Youtube Embedded Fix
@replace_tag(<figure>): $body//p[.//iframe]
粘贴并保存后,会自动在最右侧页面生成预览的效果。
当你的规则适配效果无误后,接下来只需要点击右上叫的 Mark as Checked ,来标记该页面已经检查完车。
#!/bin/sh
#
# 00-header - create the header of the MOTD
# Copyright (C) 2009-2010 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
[ -r /etc/lsb-release ] && . /etc/lsb-release
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# Fall back to using the very slow lsb_release utility
DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi
printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
其中有价值的代码主要就是最后几行的输出。
类似的, 10-help-text 的代码则输出了文字。
#!/bin/sh
#
# 10-help-text - print the help text associated with the distro
# Copyright (C) 2009-2010 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>,
# Brian Murray <brian@canonical.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
printf "\n"
printf " * Documentation: https://help.ubuntu.com\n"
printf " * Management: https://landscape.canonical.com\n"
printf " * Support: https://ubuntu.com/advantage\n"