Posts by RFL • 6,205 points
308 posts
-
0
votes1
answer71
viewsQ: Assign method to custom types in Golang
I have a code where I need to perform several replaces and for that I did so as follows: exemplo := "Olá, meu nome é xpto, na verdade xpto da silva xpto" formated := strings.Replace(exemplo, "xpto",…
-
4
votes1
answer102
viewsA: Capture data into space, regex
you can use the \w+ to indicate that there are only letters between the asterisks: the expression: \*(\w+)\* see working on Regex101…
-
1
votes7
answers4789
viewsA: Force input with a dot instead of an html comma
You can use the tag pattern of html, see; <form action="#"> <label for="price">Preço:</label> <input type="text" name="price" pattern="[0-9]\.[0-9]" title="casa decimal deve ser…
-
1
votes0
answers421
viewsQ: File upload with Standard 5.4
I’m following the documentation to upload files to the folder storage however the path that the function returns is not the same path in which the file was stored, see in the documentation: $path =…
-
0
votes1
answer313
viewsQ: Capture changes that have been rendered with state in vueJS
I’m rendering the data that’s in one state in the vuex on some inputs that are scattered around the screen; I know I can’t use the same method of a "model" (two-way-databiding) to change the value…
-
1
votes1
answer133
viewsQ: Convert multiple nodes to XML for struct
I looked for some examples in the official documentation of golang and in some online tutorials but only find simple examples see: <data> <person> <firstname>Nic</firstname>…
-
1
votes1
answer218
viewsQ: Use function in another Golang folder
I created a pacote inside $GOPATH/src/github.com/meu-user/meupacote with a file meupacote.go who has the function main and another folder with the name productsthat holds the file products.go, in…
-
-2
votes1
answer2504
viewsA: Insert space into a PHP variable
you can use the function sprintf, see: $var1 = "Olá"; $var2 = "Mundo"; $var3 = sprintf("%s %s", $var1, $var2); echo $var3; // Olá Mundo You can use as many parameters as you want in the function…
-
1
votes1
answer99
viewsQ: Access prop through Watchers in Vuejs
A similar problem has been solved in this issue: Access prop in Vuejs method Where a prop era null for the requisition ajax of the parent component had not yet concluded; but in my case the prop is…
-
3
votes1
answer955
viewsQ: Difference in hours between days using Carbon
By checking the difference in hours between today and tomorrow I get the value of 6 which refers to the amount of hours until 00:00 today; $t = \Carbon\Carbon::tomorrow(); $n =…
-
1
votes1
answer366
viewsQ: Access prop in Vuejs method
I’m passing a array of objects to a component and within this component I try to access past values: <orders-list :orders="items"></orders-list> Component orders-list: <template>…
-
-1
votes1
answer60
viewsQ: Parser error in Laravel 5.5
In my view, welcome.blade.php I am getting a parser error in the following HTML snippet: <div class="single_service_left"> <img src="{{ asset('images/flaticon4.png') }}" alt="" />…
-
0
votes1
answer98
viewsQ: set $Scope inside angular callback
I’m trying to define a variable $scope.plan_id within a callback used in the $http, and always when I check this variable I get undefined. $http({ method: 'get', url: '/api/pricings/get'…
-
1
votes2
answers269
viewsA: Length of jQuery does not update with the append, how to resolve?
When to insert a new elemento HTML with the append insert passing it as an object jquery, see: $( document.body ) .click(function() { $( this ).append( $( "<div class='mydiv'>" ) ); var n = $(…
-
3
votes1
answer985
viewsQ: Downgrade of package in Laravel
I’m facing a problem to run the composer install due to a package that is incompatible with the version of the Laravel that I currently use; The version I have is 4.1 with php 5.6, but when I run…
-
0
votes2
answers133
viewsA: Treatment JSON
The return of the data appeared in the variable response which is the function parameter when it finishes (done), you can simply use the notation of ponto to access the keys of a json, see:…
-
5
votes5
answers1186
viewsA: How to use the reduce (reduce) operation on objects?
You forgot to pass the second parameter to the reduce function, which is the value that will start the operation, see: var valores = [{valor: 1}, {valor: 2}, {valor: 3}, {valor: 4}, {valor: 5},…
-
5
votes1
answer967
views -
4
votes2
answers373
viewsA: Concatenate variable into array
You can turn your json in array, add whatever you want and then convert to json again. $jsonData = json_decode($json, true); $jsonData['clienteLogin']['email'] = $email;…
-
0
votes1
answer40
viewsQ: Ignore a certain value with AVG
I wish I could calculate it AVG ignore the values above 100000 (10 seconds), with the following query: user_id, COUNT(*) as total, AVG(`exec_time`) as tempoMedio, SUM(CASE WHEN `success` = 1 THEN 1…
-
0
votes0
answers209
viewsQ: microtime for seconds
I’m checking how long a API delay to respond and I’m picking up the values at the beginning with microtime(true) and at the end with microtime(true) therefore; $start = microtime(true); ... ... ...…
-
1
votes0
answers30
viewsQ: Difference between using COUNT in column and COUNT with "*"
I accomplished 2 querys in a bank where I needed to know the amount of records based on a column but if I change the parameter of COUNT() the results are different. SELECT COUNT(`time`) as 'tempo'…
-
1
votes1
answer160
viewsQ: String validation (Isogram)
When creating a function that returns false if there are repeated letters in a word, and true if there is no following test passes with the characters:…
-
2
votes2
answers106
viewsA: Comparison of dates - PHP
Taking into account that $transacao->data_expira is the type DateTime, you can compare using the function ->diff(), see: if ($transacao->data_expira->diff(new DateTime("today")) >= 0)…
-
2
votes1
answer198
viewsA: Use variables external to Route do Laravel 5 to send to view
Variables external to an anonymous function are not visible within them, so you can use this variable within an anonymous function you need to use the use() after the function call, see: $foo =…
-
1
votes1
answer370
viewsQ: Return values in time format
I own a struct with 2 ints and I need to return these values in string but in time format. type Clock struct { hour int minute int } func New(hour, minute int) Clock { return Clock{hour, minute} }…
-
1
votes2
answers1623
viewsA: Checking whether a string is empty in Javascript. Idiomatic or readable?
You can use the class String to start a new variable of this type, see: const myText = new String("Hello!"); console.log(myText.length); // Saída: 6 (tipo número) const emptyText = new String("");…
-
0
votes1
answer107
viewsQ: Download package using "go get"
The installation of go in /usr/local/go occurs perfectly and I can verify this using: go --version When trying to use get with: go get github.com/russross/blackfriday I get the following error:…
-
2
votes1
answer34
viewsQ: Check Unix user
To check the user name I can easily use: import ( "fmt" "os" ) fmt.Println(os.Getenv("USER")) But to make things a little easier I’d like to add a new role to struct os, so I did it this way: func…
-
0
votes3
answers866
viewsA: print value of a given array with PHP
How the data is inside a array, you will need to use a loop as for, foreach or while, see below an example with foreach: $dados = []; foreach($dados as $item) { echo $item->product_price; }…
-
2
votes2
answers796
viewsA: How to put a json code in textarea html?
with javascript you can transform a json in texto using the function stringify(), after the conversion included in its HTML normally. let json = JSON.stringify({"Language":"PT-BR",…
-
3
votes1
answer557
viewsQ: Validate composite key with Laravel?
I have a table where employees of a company are inserted with the following fields; id, name, email, use_id, role_id. user_id is the id of the company the employee works for. The validation I need…
-
3
votes3
answers327
viewsA: Error reading JSON with PHP
There are some mistakes in your json what makes the PHP return null when you use the json_decode, errors are the commas in the last elements of each objeto, for example: "conversion_origin": {…
-
2
votes2
answers48
viewsA: Avoid error while recovering Json field
I suggest you check to see if the element is or is not a array, but if it is an array it would be ideal to check if there is only one key (if the front-end sends an array with two keys). $raw =…
-
0
votes2
answers51
viewsA: I cannot place element inside JSON
The second function parameter json_decode defines whether the json will be maintained as objeto or converted to array, how did you pass true then it was defined that it would be used as array, but…
-
3
votes3
answers115
viewsA: Problem in the price formatting function
You can use Intl.NumberFormat to convert values to the monetary format. const Money = Intl.NumberFormat('BRL', { style: 'currency', currency: 'BRL', }); Money.format(19.50); // Saida R$19,50…
javascriptanswered RFL 6,205 -
1
votes2
answers917
viewsQ: Select only 1 radio button with Ionic
I’m trying to render some radio buttons using *ngFor and only that I can select or first or the last option, never the middle options. I got the following array: [ { "title": "First question",…
-
1
votes2
answers1306
viewsA: Check if there is a key in the/json array
you can use the function array_key_exist but for this you need to inform the json_decode to convert the json for array and not objeto, or use the function property_exists to test the objeto. Check…
-
0
votes1
answer70
viewsQ: Angular Service using third-party Packages
I’m creating a service in angular who consumes a package to consult a api, but I always get the same mistake; Can’t resolve all Parameters for Apiservice: (?). the Code: import { Injectable, Inject…
-
0
votes3
answers1764
viewsA: How to create a static method using Kotlin?
according to the java for kotlin, the corresponding code would be: fun getDragonGlass():String { return ("All the dragon glasses.").toString() } The return type declaration is made after the…
-
3
votes2
answers1666
viewsA: How to turn array into string with php
You can use the function implode(). implode($array, ','); This will cause the array to be grouped into a string separating the values by comma (you can use anything as a separator). Example: $array…
-
1
votes2
answers77
viewsA: What was my mistake with that code?
You are using double quotes to start the onClick() and within the onClick() you are also using double quotes which is what is generating this error when you do onClick="... and put another double…
-
1
votes0
answers974
viewsQ: Enable method POST wordpress/Woocommerce
I’m trying to send a POST for Woocommerce/wordpress using the API Woocommerce-api, but I only get the error 401 what it says: Fetch API cannot load http://wc-project.dev/wp-json/wc/v1/orders...…
-
0
votes1
answer71
viewsA: CSS Gradient Radial
You’re wearing linear gradient when actually should use radial-gradient, you can see the difference between them in WC3 website. body { height: 100vh; background: radial-gradient(#7db9e8, #1e5799);…
-
3
votes2
answers357
viewsQ: Update key in state when another key is updated
The main idea is based on a shopping cart, when a product is added to the cart (key products) the key orderTotal is updated. Inside the key products own a object with various products each…
-
1
votes4
answers211
viewsA: Like a tag on a table element with jQuery?
Let’s separate by steps what must be done: Take all values within each td. Put them in order from minor to major. Take the lowest value element and insert the tag <mark></mark> in it.…
-
3
votes1
answer3707
viewsA: What is the best way to generate random code that does not repeat in the database?
you can use the uniqid function that returns a prefixed unique identifier based on current time in millionths of a second. echo uniqid(); // Saida: 5975b4239b793 or you can also pass a parameter to…
-
4
votes3
answers274
viewsA: Add javascript to Wordpress plugin
I found the answer in this stack topic in English. To include the archive with wp_enqueue_script be a plugin, the function shall be used plugin_dir_url and not get_template_directory_uri(), because…
-
1
votes0
answers17
viewsQ: Remove "dist" string from build with Webpack
I created a rule in my file webpack.config.js so I can work with sources inside my scss, but when I do the build for production the string to load the file is as: /distfonts/minha_font.woff Where…
-
5
votes3
answers2171
viewsA: Javascript function when clicking on any class="foo"
To select all the elementos of a certain class, you can use the function querySelectorAll() who had returned a array with all the elementos <a> who have the informed condition, for example:…