Posts by Paulo Costa • 3,976 points
66 posts
-
4
votes2
answers125
viewsQ: How to remove rows from a table A that has no relationship to table B?
I have 2 tables and want to remove the rows of table A that has no relationship with table B? For example: In table B I have a field FK_ID and I want to remove from table A all rows that have no…
-
1
votes1
answer426
viewsQ: How to convert varchar to datetime?
How to convert a date into varchar for datetime in the mysql? For example: 04-12-2016 for 2016-12-04 16:00:00 04/12/2016 for 2016-12-04 16:00:00…
mysqlasked Paulo Costa 3,976 -
-1
votes2
answers72
viewsA: Why are non-https origins considered unsafe by browsers?
"We at the Chrome Security Team propose to change your UX to display unsecured sources as affirmatively unsecured. We intend to design and start deploying a transition plan for Chrome in 2015. The…
sslanswered Paulo Costa 3,976 -
4
votes1
answer3297
viewsQ: Generate random numbers in Java
How to generate only numbers larger than 2? How to generate only numbers larger than 2 and the generated numbers have to be multiples of 3(eg. 3, 6, 9)? How to generate only numbers smaller than 10?…
-
1
votes1
answer475
viewsQ: How to show Hashmap value?
I’m having trouble showing (can be using a for) the value of this Hashmap. Does anyone know how? The console only shows this value: {Joao=[Ljava.lang.String;@2b05039f} I can’t show the internal…
-
2
votes1
answer651
viewsQ: How to just send messages to other customers?
I have a question with java sockets. My code sends messages to all customers, including what you send. I want it to send only to other customers. Is there any way to do this? I test using the…
-
0
votes2
answers742
viewsA: What’s a destroyer for?
They are special methods that contain clear code for the object. You cannot call them explicitly in your code, as they are implicitly called by GC. In C# they have the same name as the class name…
-
2
votes1
answer80
viewsA: What are the advantages of using Splfixedarray instead of an array?
The advantage is that it allows a rapid implementation of Array. As illustrated by the benchmarks performed by the author of this article: In addition, Splfixedarray’s memory consumption is actually…
-
3
votes4
answers13756
viewsA: Sort List in java
List<Pessoa> pessoas = new ArrayList<Pessoa>(); // setando Pessoa pessoa; for(int i=0;i<100;i++) { pessoa = new pessoa(); pessoa.setNome(...); …
-
1
votes2
answers42
viewsA: Doubt Mysqli Parameter new_link
Every instance mysqli is completely independent of each other and therefore every db connection of an instance is a new_link. Therefore, there is nothing equivalent to new_link in the mysqli.…
-
13
votes5
answers169
viewsQ: What is the fastest is_null($y) or $y == null?
What’s the fastest is_null($y) or $y == null?
phpasked Paulo Costa 3,976 -
1
votes1
answer97
viewsA: How to program to open a specific file type?
A file .cbr is a rar archive. Inside the package are a lot of image files. You can use any tools/utilities that you would normally use for RAR/ZIP files to enter the files and handle the images…
-
1
votes1
answer790
viewsA: How do I use Sqlite in a Cordova application?
There is a native sqlite interface in Cordova/Phonegap cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage.git Example: module.controller('MyCtrl', function($scope,…
-
4
votes1
answer1239
viewsQ: Is there a Java function equivalent to var_dump()?
Does anyone know if there is a Java function equivalent to var_dump()?
-
4
votes1
answer5877
viewsA: How to get a div to automatically scroll down?
Using Jquery: $().ready(function(){ $("#corpo").animate({ scrollTop: 1000 }, 3000); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div…
-
6
votes1
answer1272
viewsA: How to return the index of a matrix and its value in different variables?
There are two functions called: $array_keys = array_keys($array); // retorna só as chaves $array_values = array_values($array); // retorna só os valores Example: $array = array('194800' =>…
-
2
votes4
answers34013
viewsA: How to make a loading screen before opening the site
<div id="content" style="display: none"> Conteúdo da página. </div> <div id="loading" style="display: block"> Loading... </div> // Only for simulated loading delay. var i =…
-
3
votes2
answers340
viewsA: Read only last characters of a LUA string
Read 2 last characters: str = "12/5/2015;00:00:05;90" print(string.sub(s, -2)) Split into 3: str = '12/5/2015;00:00:05;90' for word in string.gmatch(str, '([^;]+)') do print(word) end Placing each…
luaanswered Paulo Costa 3,976 -
2
votes1
answer469
viewsA: I created a registration system using PHP+Mysql then when running asks to replace Mysql with Mysqli... Which ones should I replace?
<?php $host = "localhost"; $user = "root"; $pass = ""; $banco = "dbcadastro"; $conexao = mysqli_connect($host,$user,$pass,$banco); // verifica a conexao if (mysqli_connect_errno()) { echo "Erro…
-
38
votes3
answers1203
viewsQ: Why do parameterized SQL queries (name = ?) prevent SQL Injection?
Why parameterized SQL queries(nome = ?) previnem SQL Injection? Can cite examples?
-
12
votes4
answers82876
viewsA: Not IN or Not EXISTS which to use?
Complementing the above answer. The goal now is to find all employees who are not managers. Let’s see how we can achieve this using the NOT IN and NOT EXISTS. NOT IN SQL> select count(*) from…
-
1
votes2
answers229
viewsA: View how many people accessed pdf
1 phase - collecting accesses and displaying the file // abrir o arquivo através do link do seu servidor $file = 'file.pdf'; // nome do arquivo $filename = 'file.pdf'; /* Nota: sempre use .pdf no…
-
5
votes2
answers520
viewsA: Releasing PHP memory using __destruct
I don’t think so, after all __destruct will be called automatically when all references are released, or when the script ends. Also, if you set as null does not release memory alone, it just marks…
-
2
votes1
answer2122
viewsA: Ask Login for Password
<?php class Authenticator { public static $username = "hugo"; public static $password = "1234"; public static function check() { if ( isset($_SERVER['PHP_AUTH_USER']) &&…
-
1
votes1
answer120
viewsA: Twitter ( php ) - how to get a picture of the user and the email this user uses on the social network
Twitter does not free access to user’s email, soon you will not be able to get that information from the API from Twitter. Instead, you have to get this information on the registration form. // a…
-
8
votes2
answers1839
viewsA: Which one performs better? For or Foreach+Range?
My personal opinion is to use what makes sense in context. The time difference will be minimal in most cases. The great thing to observe is: for( $x=1; $x < 31; $x++ ) This is an expensive loop,…
-
0
votes3
answers2230
viewsA: if/Else condition to mark/deselect checkbox
You can use this function JS: function marcarDesmarcar(source) { checkboxes = document.getElementsByName('foo'); for(var i=0, n=checkboxes.length;i<n;i++) { checkboxes[i].checked =…
-
2
votes2
answers1183
viewsA: Dynamic Link? And how to implement?
The browser only decreases the link to be better readable to the user, but the original link does not change, it is just a way to improve readability.
-
15
votes1
answer3061
viewsA: When to use Interfaces
Interfaces An interface is a contract: the guy writing the interface says: "Hey, I accept things this way here." And the guy using the interface says: "Okay, the class I’ll write will be like this".…
-
2
votes1
answer3288
viewsA: How do you insert complex numbers in Python?
Boolean No format specifier for bool. You can print it using some of the existing specifiers for printing integral types or do something different: Example 1 printf("%s", x?"true":"false"); Example…
python-3.xanswered Paulo Costa 3,976 -
0
votes2
answers1021
viewsA: Display all directories and files contained in them
This one lists everything! Subdirectories, and all files. import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import…
-
8
votes1
answer5624
viewsA: Change selected item color - select > option
Elements SELECT are rendered by the operating system, not HTML. You cannot change this blue color because it is the default OS. "The alternative is to use libraries that customize select, usually…
-
0
votes1
answer83
viewsA: Mysql encoding
Try to make your appointment like this: SELECT convert(campo USING latin1) FROM tabela With more than 2 fields SELECT convert(campo USING latin1), convert(campo2 USING latin1) FROM tabela campo - is…
-
2
votes1
answer4124
viewsA: Export screen data to excel
You can use the Apache POI to create files xls. //Baixe o jar aqui "http://poi.apache.org/download.html" import java.io.*; import org.apache.poi.hssf.usermodel.HSSFSheet; import…
-
16
votes2
answers14697
viewsA: Why does the address of some sites contain number after www?
Yes, it is possible! This is usually done by a process called balanceamento de carga. Load balancing is basically split the load (i.e., requests from sites that in turn require some processing power…
-
1
votes2
answers1127
viewsA: Text slide
$(function(){ /* Aqui ficam as configurações padrões do slide */ $('#slider-id').codaSlider(); /* Se você quiser mudar alguma configuração, pode mudar aqui: $('#slider-id').codaSlider({…
-
0
votes2
answers143
viewsA: How can I apply a style only to one or the other <p>?
.azul{ color:blue } .vermelho{ color:red } <p class='vermelho'>teste</p> <p class='azul'>teste</p>…
-
1
votes2
answers2454
viewsA: Alert when closing the browser
window.location ao clicar em um botão function redirecionar(){ alert("Você será redirecionado"); window.location="sair.php/"; } Or function funcao() { var r = confirm('Quer mesmo sair?');; if (r ==…
javascriptanswered Paulo Costa 3,976 -
1
votes1
answer136
viewsA: How to implement multiple authentication drivers
You can "emulate" a new Auth Class. The Laravel Auth component is basically the Illuminate Auth Guard class, and this class have some dependencies. So basically you have to create a new Guard…
-
0
votes3
answers1551
viewsA: Keep the height of a div block proportional to its width
div { background:red; margin:auto; text-align:center; height: 150px; } #test{ width: 20%; } #test:before{ content:''; padding:50% 0; display:inline-block; vertical-align:middle; } span {…
-
0
votes3
answers23957
viewsA: Calculate values in real R$
Just replace: $("#totalEntrada").append("R$ " + $entrada); $("#totalSaida").append("R$ " + $saida) $("#totalGeral").append("R$ " + $total); For: $("#totalEntrada").append("R$ " +…
javascriptanswered Paulo Costa 3,976 -
6
votes8
answers2700
viewsA: Is it good practice to mix Php and Html?
This may and should vary depending on the tipo de arquivo that you are working. If you follow the padrão MVC, your point should be the last. Try to keep a separação de exibição/formatação de saída e…
-
5
votes1
answer830
viewsA: KEK (Key Encryption Key) what it is and how to use it correctly
Key Encryption key (KEK) Is used by the application to protect (encrypt/decrypt) other keys(e.g. TEK, TSK). An example of use If you have already used TEK and TSK keys to protect something, such as…
-
16
votes8
answers17275
viewsA: Difference between while and for
Here has a scientific article that deals only with this comparison. Moreover, the performance clearly depends on the applying in particular and the compiler of the language used. In C#, FOR is a…
-
11
votes1
answer837
viewsA: What’s the difference between css and javascript animations?
The CSS3, is not yet ready for professional level animations in large scalable projects. For simple things, - CSS3 is the winner, we can’t even argue about it. If you’re looking for animations mais…
-
1
votes2
answers135
viewsQ: Is it possible to add an empty directory to a Git repository?
I wonder if I can add an empty directory to my Git repository? If possible, how to do this?
gitasked Paulo Costa 3,976 -
20
votes4
answers19183
viewsQ: Is it possible to comment on a JSON file?
Can I comment on a JSON file? If so, how?
jsonasked Paulo Costa 3,976 -
6
votes4
answers15428
viewsQ: How do I remove local files(untracked files) from my current branch(branch) in Git?
How to remove these files from my current branch(branch) in Git?
gitasked Paulo Costa 3,976 -
28
votes1
answer39248
viewsQ: How do I undo a "git add" before a commit?
I added by mistake arquivos using the command git add and I haven’t executed one yet git commit. There is a way to undo or remove these files from the commit?…
gitasked Paulo Costa 3,976 -
26
votes3
answers31330
viewsQ: How to edit an incorrect commit message in Git?
How to edit an incorrect commit message in Git? Examples can be cited?
gitasked Paulo Costa 3,976