Node和npm都已安装并且是最新的,但在尝试安装coffeescript时仍然遇到此错误.我还是编程的新手,所以任何建议都会非常感激.
test-macbook:~ Test$ npm -v
1.1.0-3
test-macbook:~ Test$ node -v
v0.6.8
test-macbook:~ Test$ npm install -g coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
npm ERR! Could not create /usr/local/lib/node_modules/___coffee-script.npm
npm ERR! error installing coffee-script@1.2.0
npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! cwd /Users/Dylan
npm ERR! node -v v0.6.8
npm …Run Code Online (Sandbox Code Playgroud) 我前段时间为我的rails应用程序创建了一个heroku repo但删除它因为我从未使用它.现在我已经到了需要使用heroku但我遇到以下错误:
! No such app as furious-mist-2295. 这是旧的回购名称,所以显然没有推到我创建的新堆栈.
这是我正在考虑的尝试,但我担心会对我的git repo造成不必要的更改.
git remote rm origin
git remote add origin <URL to new heroku app>
git push -u origin master
我使用以下命令在Javascript程序中创建了几个ISO日期:
var isodate = new Date().toISOString()
以格式返回日期"2014-05-15T16:55:56.730Z".我需要从这些日期中减去5个小时.然后将上述日期格式化为"2014-05-15T11:55:56.730Z"
我知道这很hacky但非常感谢快速修复.
我有一个配置有GeoDjango的Django应用程序,该应用程序在CircleCI 2.0构建中失败,并出现以下错误:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library. Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
Run Code Online (Sandbox Code Playgroud)
但是,当我'django.contrib.gis'从构建中删除时DJANGO_APPS,settings.py运行成功。
除了postgres和GDAL码头工人镜像之外,是否还有其他步骤在CircleCI中配置GDAL?我(可能是错误地)假设在安装Docker映像后将找到GDAL。以下是我的config.yml:
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.3
- image: circleci/postgres:10.1-postgis
environment:
- POSTGRES_USER=ubuntu
- POSTGRES_DB=myapp_test
- image: geodata/gdal
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用express-validator在我的Node/Express API中构建参数验证.但是,当我使用以下curl命令发出缺少字段(在本例中为name)的POST请求时curl -X POST -d "foo=bar" http://localhost:3000/collections/test,请求仍然成功完成,跳过验证.以下是我目前的代码 - 为什么验证被绕过的任何想法?
var util = require('util');
var express = require('express');
var mongoskin = require('mongoskin');
var bodyParser = require('body-parser');
var expressValidator = require('express-validator');
var app = express();
app.use(bodyParser());
app.use(expressValidator());
var db = mongoskin.db('mongodb://@localhost:27017/test', {safe:true})
app.param('collectionName', function(req, res, next, collectionName){
req.collection = db.collection(collectionName)
return next()
});
app.post('/collections/:collectionName', function(req, res, next) {
req.checkBody('name', 'name is required').notEmpty();
req.collection.insert(req.body, {}, function(e, results){
if (e) return next(e)
res.send(results)
});
});
app.listen(3000);
Run Code Online (Sandbox Code Playgroud) 在下面的用户模式中有一个foobar.events字段,我试图将新的哈希值(从API POST请求中接收)推送到.
var userSchema = mongoose.Schema({
foobar: {
id : String,
token : String,
email : String,
name : String,
events : [{
action : String,
timestamp : Date,
user_xid : String,
type : {type: String},
event_xid : String
}]
}
});
Run Code Online (Sandbox Code Playgroud)
这是Express路线的逻辑:
app.post('/foobar/post', function(req, res) {
var jb_user_xid = req.body['events'][0]['user_xid'];
var jb_timestamp = req.body['events'][0]['timestamp'];
var jb_action = req.body['events'][0]['action'];
var jb_type = req.body['events'][0]['type'];
var jb_event_xid = req.body['events'][0]['event_xid'];
User.findOne({'foobar.id':jb_user_xid}, function(err, user) {
console.log(user);
user.foobar.events.push({
user_xid: jb_user_xid,
timestamp: jb_timestamp,
action: …Run Code Online (Sandbox Code Playgroud) 在控制器中:
\n\ndef createUserForHotel\n @user=User.new(params_createUserForHotel)\n if @user.save\n flash[:notice]="New user is created for the hotel"\n redirect_to(:controller=>\'hotels\',:action=>"createnewhotel")\n else\n flash[:notice]="New user not created "\n redirect_to(:controller=>\'hotels\',:action=>"createnewhotel")\n end\nend\n\ndef params_createUserForHotel\n params.require(:user).permit(:username,:password,:email,:hotel_id)\nend\nRun Code Online (Sandbox Code Playgroud)\n\n在迁移中:
\n\ndef up\n create_table :users do |t|\n t.string "first_name",:limit=>25\n t.string "last_name",:limit=>50\n t.string "email",:null=>false,:limit=>100\n t.string "username",:limit=>50 \n t.string "password",:limit=>40 \n t.integer "hotel_id"\n t.timestamps\n end\n\n add_index("users","hotel_id")\nend\n\nclass AlterUsers < ActiveRecord::Migration\n def up \n rename_column("users","password","hashed_password") \n end\nRun Code Online (Sandbox Code Playgroud)\n\n在 Heroku 日志中:
\n\n\xe2\x86\x90[0m Started POST "/hotels/createUserForHotel" for 122.50.216.93 at 2014-11-16 10:18:16 +0000\n\xe2\x86\x90[36m2014-11-16T10:18:16.170638+00:00 app[web.1]:\xe2\x86\x90[0m\n\xe2\x86\x90[36m2014-11-16T10:18:16.170641+00:00 app[web.1]:\xe2\x86\x90[0m NoMethodError (undefined method …Run Code Online (Sandbox Code Playgroud) 我有一个python对象,它收集一些请求数据,所以我可以根据我通过GET方法收到的过滤器和分类器创建模型查询.(排序= ID&为了= DESC ...)
class Search( object ):
sorters = []
filters = []
Run Code Online (Sandbox Code Playgroud)
如果请求具有过滤器和分类器,则类属性将填充正确的参数.这很好用,查询构建正常.问题是当我触发第二个请求时,分拣机和过滤器会保留前一个请求中的值,因此Search对象不是新的但是持久的.
知道它为什么会这样吗?顺便说一下,我是python的新手,PHP(我的区域)将只为每个请求实例化一个新对象.
我的目标是根据用户上传到 Amazon S3 的 excel 文件中的数据制作图表。
我已经实现了用户使用 Carrierwave 上传 excel 文件的功能,现在我需要能够访问数据并使其可呈现以与图表库 (Highcharts) 一起使用。
我坚持的任务是通过Rails直接访问S3中的数据。提取数据后,使用 Highcharts 操作它应该相当简单。
我们欢迎所有的建议!
我目前在我的Rails应用程序中使用Pow作为服务器,并且需要将环境从开发改为生产.我已经添加RAILS_ENV = 'production'到我的配置/环境文件并重新启动了服务器; 但是,日志仍然在生成log/development