Posts by yamadapc • 736 points
24 posts
-
3
votes1
answer75
viewsA: Why use . length no for?
In that case keys must be a Array. For example: const keys1 = ['key1', 'key2'] // keys1.length === 2 const keys2 = Object.keys({ key1: 10, key2: 20, key3: 10 }); // keys2.length === 3…
javascriptanswered yamadapc 736 -
3
votes1
answer126
viewsQ: How efficient is Operator spread when copying Javascript objects?
I recently saw a comment around that talked about the performance of the operator "spread" or "scattering" in Javascript. The question essentially would be: if we wanted to copy an object and for…
-
1
votes1
answer126
viewsA: How efficient is Operator spread when copying Javascript objects?
If we wanted to implement a good copy function, it is important to understand that in the first version: { ...memo, [key]: target[key] } Are you copying memo for this new temporary object in each…
-
4
votes1
answer375
viewsA: Double Characters in Regular Expressions
What you want to do would need something called backreference (http://www.regular-expressions.info/backref.html), where one refers to a previously captured group within the regular expression. It…
javascriptanswered yamadapc 736 -
1
votes1
answer216
viewsA: Amazon Elastic Beanstalk + Django + Sentry returning Raven.exceptions.Invalidgitrepository
Elasticbeanstalk does not use git to deploy revisions of the application. It uses "Bundles" of the entire application stored in S3 (a zip/tarball of the entire repository, without the .git). You…
-
1
votes1
answer1609
viewsA: Adding Component Dynamically in React
To render a component react, intentionally cannot use imperative Apis as element.append. The way is to change yours state to reflect what you want to render using .setState({...}) and use this…
-
1
votes1
answer102
viewsA: Importing files without naming with Nodejs
You can use foo/index.js and require('./foo') (this is more prudent and common good). Or you can add a package.json in the directory foo and give any name to the main. eg. foo/package.json {"main":…
-
2
votes1
answer75
viewsA: How to use Monad batteries?
Yes, but note that there are two variants of Monad Transformers. The first is the one you are using, from the package transformers, where one wins at being able to use many monads, but has the…
-
2
votes2
answers896
viewsA: Block Save Repeated Data
The best way to do this is to establish a unique index in the field. This can be done by adding unique: true for setting the field in the schema: var UserSchema = new mongoose.Schema({ email: {…
-
1
votes1
answer44
viewsA: Generate Json x Search in mongodb
You should search for contacts who have references to related documents. Contato.find({ client_id: client_id }, function(err, contatos) { // ... }); Or: Contato.find({ company_id: company_id },…
-
1
votes2
answers158
viewsA: Error - Password update bcrypt
The problem is that the findByIdAndUpdate, and most family functions update of Mongoose, do not instantiate the Model and therefore do not execute: defaults setters validators middleware There is a…
-
1
votes1
answer117
viewsA: Couldn’t match expected type `Double' with actual type `Integer'
I don’t know where that function comes from fromDouble, but the problem without it is that bin2dec algumaCoisa returns a Integer. You need to use the function fromInteger :: Num a => Integer…
-
1
votes2
answers2228
viewsA: Update in array in Mongodb
You must use the $addToSet or the $push. The difference is whether you want unique elements in the array or not. There is a positional operator $ that you can use to update elements in the index…
-
0
votes1
answer63
viewsA: Search comparing id of two Collections
Maybe you don’t understand what you want, but if contact.Client.id and client.id are equal, the query you want is: Contact.findOne({ _id: contact.Client.id }, /*...*/) If they are different and you…
-
2
votes4
answers1210
viewsA: How to check if an input has a string?
The problem is that endereco in your code will always be a String, because jQuery.val() will always return to String for an input or textarea. To do the check you want, you need to use the parseInt,…
-
8
votes1
answer2380
viewsA: Doubt the $group mongodb
The $group is one of the stages of aggregate. The idea of aggregate is to establish a pipeline of operations on a Collection that will produce a certain output. It is an alternative to map-reduce…
-
1
votes1
answer507
viewsA: Clear Document write
What you want to do specifically is not possible. However, there are simple ways to solve this, even using only HTTP, rather than something like Websockets or a library like Socket.IO. A common…
-
2
votes1
answer421
viewsA: Change field Unique Collection mongodb
This is the case of rotating db.collection.dropIndex. When you create this model with the mongoose, it records your Collection and sets it to index fields marked as unique. You can read more about…
-
4
votes1
answer1396
viewsA: Enable CORS via Javascript (Phonegap)
In the Phonegap From other Stackoverflow questions (translated freely into English): Phonegap supports Cors? RE: Yes it supports, all you have to do is add that line to your file config.xml:…
-
1
votes2
answers278
viewsA: Image Cutting
Yes, you can use the Jcrop, which is a simple jQuery plugin to capture the dimensions of the hack in the browser: $(setup) function setup() { $('#picture').Jcrop({ onSelect: function(c) {…
-
3
votes2
answers71
viewsA: How to perform text distribution on a line
You can use a media-query when the page will be broken into several lines. On your page, there seems to already be a media-query for screens smaller than 767px: @media screen and (max-width: 767px)…
-
0
votes1
answer166
viewsA: Offline modules in Nodejs with npmbox
The npmbox comes with two executables: npmbox <nome-do-pacote> <nome-de-outro-pacote>… npmunbox <nome-do-box> Creating files .npmbox with the NPMBOX To create a package Bundle,…
-
3
votes1
answer693
viewsA: What are the ways of data storage in the browser?
According to this Wikipedia article in English, freely translated into Portuguese: Storage size Web Storage provides much more capacity (5 MB per source in Google Chrome, Mozilla Firefox and Opera;…
-
1
votes1
answer167
viewsA: Error sharing HTTP Session with socket.io. io.sets "is not Valid".
I believe this API of socket.io is deprecated. The solution would be to change its use of the method Server.prototype.set for Server.prototype.use, that will plant a middleware like those of the…