Posts by Miguel • 29,306 points
758 posts
-
1
votes1
answer174
viewsA: Curl and Laravel, always redirect
Solved, looks like the requests library (even without using Session()) retain cookies and place them in the redirect request header, in which case it is the language cookie ..../pt that, by the app…
-
0
votes1
answer174
viewsQ: Curl and Laravel, always redirect
I’m trying to make a simple Curl to an Laravel app (5.2) running on my machine: curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"…
-
2
votes1
answer68
viewsQ: Preg_match_all, get input name attribute values
I am doing a project with dynamic forms, that is, the user (administrator) can make his own form (HTML/CSS), but when fetching the form from the database I need to check if the names (name) of…
-
3
votes2
answers2340
viewsA: Iterating over nested dictionaries (Pythonic)
There is, yes, several pythonices :P can do: Way 1 dic = {'section1': {'key1': 'value1', 'key2':'value2'}, 'section2': {'key3': 'value3', 'key4': 'value4'}} values = [item for sublist in…
-
2
votes2
answers1944
viewsA: Remove comma from the last foreach value in PHP
There are several ways. Can do with rtrim: $array = [1,2,3,4]; $text = ''; foreach($array as $item) { $text .= $item. ', '; } $text = rtrim($text, ', '); echo $text; // 1, 2, 3, 4 Or ex, like this:…
-
1
votes1
answer166
viewsA: Pick up input file with multiple classes
The way you are selecting is not the most conventional, if you want to select elements according to a class you can simply: $('.upload').on('change', function() { alert($(this).prop('class')); // só…
-
5
votes2
answers109
views -
3
votes2
answers412
viewsA: How to find out what is the first or last item of the Loop in Laravel?
As far as I know, this only exists in the new Laravel 5.3: @foreach ($users as $user) @if ($loop->first) // primeiro item do loop This is the first iteration. @endif @if ($loop->last) //…
-
3
votes2
answers58
viewsA: Shopping list within function
For the next one it is better to put the relevant code part here, to help those who want to help you, not everyone has time/want to go to external links to see code. You can do so, I suggest these…
-
2
votes1
answer550
viewsA: How to find a "<li>" tag with a "dorm" text from a list of tags in python3?
The tag <strong> in the middle of <li> spoils the search a little the way you are doing. However you can approach the problem also in this way: from bs4 import BeautifulSoup import re…
python-3.xanswered Miguel 29,306 -
1
votes1
answer96
viewsA: Get exception name in Python where it is not specific
It seems to me that it has to do with the connection. Try: try: s.connect(('IP', 'PORT')) except socket.error as exc: print 'Cautela: %s' % exc
-
4
votes3
answers7332
viewsA: How to put scroll at the end of the div?
You can do this with jquery: $('#scroll-div').animate({ scrollTop: $(this).height() // aqui introduz o numero de px que quer no scroll, neste caso é a altura da propria div, o que faz com que venha…
-
3
votes2
answers37
viewsA: Contenteditable attribute does not work
contenteditable="false" apparently it doesn’t work in input, do so (readonly) <input type="email" name="email-empresa" id="email-empresa" placeholder="ex: seuemail@domínio.com" class="txt-input"…
-
3
votes1
answer880
viewsA: jQuery - Using event click on div father and son
If I understand correctly, you want the event not to propagate for the child but to shoot by clicking on the father (click on any place of the father except the son). Has to give a…
-
5
votes2
answers150
viewsA: Retrieve PHP data within a text
You can do it like this: $texto = "Olá {cliente}, seja bem vindo ao site {site}! Aqui você terá acesso as seguintes opções: {opcoes} Estes dados foram gerados automaticamente em {data} Pela empresa…
-
4
votes1
answer324
viewsA: How to do While from one table and show data from another?
The solution I left in comment would be the most appropriate: SELECT * FROM Tabela1 JOIN Tabela2 ON Tabela1.id = Tabela2.Id_fk; But for coherence between answer/question here is a solution to what…
-
10
votes5
answers426
viewsA: Explodes with name indexes (associative)
Can do with array_combine to associate each key to the corresponding value: $user = "Diego:25:RJ"; $keys = array('nome', 'idade', 'estado'); $info = array_combine($keys, explode(":",$user));…
-
4
votes1
answer1178
viewsA: Text alignment with css
You can only touch the property bottom in the p, and forget the margins, are not necessary, nor does it have to specify a width in this case, unless you want to force the line break: .se-pre-con {…
-
1
votes3
answers1906
views -
4
votes2
answers3070
viewsA: How to see the queries that were executed by the eloquent in Laravel?
In Laravel 4 can do: $queries = DB::getQueryLog(); // array de todas as queries que foram corridas Already on Laravel 5, since the log is not active by default and we have to activate it: use DB;…
-
5
votes1
answer567
viewsA: How to convert array keys to all uppercase or lowercase?
There is, the function array_change_key_case, Wallace. Veja: $arr = ['Id' => 44, 'NumeroDoCliente' => 55, 'ProdutoCodigoNum' => 77]; To upper case: $upperKeys = array_change_key_case($arr,…
-
0
votes1
answer7755
viewsA: Matrix (Create 2 Matrices and Sum them)
To add up the matrices can do: def somarMatrizes(matriz1, matriz2): if(len(matriz1) != len(matriz2) or len(matriz1[0]) != len(matriz2[0])): return None result = [] for i in range(len(matriz1)):…
python-3.xanswered Miguel 29,306 -
1
votes1
answer1139
viewsA: Creation of a random vector
From what I realized all inputs of the user should be passed parameters ("...receives as parameters the size of the vector and the range of values."): from random import randint # para gerar os nums…
-
1
votes2
answers659
viewsA: Problem with float python (Uri 1098)
Your code seems to work well. As for running to infinity I think it’s because of the logic in your while. To answer your question: there is some function that is better working with decimals? Yes…
-
2
votes2
answers323
viewsA: How to sort by average and quantity (weight)?
See if this solves, multiply the media by way of qtd_avaliacoes respective: SELECT (AVG(rating), 0)*(COUNT(dealer_ratings.id), 0) as result FROM dealers ORDER BY result DESC; Adapted to your case:…
-
3
votes1
answer106
viewsA: Sort array php
Adapted from this excellent response in the Soen: $array = array( array( 'id'=>5, ), array( 'id'=>2, ), array( 'id'=>1, ), array( 'id'=>3, ) ); usort($array, function($a, $b) { return…
-
1
votes1
answer166
viewsA: Open Ajax with addition to url
I suggest to pass as argument right away the two parameters, $name and $id: HMTL ...onclick="<?php echo 'portfolioModal(\'' .$name. '\', ' .$id. ');'; ?>"... JS: function portfolioModal(name,…
-
2
votes1
answer819
viewsA: How to create an UDP port scanner in python 3?
See if this one works: import socket ip = '127.0.0.1' while True: port = input('port?\n') if(port == 'exit'): break s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((ip,…
-
2
votes3
answers2985
viewsA: Delete file Laravel
With Storage::delete(...), never tried, always use the native php function unlink, try the following: unlink(public_path('uploads/'.$asset->contents->belongs_to.'/'.$asset->name));…
-
3
votes1
answer460
viewsA: Upload file . txt removing php accents
Do so: <form enctype="multipart/form-data" method="POST"> <input type="file" name="txt"> <input type="submit"> </form> <?php if($_SERVER['REQUEST_METHOD'] == 'POST') {…
-
1
votes1
answer336
viewsA: Centralized HTML/CSS menu
Must put in the #menu ul, #menu ul li and #menu ul li a the following amendments. Notes that display: inline; does not allow you to give comprimento/altura to the element, float: left; is…
-
1
votes1
answer226
viewsQ: Check which Guard is logged
I have a 5.2 Standard application, with multiauthentication, the Guards configured in config/auth.php sane: ... 'admin' => [ 'driver' => 'session', 'provider' => 'admin', ], 'user' => […
-
8
votes3
answers14487
viewsA: Divide a list into n sublists
l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] You can do so if you want 3 sublists: n = 3 splited = [l[i::n] for i in range(n)] print(splited) # [[0, 3, 6, 9, 12], [1, 4, 7, 10, 13], [2, 5,…
-
0
votes1
answer46
viewsA: Comparing a data entry to a list, regardless of whether the word starts with a capital letter
Make the comparison by also transforming what you typed into minuscule letter: prompt = "Digite o mês de seu nascimento (digite exit para sair): " meses = ['janeiro', 'fevereiro', 'março', 'abril',…
-
5
votes2
answers781
viewsA: Can I run CSS commands in javascript? HTML
Of course, pretty much everything that happens in GIFT can control/manipulate with javascript: var btn = document.getElementById('btn'); btn.addEventListener('click', function() {…
-
2
votes1
answer137
viewsA: Label stylization in a file type input
I don’t know if you can do this just with css, you need to track the event change no input, anyway here’s a solution using javascript: function change_label() { // aqui coloca todas as mudanças a…
-
4
votes2
answers5344
viewsA: Is it possible to capture the current url in the Blade view?
To get the url in the view you can do: <p>{{Request::url()}}</p> To check if the second segment of the url has "user": @if(explode('/', Request::url())[3] == 'user') // tem '/user'…
-
7
votes1
answer12952
viewsA: Generate all combinations given a python list
To generate all combinations of 8 chars from a list of 70 elements will be extremely costly, 708 (576,480,100,000,000) combinations... Good luck :P To generate all possible combinations, including…
-
4
votes2
answers194
viewsA: How do I exchange the 3 and 5 occurrences of a word in a string
You can do it like this: my_str = 'Isto é o meu texto , sim é o meu querido texto , gosto muito deste texto ... Melhor texto do mundo, sim é um texto ' words = my_str.split() words_count = {} for k,…
python-3.xanswered Miguel 29,306 -
7
votes4
answers18339
viewsA: Javascript customize confirm, replace text button "ok" and "Cancel", run function only if clicked on ok
With the native function you can’t create custom confirmation boxes, can however use jquery UI to simulate this: function funcao_b() { alert('funcao B'); } function confirmar() { $(…
javascriptanswered Miguel 29,306 -
1
votes2
answers43
viewsA: How to extract the link title from a responsive menu?
You were doing wrong: IS text and not text() console.log($('#responsiveAccordion > li .responsiveInykator').parent().children()[1].text); <script…
-
1
votes1
answer326
viewsA: Calling method within URL in Laravel
try the following: href="{{URL::previous()}}" You can also do with javascript: <a href="#" onclick="window.history.go(-1);">...</a>…
-
1
votes1
answer77
viewsA: I cannot use the CSS pseudo-element with Jquery
According to this answer in the Soen: This is not possible; pseudo-Elements are not part of the DOM at all so you can’t bind any Events directly to them, you can only bind to their Parent Elements.…
-
2
votes4
answers559
viewsA: Load url on same page
Experiment with Curl: function do_sms($serv) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, True); curl_setopt($curl, CURLOPT_URL, $serv);…
-
3
votes1
answer287
viewsA: Countdown that renews at midnight using pure javascript
You can do it like this: function calculateHMSleft() { var now = new Date(); var hoursleft = 23-now.getHours(); var minutesleft = 59-now.getMinutes(); var secondsleft = 59-now.getSeconds();…
javascriptanswered Miguel 29,306 -
5
votes2
answers337
viewsA: Data entry without echoing on screen
With the method input() I don’t think so. But you can do it like this: import getpass p = getpass.getpass(prompt='digite a senha\n') if p == '12345': print('YO Paul') else: print('BRHHH') print('O…
-
5
votes3
answers1045
viewsA: Fibonacci with parallel execution? Threads?
I’ll leave an example with the threading module: import threading def fibo(n): a, b = 0, 1 for i in range(n): a, b = b, a+b data[threading.currentThread().getName()] = a def get_results():…
-
21
votes7
answers52205
viewsA: Is there a way to print everything without breaking the line?
If you are using python 3.x: print('t', end="") print('e', end="") print('s', end="") print('t', end="") print('e') If not (if python2.x) the easiest way to not import unnecessary things would be to…
-
5
votes3
answers31234
viewsA: How to print skipping lines (each variable in a row)?
Thus: nome ='Paulo' profissao = 'estudante' escola = 'estadual dourado' idade = 18 print 'Nome: '+nome + '\nTrabalho: '+profissao + '\nEscola: ' +escola+ '\nIdade: '+str(idade)+ ' anos' Note for…
-
1
votes2
answers1161
viewsA: Add CSS class in Input when Loading page
I was mixing native javascript methods (document.getElementById) with jquery methods (addClass), so did not do what expected. These two methods return different things. Do so:…