Posts by Miguel • 29,306 points
758 posts
-
4
votes1
answer182
viewsA: Only 2 houses after the comma
If you just need to print and do no calculations with that value later you can: printf("\n\n VOLUME = %.2f \n\n", resp);
-
6
votes3
answers756
viewsA: Get larger number of items in a Python list array
Use max: matriz = [[1,2,3],[4,5,6,7],[1,2,3,4,5,6]] len_maior = len(max(matriz, key=len)) # tamanho da maior sublista, 6 max(matriz, key=len) will return to higher sublist ([1,2,3,4,5,6]), based on…
-
3
votes1
answer211
viewsA: Join repeated information in a PHP table row
Save data that has already come out in an array, or as @Juniornunes said in comment, use groupby: $repetidos = array(); foreach ($roteiro->ListaRoteiro($romaneioIni, $romaneioFin, $dataIni,…
-
5
votes2
answers828
viewsA: How to differentiate data from two tables with columns of equal names in an SQL request with JOIN?
The SQL can stay: SELECT pa.reference AS pa_reference, pa.price AS pa_price, p.reference AS p_reference FROM ps_product_attribute INNER JOIN ps_product ON p.id_product = pa.id_product LIMIT 0, 30;…
-
4
votes1
answer56
viewsA: Difficulty with def and regex
Do so, I may have misunderstood some of the functions, if yes, say I try to correct: with open('tests.csv', 'r') as f: lines = f.readlines() colunas = [i.strip() for i in lines[0].split(';')] dados…
python-3.xanswered Miguel 29,306 -
1
votes1
answer694
viewsA: (php/Laravel) How do I calculate mathematical expressions?
I leave here a way without using eval(), for this already has an answer that was made longer ago whose @Bacco put the link on top of the question: function callback1($m) {return c($m[1]);} function…
-
3
votes1
answer5727
viewsA: How to return today input type date?
With php, you can do so: date_default_timezone_set('America/Sao_Paulo'); ... <input name="name_01" id="id_01" type="date" value="<?php echo date('Y-m-d'); ?>" /> DEMONSTRATION…
-
6
votes1
answer3488
viewsA: When closing modal, clear search result done in the bank
You can set empty value for them one by one in the event, when you do the hide modal: $("#ID").val(''); $("#Cooperante").val(''); $("#Propriedade").val(''); $("#Vistoria").val(''); $("#UF").val('');…
-
1
votes1
answer5173
viewsA: Taberror: inconsistent use of tabs and Spaces in indentation
The problem "inconsistent use of tabs and Spaces in indentation" should be because there is inconsistency between spaces and tabs as @jbueno said in comment, better keep or always spaces, or always…
python-3.xanswered Miguel 29,306 -
1
votes1
answer100
viewsQ: Does redirection not interrupt script interpretation?
I may be missing something, but there’s no way I can see what. I have a simple login code that is behaving (at least it seems to me) in a strange way. index php.: session_start();…
-
0
votes1
answer356
viewsA: Check the type of input
Although I would put the statement of quantidade outside the try as a matter of context, what we want to try (try) is just to transfer the quantity to integer. You can do with recursiveness: def…
-
1
votes3
answers95
viewsA: Load an element in ajax as user chooses
You had a serious error in your html, there can’t be two identical id’s (#estuda), you can put as class (.estuda), does the following: $('.estuda').change(function () { var chars =…
-
3
votes2
answers1769
viewsA: Get JSON result with php
That’s what you want, the array $dados['results']['forecast'] with every day: $raw = file_get_contents('http://api.hgbrasil.com/weather?format=json&'); $dados = json_decode($raw, true); echo…
-
13
votes2
answers12658
views -
2
votes2
answers56
viewsA: How can I return a query by grouping by the table name using Pdo, php and mysql?
Try it this way: $db = new PDO('mysql:host=localhost;dbname=DB_Tests', 'asdfds', 'dsad'); $tabelas = array('users', 'posts'); // aqui coloca as tabelas que quer $dados = array(); foreach($tabelas as…
-
2
votes1
answer532
viewsA: how to change an image by clicking on a link
You can start by storing the images in an array, and loading the images of n in n, which in this case n is num_imgs: var imgs = […
-
1
votes2
answers235
viewsA: How to take a string returned from the internal execution of a URL to turn it into a JSON object?
This string comes in JSON format, to transform into an object uses the method json_decode(); Using PHP has at least two ways: Using Curl: $url =…
-
4
votes1
answer168
viewsA: In the specialized class should I use self or Parent to access the variables?
For some tests I’ve done it’s relevant to use parent:: if in the abstract class and in the one that extends it there is a method with the same name and wants to call the method of the mother class…
-
4
votes1
answer993
viewsA: Broken Pipe with python sockets
The most severe is this server side line: s.send(bytes(msg.encode())) must be: conn.send(msg.encode('utf-8')), and is doing wrong the Encounter/Code (birth of the prince who is with python3.x), in…
-
3
votes2
answers11453
viewsA: Count vowels and know how many there are
You can do it like this: 1. def conta_vogais(string): string = string.lower() # para que a comparação não seja sensível a maiuscula/minuscula result = {} vogais = 'aeiou' for i in vogais: if i in…
-
8
votes2
answers124
viewsA: Mysqli does not run Insert within a function
But you are not specifying the message column for which table column pedidos goes that text ($mensagem)? You must specify: mysqli_query($odb, "INSERT INTO pedidos (<NOME DA COLUNA AQUI>)…
-
4
votes2
answers6203
viewsA: Use array_search in a php multidimensional array
This is because in the case of the question there is no book whose category is ONLY "Romance", but would return data. We have to check the string $livros[x]['categoria'] there is the word "romance",…
-
2
votes2
answers1090
viewsA: Send value from a radio input to php
Start by having some errors and faults in your html, the error is that it does not close the tags <label> and I assume you want to send the information with the http method POST, which is…
-
5
votes4
answers544
viewsA: Error set getElementById?
The problem is that the name of your variable is an integer, you should never do this, because if it did (I’m glad it doesn’t) it would bring a lot of problems, just as the id should be passed as…
javascriptanswered Miguel 29,306 -
2
votes1
answer1176
viewsA: Get Registry ID created Laravel 5
Store the object in a variable, in this case the $new, try the following: $new = $this->repository->create($request->all()); return response()->json(['sucesso' => 'Relatorio…
-
2
votes1
answer743
viewsA: How to return multiple values in a python function?
This is due to the return, that in the first loop is immediately invoked and the function where it is contained is terminated/terminated, in this case the lista_unidades(), do the following: def…
-
1
votes1
answer1046
views -
3
votes2
answers2110
viewsA: Laravel - Route with variable
Your Route has a small error, it should be like this (I assume the controller name and the file name are right and is "select"): Route::get('/disciplina/{id}',…
-
6
votes4
answers560
viewsA: How to return correctly the values of calculations with decimals in javascript?
I think that’s what you want: var resultado = parseFloat("126,79".replace(',', '.')) + parseFloat("237,00".replace(',', '.')); console.log(resultado); //valor correto = 363,79 The reason for this is…
javascriptanswered Miguel 29,306 -
2
votes2
answers744
viewsA: How to make a menu that when clicking opens another div?
Here is an example that how to do, there are several ways. $('.seccao:gt(0)').hide(); // para começar vamos esconder todas as seccoes excepto a primeira $('.menu-item').on('click', function() { //…
-
3
votes3
answers2721
viewsA: How to join several Python dictionaries?
You can use the update, then we have: a = {"A" : 1} b = {"B" : 2} c = {"C": 3} abc = {} abc.update(a) abc.update(b) abc.update(c) print(abc) # {'A': 1, 'B': 2, 'C': 3} Since dictionaries are not…
-
6
votes1
answer648
viewsA: How to read Yaml with Python?
You have to install the module if you don’t have it: sudo pip install pyyaml Might not need the sudo, depending on the system. And then: import yaml with open("tests.yaml", 'r') as f: try:…
-
1
votes1
answer218
views -
3
votes1
answer7703
viewsA: Call method by form action
No, it is not possible to call a certain method by action of the form, at least not directly, to action is to access a service (url) in your case I assume it will be a php script: Note that if…
-
0
votes1
answer143
viewsA: Content of responsive footer
There are a lot of things you don’t need and it’s much simpler than what you did, this is just an example, just taking your HTML, you can test by increasing and decreasing the browser window…
-
2
votes1
answer644
viewsA: How to get the result of the query executed in Eloquent?
You can use the method toSql() on the Builder: $achou = \DB::table('modulo_pr_espelho') ->where('prestador_id','=', $prestador->id) ->whereMonth('data_emissao',$mes)->toSql(); This way…
-
2
votes1
answer95
viewsA: Replace words
Well, I think I understand, according to the example you put in the question you can look for the expression that is capitalized and if there are ':' on the line. with open('tests.txt', 'r') as f:…
-
2
votes1
answer99
viewsA: Grab a button on Splinter (python)
Like your earlier question I answered, it’s possible but instead of the method find_by_value use the find_by_css, defining the css selector of the html element: from splinter import Browser with…
-
4
votes2
answers978
viewsA: How to find the name of a button by source code?
You can do it like this: from splinter import Browser with Browser() as browser: browser.visit("url aqui") button = browser.find_by_value('Criar Conta!')[0] # agarramos o button pelo seu valor…
-
8
votes2
answers1196
viewsA: How to separate words from a string?
It has several ways but I think the best will be an array with explode: $frase = "O + rato + roeu + a + roupa + do + rei + de + roma"; $palavras = explode('+', $frase); Now have an array, doing…
-
4
votes2
answers53
viewsA: How do I fix Javascript to make it work before I choose an option in my select?
The easiest way to achieve this is in css display:none; to all of them: $(function(){ $("#selected").change(function(){ $('#colors div').hide(); $('#'+$(this).val()).show(); }); }); #colors div {…
-
2
votes3
answers30
viewsA: Show different contents when selecting one of the buttons
With Html5 came the date attributes. I think you should take advantage of this, I changed the html a little: $('.opcao:gt(0)').hide(); $('[data-opt]').on('click', function() { var optId =…
-
2
votes1
answer482
viewsA: Remove div "Clone" in jquery
Just click to delete the last cloned element. I think that’s what you want, I added a class (fechar) at the <p>Fechar DIV</p>: $(document).ready(function() { var linha =…
-
4
votes2
answers624
viewsA: php cannot copy remote file, but download it from the browser
Here’s what’s going on: As can be seen from the image, the server implements a cookie (security=true) and must redirect to the same url, if the cookie authorizes the download, otherwise it will be…
-
3
votes1
answer289
viewsA: How to show a while array of various things
Soponhamos que acaba (after that while is finished) with these 2 items: $items[] = array( 'assetid' => 1, 'bt_price' => "0.00", 'img' => '123.jpg', 'name' => 'item1', 'price' =>…
-
2
votes1
answer827
viewsA: Copy a numpy.array without modifying the original
You must make a copy so that r2 so that it does not point to the same object: import numpy r = numpy.arange(36) r.resize(6,6) r2 = numpy.copy(r[:3,:3]) r2[:] = 0 Making print(r) the output will be:…
-
1
votes1
answer56
viewsA: Change equal titles
You can do it like this: <?php $courses = array((object) array("fullname" => "Nome 1"), (object) array("fullname" => "Nome 2"), (object) array("fullname" => "Nome 2"), (object)…
-
50
votes3
answers4342
viewsA: What is the difference between encryption, encryption and hash calculation?
Encoding: The purpose of Encoding is to ensure that data can be consumed by different system types, e.g.: send binary data by email or be able to do the encounter of special characters on a web…
-
5
votes1
answer3930
viewsA: Best solution for three types of users
From Laravel 5.2 that a multi authentication system has become simple to do (I’m pretty sure that in 5.3 the system remains the same), in this case we have two types of users to authenticate (admin…
-
3
votes1
answer52
viewsQ: Replace in update, change extension in filenames
I have a table with images, images, in which one of these columns (file_name) has names of pictures, some jpg others png, what I need is to change, to make UPDATE all to the extension png, that is,…