Use variables on MongoDB query

My basic MongoDB query

test.find({$or : [{"timeIn":"2018-1-31 11:57"},{"timeIn":"2018-1-31 11:58"},{"timeIn":"2018-1-31 11:59"},{"timeIn":"2018-1-31 12:00"},{"timeIn":"2018-1-31 12:01"},{"timeIn":"2018-1-31 12:02"},]})

I want use variables for replace expression and I tried

    test.find({"$or" : [expression]  }, {"email": 1, "_id": 0}).toArray(function (err,data){
      if (err) throw err;

But got a error

MongoError: $or/$and/$nor entries need to be full objects

With variables expression are {"timeIn":"2018-1-31 11:57"},{"timeIn":"2018-1-31 11:58"},{"timeIn":"2018-1-31 11:59"},{"timeIn":"2018-1-31 12:00"},{"timeIn":"2018-1-31 12:01"},{"timeIn":"2018-1-31 12:02"},

How I can use variables on MongoDB query?

AJAX PUT request to Phillips Hue Hub Local

I have created a file with the following:

<form id="myForm" name="myForm">
<button type="submit">Turn Light on</button>
<script> $('#myForm').submit(function(e){
    data: JSON.stringify({"on":true}),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data){alert(data);},
    failure: function(errMsg) {

Currently, no error or success message is displayed and the light does not turn on. I can only put it down to there being an error in my code, or am I misunderstanding Jquery & AJAX and they are not client side, hence why this doesn’t work?

EDIT: Typo on the form ID was the issue.

Opencontrail logutils not found

i have a probleme with opencontrail-webui server is not running i was able to track the error to file config.utils.js when i tried to decrale a variable with the same name. server started but i got a blanc page this is some text from log file
thank you

                logutils.logger.error("Configured/Default MOTD file " +

ReferenceError: logutils is not defined
at ReadFileContext.callback (/var/lib/contrail-webui/contrail-web-core/src/serverroot/common/config.utils.js:117:17)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13)
02/16/2018 05:01:38 PM – ^[[34mdebug^[[39m: The worker #5 has disconnected.
02/16/2018 05:01:38 PM – ^[[31merror^[[39m: The worker #5 has exited with exit code 1


replace second occurrence of comma with line break in string

Trying to figure out what’s the best way to insert a line break after the second comma in a string. Here’s what I’m currently using and it works, but I would like to know if a regex would be better for this.

var data = $('#test1').html();
var position = data.indexOf(",", data.indexOf(",") + 1);

String.prototype.replaceAt = function(index, replacement) {
  return this.substr(0, index) + replacement + this.substr(index + replacement.length);

var newstr = (data.replaceAt(position, "<br />"));

<script src=""></script>
<span id="test1">3131, abc street, ZZ, ZZ  128 376</span>
<br /><br />
<span id="result">###</span>

How to define a route and then create a simple crosslink to that route?

This API is clear enough…

      title="Go to Details"
      onPress={() => this.props.navigation.navigate('Details')}

But how do I register this “Details” route for a component? In the React Navigation docs, it is often suggested to do something like…

export default StackNavigator({
  Home: {
    screen: HomeScreen,

However, the above code does not just register a route, it also affects how the UI is presented. I don’t want these coupled. I don’t want the way in which I register/define routes to have any immediate effect on the GUI.

There must be a way to simply register a route so that when I call navigation.navigate(‘SomeRoute’), the relevant screen will load.

Even the documentation for building a custom router seems to assume that I want to render something, rather than just define routes. But I just want to register a route so I can call navigation.navigate(‘Someroute’).

Cannot find module ‘…/models/user’ nodejs

I’ve got a problem with require.
I’ve got a users.js inside folder ‘router’. In users.js everything works great with

let User = require('../models/user');

But when users.js file getting bigger I wanted to part this file into a few files like login.js regiseter.js and so on. I created a folder ‘users’ inside ‘router’ and put there those files (login.js, register.js)

I changed my require to

let User = require('.../models/user');

Now I got an error:

Cannot find module ‘…/models/user’
enter image description here

Concat + wrap + compile all JavaScript files

I have a webpack project what looks something like this:

   ?   ?
   ?   ?? component1.js
   ?   ?
   ?   ?? component2.js
   ?   ?
   ?   ?? component3.js
   ?? main.js

I would like to have as output, two files:


(function(modules) { // webpackBootstrap
    // ...
(function(module, exports, __webpack_require__) {
    // my compiled JS code
    // ...


(function(modules) { // webpackBootstrap
    // ...
(function(module, exports, __webpack_require__) {
    const aSharedVariable = ...
    // compiled component1.js ...
    // compiled component2.js ...
    // compiled component3.js ...

I would like to share some common utilities (shown here as aSharedVariable) to all components, but keep the utilities scoped and out of the global scope.

Using webpack-concat-plugin I have been able to concatenate and, by using head and tail JavsScript files, wrap the code, however the code is not compiled so my require statements don’t become webpack require statements.

Using a input file:


const files = require.context("./components/", true, /.js$/);

I have been able to compile all files into a single compiled file but I’m not able to wrap the file so that I can provide scoped variables to all components.

I could also add a require statement to each component but this would result in a lot of duplicate code. There could be hundreds of components and each one may only be a couple of lines long, so I would rather have the file look like this:


doSomething("that is what my component does", () => {
    // ...

Rather than:

const utilities = require("my-common-utilities");
utilities.doSomething("that is what my component does", () => {
    // ...

Is there a way that I can concatenate my JavaScript files first, then compile the code using webpack?

kevinchappell / form Builder

I am new Comer in JavaScript
I used kevinchappell / form Builder but i am stuck because i am unable to customize it.
I need to add dynamically values in autocomplete text field can you help me

Form Builder Link

My Code is this

var fields = [
            type: 'autocomplete',
            label: 'Custom Autocomplete',
            required: true,
            fields : function (fieldData) {
                return {
                    values: '{label: "SQL"}'

// here i want to add dynamic values
                {label: 'SQL'},
                {label: 'C#'},
                {label: 'JavaScript'},
                {label: 'Java'},
                {label: 'Python'},
                {label: 'C++'},
                {label: 'PHP'},
                {label: 'Swift'},
                {label: 'Ruby'}

this is form-builder.js by kevinchappell / form Builder

How to pass a dynamic variable to a ‘component’ and then display it – VueJS

I can not display a variable (which is the link of an image) in my component I am lost …

(To help you, I’m in a table and click on the icon that opens a pdf)

Thanks you !

Vue.component('modal', {
    template: '#modal-template-pdf',
    props: {
        lien: String

let appCompta = new Vue({
        data: {
            showModalActive: false,
            currentModalPdfLink: '',
}).$mount('#'+id+' #app-compta')
<img slot="apercu" slot-scope="props" class="iconeged main" src="images/ico_pdf.png"
             @click="showModalActive = true"

<modal v-if="showModalActive" @close="showModalActive = false" v-bind:lien="currentModalPdfLink">
        <h3 slot="header">Aperçu PDF</h3>

    <script type="text/x-template" id="modal-template-pdf">
        <transition name="modal">
            <div class="modal-mask">
                <div class="modal-wrapper">
                    <div class="modal-container">

                        <div class="modal-header">
                            <slot name="header">
                                default header

                        <div class="modal-body">
                            <slot name="body">
                                <iframe height='100%' width='100%' frameborder='0' :src="currentModalPdfLink"/>

                        <div class="modal-footer">
                            <slot name="footer">
                                <button class="modal-default-button" @click="$emit('close')">

popover is off by top: 300px

For whatever reason I cannot work out my popover is off by about 300px, I cannot work out why and as a solution I want to change the that gets set on it to be +300px of whatever it gets set to.

I am using openlayers, and setting the position using the coordinates on click.


Setting the position on my tooltip is working fine using this exact method, so I need to work out what the problem is or change the css once it has been set by the onclick function;

var element = document.getElementById('popup');
map.on('click', function (evt) {
    var element = popup.getElement();
    var coordinate = evt.coordinate;
    var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
        coordinate, 'EPSG:3857', 'EPSG:4326'));
    // the keys are quoted to prevent renaming in ADVANCED mode.
        'placement': 'top',
        'animation': false,
        'html': true,
        'content': '<p>The location you clicked was:</p><code>' + hdms + '</code>'

Here is the code for toolltip:

function displayTooltip(evt) {
var feature = map.forEachFeatureAtPixel(pixel, function (feature) {
    return feature;
}); = feature ? '' : 'none';
if (feature) {
    tooltip.innerHTML = feature.get('name');
map.on('pointermove', function (evt) {
if (evt.dragging) {
pixel = map.getEventPixel(evt.originalEvent);