我正在制作一个脚本,使用nodejs上的以下脚本从谷歌电子表格中读取数据:
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
approval_prompt: 'force',
scope: [
'https://www.googleapis.com/auth/analytics.readonly',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/spreadsheets'
]
});
global.googleapis = { expiry_date: 0 };
google.options({ auth: oauth2Client });
var sheets = google.sheets('v4');
sheets.spreadsheets.get({ spreadsheetId: 'id'}, function(err, data) {
res.send(err, data);
});
Run Code Online (Sandbox Code Playgroud)
但是在每次获取请求时我都会收到此错误:
Request had insufficient authentication scopes.
Run Code Online (Sandbox Code Playgroud)
我检查了Google开发者控制台以启用Google Drive API并启用了它,所以我真的不知道它会是什么.
我有一系列哈希,类似于
[ {:type=>"Meat", :name=>"one"},
{:type=>"Meat", :name=>"two"},
{:type=>"Fruit", :name=>"four"} ]
Run Code Online (Sandbox Code Playgroud)
我想把它转换成这个
{ "Meat" => ["one", "two"], "Fruit" => ["Four"]}
Run Code Online (Sandbox Code Playgroud)
我尝试了group_by但是我得到了这个
{ "Meat" => [{:type=>"Meat", :name=>"one"}, {:type=>"Meat", :name=>"two"}],
"Fruit" => [{:type=>"Fruit", :name=>"four"}] }
Run Code Online (Sandbox Code Playgroud)
然后我不能修改它只留下名称而不是完整的哈希.我需要在一行中执行此操作,因为它适用grouped_options_for_select于Rails表单.
我只是实施Omniauth + Devise使用Google Apps登录,但在执行请求和"请求阶段已启动"时,我的应用程序被阻止,我在另一个窗口尝试了一个请求并且它没有执行,直到"请求阶段"结束,几个后来的.即时通讯使用omniauth-openid,omniauth-google-apps和Devise gems.
我在nodejs上有一个函数,可以从许多图像中生成图像,然后从中生成pdf文件。我只尝试一张图片,但我需要添加更多图片,但这似乎不起作用
function HelperHandler() {
this.pdf = function(req, res, next) {
var doc = new PDFDocument;
mergeImages(function(err, image) {
if (err)
return res.json(err);
doc.image(image, 100, 100);
doc.output(function(string) {
res.contentType = "application/pdf";
res.send(string);
});
})
}
}
var mergeImages = function(callback) {
var Canvas = require("canvas")
, fs = require("fs");
fs.readFile(global.root_path + "/images/bg.jpg", function(err, data) {
if (err)
callback("error loading image");
else {
var canvas = new Canvas(408, 939)
, img = new Canvas.Image(data);
ctx = canvas.getContext("2d");
img.onload = function() {
ctx.drawImage(img, …Run Code Online (Sandbox Code Playgroud) 我有一组值,我需要从中创建一个甘特图,值是这样的
1 0,000000 4,219309 4,219309 8,988674 8,988674 10,848450
2 4,219309 7,414822 7,414822 12,430150 12,430150 14,198310
3 8,000000 10,478795 10,478795 15,417747 15,417747 17,297929
1 11,000000 14,257995 14,257995 19,009302 19,009302 20,873072
2 14,257995 17,410029 17,410029 22,304447 22,304447 24,123009
3 18,000000 20,494690 20,494690 25,678852 25,678852 27,521070
1 21,000000 24,197839 24,197839 29,070650 29,070650 30,889371
2 24,197839 27,269837 27,269837 32,357236 32,357236 34,232483
4 27,269837 30,432503 30,432503 35,207464 35,207464 37,120424
1 31,000000 34,215182 34,215182 39,079631 39,079631 40,928846
3 34,215182 37,219774 37,219774 41,988526 41,988526 43,868911
2 37,219774 …Run Code Online (Sandbox Code Playgroud) 我试图点击显示一些信息的地图.我正在使用谷歌API
Gmaps4Rails.callback = function() {
google.maps.event.addListener(map, "click", function() {
alert("You clicked the map.");
});
};
Run Code Online (Sandbox Code Playgroud)
但这不起作用,它什么都没有
node.js ×2
ruby ×2
cairo ×1
canvas ×1
devise ×1
enumerable ×1
gmaps4rails ×1
google-api ×1
google-maps ×1
hash ×1
matplotlib ×1
node-canvas ×1
node-pdfkit ×1
numpy ×1
omniauth ×1
python ×1