小编Ajo*_*uve的帖子

循环摩卡测试

我试图在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)

mocha.js node.js

6
推荐指数
1
解决办法
1927
查看次数

全局变量表达node.js

我试图获取变量,我可以在我的代码中到处找到解决方案,但这不是很干净

//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会有更好的解决方案 …

variables node.js

5
推荐指数
1
解决办法
8990
查看次数

更改区域设置i18n Node.js

我找不到如何在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

谢谢

translation node.js express

5
推荐指数
1
解决办法
1882
查看次数

最佳实践phonegap架构

我正在尝试使用phonegap应用程序,但我不知道如何构建体系结构.

我尝试了一种带有大js的MVC模型用于控制器,带有ajax请求的js文件从服务器(模型)获取信息.

对于视图,我使用带有标题和头部的主要布局.

我使用JQuery中的load更新我的内容.

我使用这个系统有一些问题,例如前一个按钮关闭应用程序,因为我总是使用相同的页面.当我旋转屏幕时,我回到第一个屏幕,因为页面正在刷新.

我想知道你是否有一些解决方案或一些代码样本以良好的基础开始

谢谢

architecture model-view-controller android jquery-mobile cordova

5
推荐指数
1
解决办法
5073
查看次数

改变语言环境symfony 2.3

我刚开始使用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']检测用户区域设置,也许在每个页面实现时使用一个列表器?

然后我将创建一个路由来更改区域设置

但我想找到一种方法来改变语言环境.

谢谢你的帮助

php locale symfony

5
推荐指数
1
解决办法
2万
查看次数

事件FOSUserBundle Symfony2注册和登录

我正在尝试在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)

php events symfony fosuserbundle

5
推荐指数
1
解决办法
8089
查看次数

在环境变量中找不到Symfony参数

我使用的是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

php symfony

5
推荐指数
1
解决办法
3258
查看次数

迁移 createCipher 和 createCipheriv

我刚刚移至节点 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)

node.js cryptojs

5
推荐指数
1
解决办法
1912
查看次数

.npmrc 忽略私有包

我正在尝试在 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)

node.js npm

5
推荐指数
1
解决办法
289
查看次数

使用表格html创建一个没有空格的网格

我正在尝试在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/

我看到这篇文章但没有任何作用 如何删除表中行和列之间不需要的空格?

html css html-table

4
推荐指数
1
解决办法
825
查看次数