Posts by Miguel • 29,306 points
758 posts
-
4
votes3
answers11403
viewsA: Find larger and smaller unique values
This can be done even using max/min, you have to define the set of values in which they will act, in this case we do not want to include the repeated elements (occurrences > 1) in this set: vals…
-
3
votes1
answer224
viewsA: How to get the headlines of the Olympics on the CNN website with Python using Beautifulsoup?
The question is how to look at the returned html of get request and identify what it wants, in this case we want all the <span> who have the class cd__headline-text, I assume with headlines…
-
2
votes1
answer60
viewsA: Take part of the SVG ID content with PHP
If it’s always the same pattern (if id always has 'x5F' for example) even use regex, can with php do: $id = 'x5F_Bahia_x5F_Nova_Viçosa'; $exp = explode('_x5F_', $id); $zona = end($exp); echo $zona;…
-
2
votes1
answer1218
viewsA: Create share button on Linkedin
Probably how you’re using angular should change something, however one of the mistakes you gave me was: ...Event not defined... But in angular this may not happen. I don’t know if it’ll help, but…
-
3
votes2
answers1476
viewsA: Transforming Multidimensional Array into One-Dimensional
You can do it like this: $merged = call_user_func_array('array_merge', $array); $array its two-dimensional array (original) To keep the original keys equal so that we can work on them later we will…
-
6
votes1
answer91
viewsQ: Mini search engine
I am making a mini search system for urls that are stored in a.txt file, one per line, my problem is the performance issue because I have 5000 urls stored (only) and it is already slow in searching,…
-
2
votes1
answer173
viewsA: Doubt about cached files
This depends on whether you want the server to cache the resources or not, this can be seen in one of the parameters of the requested server response headers, in the case of facebook is:…
-
3
votes1
answer1967
viewsA: Size and position of div
As divs by default have display block, this means that the div will be placed under the previous element: EX: div { height: 100px; width: 50px; } #div1 { background-color: red; } #div2 {…
-
5
votes1
answer168
viewsA: Pass information to a Form Submit
Can make a input Hidden: <input type="hidden" value="123" name="senha"> The value of this input is also sent with the remaining data, but is not visible on the page.…
-
1
votes4
answers31463
viewsA: Onclick calling two functions at the same time Javascript
If I understand the doubt I think this is it: function funcao_a() { alert('funcao A'); } function funcao_b() { alert('funcao B'); } <button id="btn"…
-
5
votes1
answer46
viewsA: Formatting stdClassObject for array
Do it like this, you have to do the cast from each obj to array : $dados = $DB->return_records($query); foreach($dados as $dado) { $listagem['lista'][] = (array) $dado; }…
-
4
votes2
answers670
viewsA: Building a python Crawler web. I need help adding threads
Here is a simple example (python 3.x), the approach is slightly different from yours: import re from threading import Thread import requests def get_links(url): req = get_req(url) if(req is not…
-
2
votes1
answer68
viewsA: Dash Sliding-Middle-out on top image
.wrapper { width: 150px; position: relative; float: left; } img { width: 100%; } .bar { -webkit-transition: all .3s ease-out; transition: all .3s ease; width: 0; background-color: red; right: 0;…
-
1
votes3
answers129
viewsA: Detect text within a special character and convert it into a PHP function
At @Lollipop’s request I did not edit/withdraw my first reply, and here I put an alternative solution that we concluded (by chat/comment conversation) that would be better: function galeria1() {…
-
2
votes3
answers129
viewsA: Detect text within a special character and convert it into a PHP function
To the example you gave: function galeria() { return 'Funcao galeria'; } preg_match('/<textarea>(.*?)<\/textarea>/', '<textarea>Lorem impsun [galeria] Lorem…
-
5
votes1
answer4482
viewsA: How to get the index number of an array?
For that, if I understand correctly, you can use array_keys(): $arr = array( 'CPF_CNPJ' => array(), 'TIPO' => array(), 'Nome' => array(), ); $arr = array_keys($arr); Output from $arr: Array…
-
3
votes1
answer743
viewsA: Compare two strings and show difference between them
It has several tools that do this, but 'manually' can do so: function get_str_difs($str1, $str2) { $old = htmlentities($str1); $new = htmlentities($str2); $from_start = strspn($old ^ $new, "\0");…
-
2
votes3
answers145
viewsA: Blade default value Laravel 5.2
If the variable exists but is empty ('') you can do the following: {{($produto->complemento != '') ? $produto->complemento : 'Este produto não tem complemento'}} Or:…
-
4
votes1
answer624
viewsA: Laravel 5.2 with pagination
A small change: ... Igreja::orderBy('id', 'DESC')->paginate(3); ... Note that I am assuming that there is a column id auto-increment in this table, if there is no order by the column you would…
-
7
votes3
answers7168
viewsA: Two conditions in the same if() javascript loop
There were some syntax errors in if(...) and a few ); most after the function valida(), I believe that’s the way you want it: function valida(e){ var email = document.getElementById('email').value;…
-
4
votes1
answer4306
viewsA: Laravel 5 - Tokenmismatchexception in Verifycsrftoken.php line 67. How to solve this without using the FORM class?
You can put this into the form (if you are using Blade templating): <form method="POST" action="{{url('ROUTA DO POST')}}"> {!! csrf_field() !!} ... </form> {!! csrf_field() !!} produces…
-
2
votes1
answer86
viewsA: putting html in title, using query
Exeprimente instead of: ... $('<p class="tooltip"></p>') .text(title) ... Put this: ... $('<p class="tooltip"></p>') .html(title) ... $(document).ready(function() {…
-
2
votes3
answers5484
viewsA: Redirect page by passing "Answer" from ajax to a div
From what I understand is what you want (the way I would do): JS: $.ajax({ type: 'POST', url: 'pBuscaGenerica.php', data: data, dataType: 'html', success: function(response) {…
-
1
votes4
answers63
viewsA: Positioning of li’s on the page
body { margin:0; } ul { padding: 0; width: 100%; font-size: 0; } li { box-sizing: border-box; text-align: center; font-size: 16px; border: 1px solid; width: 33.33%; padding: 10px; display:…
-
6
votes1
answer838
viewsA: How to get a CSS attribute from a tag?
To fetch css properties from the stylesheets (*.css): var myImg = document.getElementById("my-img"); var marLeft = getComputedStyle(myImg).getPropertyValue("margin-left"); alert(marLeft); #my-img {…
-
1
votes1
answer203
viewsA: Python - PHPSESSID
To send cookies together with request, using the lib requests: import requests s = requests.Session() r = s.get('http://httpbin.org/cookies', cookies={'CHAVE1': 'VALOR1', 'CHAVE2': 'VALOR2'})…
-
1
votes2
answers1514
viewsA: Fixed menu appearing when scrolling page
We have to save the last positions of the scroll to compare, if it’s bigger it’s because we’re going down, and if it’s smaller we’re going up. You can do it like this: var lastScrollTop = 0;…
-
5
votes2
answers1231
viewsA: Regular expression (regex) for links to web pages using Python
To complete the excellent @zekk response, here’s a solution for python 3.x: import requests, re url = "/q/143677" html = requests.get(url).text urls =…
-
1
votes2
answers46
viewsA: Playing more than one txt field inside the database
There are two points where you are failing: The explosion would first have to be by line break ( n), and only then by ';' within your foreach is always echo the same data ($dividir[0], $dividir[1])…
-
1
votes1
answer438
viewsA: Take the size of an image
So (as it has structured css) will not give because the image is in the background, can however do so: div { display: inline-block; border: 2px solid yellow; /* isto é só para ver a div…
-
5
votes1
answer197
viewsA: How to know which is the first item in the ngRepeat loop?
Use the variable $first. It is intended to indicate which is the first element in ng-repeat. Behold: <div ng-repeat="name in ['guilherme', 'wallace', 'bigown', 'rray']" ng-class="{'bold' :…
-
1
votes5
answers1390
viewsA: Page redirection according to access country
You can use an API, in this case I used http://ip-api.com/, and make: // descobrir o ip do utilizador if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif…
-
1
votes1
answer406
views -
6
votes3
answers6679
viewsA: creating a python voting bot
With requests will not give because it does not process Javascript, if you do: import requests req = requests.get("http://soulegal.byethost7.com/wp/2016/07/28/pesquisa-eu-sou-legal/")…
-
1
votes1
answer88
viewsQ: Avoid using explicit loop, find/edit array with the desired value
I have the following array: $users = array( array( 'id' => 17, 'name' => 'Miguel' ), array( 'id' => 23, 'name' => 'Vera' ), array( 'id' => 39, 'name' => 'Sara' ) ); My question is:…
-
6
votes2
answers1370
viewsA: Remove onclick attribute by Javascript
Here’s an example of how to remove the attribute onclick with jQuery inside the inline referenced function (onclick="..."): function addUser(valor, ele) { console.log('botão com o valor: ' +valor);…
-
1
votes1
answer1616
viewsA: Get return of a PHP function in JS
For this you can do a get by one ajax simple with jquery: $.get("arquivo.php", function(data) { alert("Retorno: " +data); }); This is where I put the "arquivo.php" put the path to your php script…
-
5
votes2
answers83
views -
2
votes3
answers1248
viewsA: How do I redirect the site when it’s a mobile?
I already did that and I got it this way, this can be right in the <head> not to waste time processing other things before since it will (may) be redirected, nor need jquery: redi_width =…
-
12
votes1
answer4727
viewsA: How to display asterisk in fields with required css?
To do with css you can add a class (in this case I chose required) the elements you want to have the asterisk, and configure that class with the pseudo element after, examples: Before the input:…
-
4
votes1
answer2279
viewsA: Go to the bottom of the page
To scroll to the bottom of the page: $('#down').on('click', function() { $('html, body').animate({ scrollTop: $(document).height() }, 700); }); #div1 { height: 1000px; background-color: red; } #div2…
-
2
votes2
answers2031
viewsA: Sending an image and other data via Jquery to PHP
I will do an example that as fields (in addition to file, image) will have input to name and other to email: This is a working example, put these two files in the same directory and test: index php.…
-
6
votes1
answer4275
viewsA: Login to facebook com python
With requests (only) it is difficult to login to facebook, because they must bet on javascript to generate additional data for security, and it would be very complicated to track everything that…
-
3
votes1
answer61
viewsA: How to make two values switch in a variable without repeating
Can do with Session: session_start(); if(!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { if($_SESSION['count'] == 0) { $_SESSION['count'] = 1; } else { $_SESSION['count'] = 0; } }…
-
3
votes1
answer1435
viewsA: Inserting holidays in jquery datepicker?
Should use beforeShowDay choke: $('#Data_ProximoContato').datepicker({ inline: true, dateFormat: "dd/mm/yyyy", beforeShowDay: function(dateText, inst) { var datepickerDay = ('0' +…
-
1
votes2
answers527
viewsA: Table with width 100% and Scroll
In reality your table has width: 100%, can prove this by adding border: 1px solid green; à table.width {... and seeing that this one has the 100%. That is, we want each td to be resized (increased,…
-
3
votes2
answers998
viewsA: Animation when changing the display into HTML
Here, you must adjust the id of the element to appear and time within the function onclick button function fadeIn(elem, speed) { if(!elem.style.opacity) { elem.style.opacity = 0; } var op =…
-
6
votes1
answer3624
viewsA: Check for Jquery internet connection
It’s possible, try to: var online = navigator.onLine; // true ou false, (há, não há conexão à internet) if(online) { // efetuar pedido ajax } To test, create a file on your computer, e.g.,…
-
3
votes2
answers4318
viewsA: Change color CSS
With CSS, provided the element to be changed is child of the element to be made: div:hover h2 { color: red; } <div> <h1>Olá</h1> <h2>Adeus</h2> </div> With more…
-
5
votes1
answer1665
viewsA: How to get the HOST IP through the PYTHON domain?
In reality python is almost that: import socket socket.gethostbyname('www.google.com') # 216.58.211.196