我试图在mocha中使用数据提供程序来编写更少的代码
var should = require('should');
var assert = require('assert');
var request = require('supertest');
var mongoose = require('mongoose');
var winston = require('winston');
var config = require('../app/config');
describe('Authentification', function() {
var url = config.web.protocol + '://' + config.web.host + ':' + config.web.port;
describe('signin',function()
{
var provider = [
{
describe: 'should return error trying to signin with empty body',
body: {},
status: 404,
message: "firstName not found"
},
{
describe: 'should return error trying to signin with no first name',
body: { …Run Code Online (Sandbox Code Playgroud) 我试图获取变量,我可以在我的代码中到处找到解决方案,但这不是很干净
//environment.js
module.exports.appName = "appName";
Run Code Online (Sandbox Code Playgroud)
和我的app.js.
var express = require('express')
, routes = require('./routes/main')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
var app = express();
environment = require('./environment');
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.home);
app.get('/users', user.list);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
Run Code Online (Sandbox Code Playgroud)
通过这种方式我的var工作,我可以到处访问environment.appName,但Y会有更好的解决方案 …
我找不到如何在i18n中更改语言环境
https://github.com/mashpie/i18n-node
我这样配置
i18n.configure({
// setup some locales - other locales default to en silently
locales:['en', 'de'],
// where to register __() and __n() to, might be "global" if you know what you are doing
register: global
});
Run Code Online (Sandbox Code Playgroud)
但我总是把en作为语言环境,我找不到如何设置de
谢谢
我正在尝试使用phonegap应用程序,但我不知道如何构建体系结构.
我尝试了一种带有大js的MVC模型用于控制器,带有ajax请求的js文件从服务器(模型)获取信息.
对于视图,我使用带有标题和头部的主要布局.
我使用JQuery中的load更新我的内容.
我使用这个系统有一些问题,例如前一个按钮关闭应用程序,因为我总是使用相同的页面.当我旋转屏幕时,我回到第一个屏幕,因为页面正在刷新.
我想知道你是否有一些解决方案或一些代码样本以良好的基础开始
谢谢
architecture model-view-controller android jquery-mobile cordova
我刚开始使用symfony我正在尝试构建一个multilang网站,但是我有一个问题需要更改语言环境
我阅读了一些帖子,我阅读了有关此内容的文档但是语言环境没有改变,我尝试:
public function indexAction()
{
$this->get('session')->set('_locale', 'fr');
$request = $this->getRequest();
$locale = $request->getLocale();
return $this->render('PhoneMainBundle:Default:index.html.twig',array('locale'=>$locale));
}
Run Code Online (Sandbox Code Playgroud)
但是$ locale中的值总是'en'(我的默认语言环境)
我也试试
public function indexAction()
{
$this->get('session')->set('_locale', 'fr');
$request = $this->getRequest();
$request->setLocale('fr');
$locale = $request->getLocale();
return $this->render('PhoneMainBundle:Default:index.html.twig',array('locale'=>$locale));
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,$ locale是fr,但翻译始终来自messages.en.yml
我想第一次使用$ _SERVER ['HTTP_ACCEPT_LANGUAGE']检测用户区域设置,也许在每个页面实现时使用一个列表器?
然后我将创建一个路由来更改区域设置
但我想找到一种方法来改变语言环境.
谢谢你的帮助
我正在尝试在FOSUserBundle上实现事件
<?php
namespace EasyApp\UserBundle\Service;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine;
use EasyApp\UserBundle\Entity\UserLogin;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\FOSUserBundle;
class LoginManager implements EventSubscriberInterface
{
/** @var \Symfony\Component\Security\Core\SecurityContext */
private $securityContext;
/** @var \Doctrine\ORM\EntityManager */
private $em;
/**
* Constructor
*
* @param SecurityContext $securityContext
* @param Doctrine $doctrine
*/
public function __construct(SecurityContext $securityContext, Doctrine $doctrine)
{
$this->securityContext = $securityContext;
$this->em = $doctrine->getEntityManager();
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::SECURITY_IMPLICIT_LOGIN => 'onSecurityImplicitLogin',
FOSUserEvents::REGISTRATION_COMPLETED=> 'onRegistrationCompleted' …Run Code Online (Sandbox Code Playgroud) 我使用的是Symfony 2.8.12,这是我的parameters.yml文件:
parameters:
database_host: localhost
database_port: 3306
database_name: test
database_user: root
secret: TODO
Run Code Online (Sandbox Code Playgroud)
我的环境变量SYMFONY__DATABASE_PASSWORD等于root
如果运行,app/console debug:container --parameter="database_password"我有
------------------- -------
Parameter Value
------------------- -------
database_password root
------------------- -------
Run Code Online (Sandbox Code Playgroud)
但是当我转到localhost / app_dev.php时
ParameterNotFoundException in ParameterBag.php line 84:
You have requested a non-existent parameter "database_password". Did you mean this: "database_port"?
Run Code Online (Sandbox Code Playgroud)
清除缓存后也是一样
Doc:http : //symfony.com/doc/current/configuration/external_parameters.html
我刚刚移至节点 12.13,并且遇到一些crypto.createDecipher问题crypto.createCipher
首先,当我使用这两个函数时,我收到了弃用警告。
const encodeString = (value, password) =>
new Promise((resolve, reject) => {
const cipher = crypto.createCipher("aes192", password);
let encrypted = "";
cipher.on("readable", () => {
const data = cipher.read();
if (data) encrypted += data.toString("hex");
});
cipher.on("end", () => resolve(encrypted));
cipher.write(value);
cipher.end();
});
const decodeString = (encrypted, password) =>
new Promise((resolve, reject) => {
const decipher = crypto.createDecipher("aes192", password);
let decrypted = "";
decipher.on("readable", () => {
const data = decipher.read();
if (data) decrypted += data.toString("utf8"); …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 gitlab 私有实例上使用我的第一个私有 npm 包
我添加@ajouve:registry=https://gitlab.my-website.io/api/v4/packages/npm/到.npmrc
该命令npm get似乎返回了正确的配置
; "project" config from /Volumes/Work/service/.npmrc
@ajouve:registry = "https://gitlab.my-website.io/api/v4/packages/npm/"
; "cli" config from command line options
omit = []
user-agent = "npm/7.5.4 node/v12.18.1 darwin x64"
; node bin location = /usr/local/bin/node
; cwd = /Volumes/Work/service
; HOME = /Users/ajouve
; Run `npm config ls -l` to show all defaults.
Run Code Online (Sandbox Code Playgroud)
但是当我想添加包时
npm install --save @ajouve/my-module
我有
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@ajouve/my-module Not …Run Code Online (Sandbox Code Playgroud) 我正在尝试在html中构建一个网格,但我想删除我的单元格之间的空格,我找不到.
<table id="gameGrid" cellspacing="0" >
<tr class="gridRow" >
<td class="box" ></td>
<td class="box" ></td>
<td class="box" ></td>
</tr>
<tr class="gridRow" >
<td class="box" ></td>
<td class="box" ></td>
<td class="box" ></td>
</tr>
<tr class="gridRow" >
<td class="box" ></td>
<td class="box" ></td>
<td class="box" ></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
和CSS:
#gameGrid{
border:1px solid black;
border-collapse: collapse;
padding:0;
margin:0;
border-spacing: 0;
}
#gameGrid .gridRow{
margin:0;
padding:0;
}
#gameGrid .gridRow .box{
margin:0;
padding:0;
background-color:green;
height:16px;
width:16px;
display:inline-block;
}
Run Code Online (Sandbox Code Playgroud)
一个例子:http://jsfiddle.net/sLG2D/1/
我看到这篇文章但没有任何作用 如何删除表中行和列之间不需要的空格?