Posts by 13dev • 2,415 points
133 posts
-
2
votes4
answers559
viewsA: Function has screen in real time, hangs the screen with time!
The problem is you make a connection and at short intervals and leave the same open . The most correct thing in this situation would be to use ajax with return of json what consumes less of the…
-
2
votes2
answers189
viewsA: Generate files with all permissions
You can really use the class File after the file is generated String caminho = "caminho/do/meu/arquivo"; final File file = new File(caminho); file.setReadable(true, false); file.setExecutable(true,…
-
2
votes3
answers2326
viewsA: Check if html page exists HTML/Javascript
The simplest of all would be to make an ajax request to check if the page exists: $.ajax({ url: "http://meusite.com", type: "HEAD" }).done(function() { alert('Site existe!'); }).fail(function() {…
-
4
votes2
answers166
viewsA: Bad practice in PHP code
Wow, of course it’s taking that long Then you have the following function: public function getCount_Notas_ByNota($setor,$nota) { // conexão com banco de dados $conexao =…
-
0
votes2
answers166
viewsA: Dynamic completion autocomplete
I think you should do the parse of json received by the function success: function carregarComboSetor( idSetor ){ $.ajax({ url : 'funcao/setor.php', type : 'post', dataType : 'json', data : { acao :…
-
0
votes3
answers134
viewsA: reading return json_encode php with ajax
I don’t think you’re using the variable direction so I removed it, you can always remove functions other than yours, like this: $.ajax({ type : 'GET', url: 'dadosPS.php?ps=direcionamento', dataType:…
-
0
votes4
answers183
viewsA: Pdostatement::rowCount returns -1
To complement the existing answers I will give an example, how you can capture the two classes (PDOException, Exception) in the same Try: <?php try { $stmt = $db->prepare("INSERT INTO…
-
0
votes2
answers501
viewsA: Error in deploy Django/app in Heroku?
In your repository you must have changes that are not yet on the machine which probably leads to this error tries to force the push in this way: git push -f heroku master…
-
4
votes2
answers1169
viewsA: Place border-bottom online table with css
selector :first-child But you will need to use the selector not() to apply to all but the first child: .tab_dados tr:not(:first-child) { border-bottom: 1px solid #D5D5D5; } Or you can simply remove…
-
1
votes1
answer528
viewsA: javascript - Ignore string whitespace
When the name parameter exists these return the following: return results === null ? "" : decodeURIComponent(results[1].replace("/\+/g", " ")); Then that line is to compare the result if it is not…
javascriptanswered 13dev 2,415 -
5
votes1
answer1087
viewsA: How to verify if a String is encoded in Base64?
You can use regular expression to check whether a string is encoded in Base64 or not: ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$ Example: var base64 =…
-
5
votes2
answers1366
viewsA: Discover machine operating system in C
To know if the system is linux or windows can do as follows: #ifdef __unix__ #include <unistd.h> #include <stdlib.h> #elif defined(_WIN32) || defined(WIN32) #define OS_Windows #include…
-
0
votes3
answers1702
viewsA: Create button with border and gradient text
Well first of all, put gradient on edges is a bit difficult, EDITED: made this small example of a button the result is almost identical: a { text-decoration: none; font-family:sans-serif; } input{…
-
1
votes2
answers197
viewsA: Is there a way to collapse all the blocks of code into an eclipse?
Yes exists by default is: Ctrl + Shift + NUM_KEYPAD_DIVIDE. You can change this shortcut to: Window -> Preferences, and look up "Keys" then "Collapse All". And to open all blocks the default is:…
-
1
votes1
answer56
viewsA: View monetary values simply
Use this function always gave me a huge fix for this problem: function format_num(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }
-
2
votes1
answer69
viewsA: Increment even if delete record
You’re taking the number of existing records and adding one more is why it doubles when you remove a record To correct try to do this way, take the id of the last record and sum one more: public…
-
3
votes2
answers722
viewsA: Extract multiple values from a single variable in python
Try to use split() dia, mes, ano = input("Dia.mês.ano:").split('.') print("Dia:", dia) print("Mês:", mes) print("Ano:", ano)…
-
3
votes1
answer111
viewsA: PHP Doubts how to optimize Session
There’s not much you can do about it, But try applying this little script that will save the last requisition, with waiting time, will prevent attacks Ddos // vou assumir que ja tens a sessão…
-
0
votes3
answers130
viewsA: How to perform function once per visitor after loading the site?
I particularly like to wear cookies for this case, example: function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c =…
-
0
votes3
answers655
viewsA: Lateral alignment of Divs
So resolve, here appears misaligned because the width of the page is small: form { width: 400px; padding: 1em; border: 1px solid #CCC; border-radius: 1em; background-color: #f2f2f2; overflow:…
-
1
votes1
answer256
viewsA: How to dynamically pass the input name to Jquery
Creates a object and passes keys with the value you want in this case the input name , and in the ajax raisins the object whole; $('.myinput').on('blur', function(e) { var name =…
-
3
votes2
answers137
viewsA: Image on a text
I just made this little code and I think this is what you say: $("#texto").hover(function () { $("#image").css('display', 'block'); $(this).mousemove(function(e){ $("#image").css({left:e.pageX + 15,…
-
3
votes2
answers373
viewsA: Remove spaces from a String array
in the java-8 you can just do it this way: String[] resultado = Arrays.stream(meuArray).map(String::trim).toArray(String[]::new); Or you can make this version more "dirty" without creating a final…
-
1
votes1
answer67
viewsA: Single download page for each user
I think you should use a database and it wouldn’t stop you from anything (in my view of the problem) For this to happen you only have to make a simple 1-to-many ratio (because 1 user can have…
-
0
votes1
answer50
viewsA: Closing app on android 6.0
I always wear it like this and it always works: <a href="#" onClick="fechaMe();" data-role="button">Fechar App</a> Javascript function fechaMe() { navigator.app.exitApp(); }…
-
2
votes2
answers70
viewsA: Insert php field concatenating date
Simple with a function, in the variable code the code you want will be saved and then you can enter the code in the database: Obs the id is from the database and as it is a code I suppose it should…
-
1
votes1
answer27
viewsA: Check an obj json option and return
The javascript already provides the function filter: var normal = alerts.filter(function( obj ) { return obj.color == "green"; }); and for Attention: var attention = alerts.filter(function( obj ) {…
-
2
votes3
answers228
viewsA: Doubt Warning in Javascript
That’s because your button must have some hyperlink or Submit to leave the current page which makes sense. To solve this problem just undo the function onbeforeunload at the event onclick button:…
-
1
votes1
answer25
viewsA: PHP Add Records to MYSQLI for all USERS
This is a practice! , you should wear mysqli Prepared statements or PDO, so your application is vulnerable to various types of attacks! the problem is you were trying to convert a array for string..…
-
0
votes2
answers307
viewsA: How to create an exception in htaccess for locking folders
inside the archive .htaccess you may have this solution with error page: ErrorDocument 403 /error403.html #apresenta pagina se não tem permissoes Order Allow, Deny Allow from 127.0.0.1 # ip do teu…
-
2
votes1
answer226
viewsA: How to check if json is an object
So if nay you want an array in the property Authentication, Not you can do this: echo $obj->Autenticacao[0]->login; Because you’re trying to access it in the form of array that does not exist…
-
1
votes1
answer124
viewsA: Returning External Array when Retrieving Data with Laravel
Try to use Pluck method native of the Arable, it would look something like: $clubes = Socios::where('socio', $socio)->pluck('clube'); if you want in array form just add toArray(): $clubes =…
-
0
votes3
answers499
viewsA: Concatenate Javascript with PHP
The problem is that you don’t need to escape the quotes even because to space them is with \ and at the same time are concatenating outside the PHP Enough like this: <button onclick="return…
-
0
votes2
answers857
viewsA: Incorrect Background Image on Iphone
Try the following code, it worked perfectly on my application html { background: url(http://placebear.com/1200/800) no-repeat center center fixed; background-size: cover; height: 100%; overflow:…
-
2
votes1
answer1293
viewsA: Mode to translate website automatically
Me Particularmente like this systemZito, It’s simple and you can do a lot of things with it! you can define the language by $_GET, ie is by url You can have as many languages as you need, and it’s…
-
2
votes1
answer5104
viewsA: Fatal error: Uncaught Error: Call to a Member Function query() on null in
Try to use dependency injection in class Usuarios , would look something like: <?php class Usuarios { /** @var \mysqli */ protected $conn; public function __construct(\mysqli $conn) {…
-
0
votes4
answers2232
views -
2
votes2
answers10715
viewsA: Simplest way to generate a PDF of an HTML, client-side input
The simplest I’ve ever used was supposedly jsPDF!. I think jsPDF fits perfectly into what you need Look how simple you can generate a PDF with so little code: //Tão simples var doc = new jsPDF(); //…
-
1
votes3
answers895
viewsA: Return Id’s That Are Not in Database - MYSQL
Try using this query, if you want to read more here you have link SELECT a.id + 1 AS start, MIN(b.id) - 1 AS end FROM minha_tabela AS a, minha_tabela AS b WHERE a.id < b.id GROUP BY a.id HAVING…
-
0
votes3
answers115
viewsA: Problem in the price formatting function
This job of yours is a disaster, with a line you can do that, I would suggest you use this one, it always came in handy: function formatNumber(x) { return…
javascriptanswered 13dev 2,415 -
2
votes4
answers774
viewsA: Concatenate variables from an array
The best solution to your problem would be to use the function implode() example using implode(): if(count( $array ) == 1) { $str = implode("+", $array); }else{ $str = $f1 . "+" . $f2; }…
-
3
votes2
answers44
viewsA: Allow only delete key
Yes, you can do it this way $(".readonly").keydown(function(e){ if( e.keyCode !== 46 ){ // 46 é tecla delete e.preventDefault(); } });
-
2
votes3
answers590
viewsA: How do I know if one string contains another?
Just use Contains var Value1 = "ddabcgghh"; if (Value1.Contains("abc")) { [..] } To check with a List try the following: foreach(string item in minhaLista) { if(item.Contains("ABCABC")) return item;…
-
3
votes1
answer822
viewsA: Echo respecting mysql line break
Try using the function nl2br() PHP documentation: nl2br - Inserts HTML line breaks before all newlines in one string Changes to the following: <?php echo nl2br($row['descricao']); ?>…
-
2
votes2
answers266
viewsA: Apply FILTER_SANITIZE or real_escape_string to all fields of a json
For this question I decided to do a small function, which only works if the json is only 1 degree but solves the situation well. OBS the variable is passed by reference which means it will be…
-
1
votes3
answers94
viewsA: How to reference the first loop from the second in a chain of loops?
Try it like this, it should work if ($j == $i) continue 2; In the PHP manual: continue accepts an optional numeric argument that says how many nested loop levels must jump. The default value is 1,…
-
3
votes1
answer145
viewsA: Add PHP log to Mysql database
I’ll try to give you a little help First First of all design your database so that in php it is easier. 2nd Second Already with the database thought create your connection file (Connect.php) I leave…
-
2
votes2
answers116
viewsA: Invalid argument foreach() return empty message
Just check if index exists this way <?php if(isset($arrayReturn['qsa'])): ?> <?php foreach($arrayReturn['qsa'] as $value): ?> <tr> <td>NOME:</td>…
-
2
votes2
answers235
viewsA: Background-position is not working
I solved it very simple how you were rendering the image width was conflicting so just add: aside h1{ display: block; margin: 0 auto; } aside { height: 100vw; background-color: #fff; border-right:…
-
4
votes3
answers1519
viewsQ: What is 'final' in PHP?
I was at Github and I came across a class this way: final class Noticia { [...] } What use is this final reserved word? -Can only be used in classes?…