Posts by Kazzkiq • 11,493 points
136 posts
-
3
votes1
answer486
viewsQ: Is it worth encrypting database?
Recently I’ve been having the curiosity about the utility of encrypting all fields of all tables in a database. The idea is this: Create two Crets (one in the bank and one in the application); The…
-
3
votes2
answers174
viewsA: Smoothing animation in JS
It is considered good practice to use the property transform CSS3 whenever you do some kind of CSS animation. This is because certain properties CSS have their optimized rendering via hardware,…
-
3
votes1
answer154
viewsQ: bash - How to prevent malicious code execution via input?
I own a script (script.sh) who receives a environment variable: echo $MINHAVARIAVEL But when calling it via terminal, I realized that I can pass commands through this variable, and these commands…
-
2
votes6
answers28831
viewsA: How to limit an input of type Number to only 3 characters?
You could make use of the method .substr(): function limitaTotal (evt) { var input = evt.target; var value = input.value; if (value.length <= 3) { return; } input.value = input.value.substr(0,…
-
3
votes1
answer533
viewsA: HTML + CSS - Element position relative to div
You could use top and right instead of left. Example: .ExcluirRelativePosition { top: -10px; right: -10px; /* O botão vai sempre ficar ao final da div */ }…
-
10
votes4
answers1794
viewsA: Node replaces Nginx? Can someone explain this architecture to me?
I will focus on this answer in your second question, since the first (Node replaces NGINX?) falls into a more opinionated field. About the Node.js + NGINX architecture The approach of deploying a…
-
14
votes2
answers2381
viewsQ: What is the difference between static and dynamic linkage?
Recently, searching why small Go codes have a much larger executable than the same C-generated code, I read an answer stating that the reason is because Go use linkage static, unlike C, which uses…
-
4
votes3
answers57
viewsA: THIS object in conflict between jQuery and ECMA6 class
As you are already using ES6, you can make use of Arrow Functions to preserve reference to the this and solve this problem. Example: $('input').each((i, elemento) => {…
-
1
votes1
answer532
viewsA: Pass variables as parameter when loading page
You can generate a JSON in your back-end (PHP) and load it via AJAX on your page through a URL defined by you (which can change according to the ID of the page, user, etc). Example (in its…
-
2
votes2
answers78
viewsA: "Permissive" regular expression to detect extensions and allowed hosts
Another simple way to achieve the same result would be by using the property Array.filter() Javascript native, for example: function filtrarUrls(lista) { var base = 'https://www.exemplo.com'; lista…
-
4
votes1
answer3334
viewsQ: Clone private repository by passing password as parameter
I have a script on my production server that automates the entire process of checking new commits, generating the build and publishing the new changes. It works perfectly with open repositories…
-
13
votes4
answers2497
viewsQ: Merge two Javascript arrays
Imagine I have two arrays: var array1 = ['abc', 'def', 'ghi']; var array2 = ['123', '456', '789']; I can use the function .concat() to join both arrays one after the other, example:…
javascriptasked Kazzkiq 11,493 -
5
votes2
answers1859
viewsQ: Is there a maximum size limit for an HTML page?
Note: This question is not on code optimization. It is known that browsers have a size limit for a URI. There is some kind of limit for requesting/rendering an HTML file? Giving a simple example,…
-
9
votes1
answer200
viewsQ: When and why to use window before functions?
There are numerous predefined Javascript functions that can be used with or without the object window as prefix. Example: window.setTimeout(function() { }); setTimeout(function() { }); What is the…
javascriptasked Kazzkiq 11,493 -
7
votes2
answers16161
viewsA: What types of data exist in Mysql for text?
The type of data you intend to use (TEXT) supports data at most around 65kb. For a reference, the HTML returned from the news portal Globe with. has the size of ~48kb, and the BBC, more than 100kb.…
-
0
votes3
answers2116
viewsA: How to get the index of the button clicked?
As each button is in a row distinct from your table, you can "simulate" its index by adding an attribute to your button when you create it, and then retrieve this index using the function .data()…
-
3
votes2
answers332
viewsA: How to prevent a website from being listed on Google
Searchers use web crawlers to find and index websites on the web. To prevent your site from being indexed, an alternative is to use the metatag: <meta name="robots" content="nofollow" /> In…
-
16
votes4
answers8429
viewsA: How to use template string in Javascript?
Using the calls Template Strings, available as one of the modules of Ecmascript 2015 (ES6) and that should soon enter all browsers (already available in Firefox), you could do so: var user = { nome:…
-
0
votes2
answers131
viewsA: Div disturbs the Link
The element <a> by default has the display type as inline, which allows it to be incorporated into texts and in conjunction with other words. But inline elements do not accept certain existing…
-
3
votes1
answer934
viewsA: Input required attribute does not work after using jquery
You can use the event submit in place of click to send the form, example: $(function(){ $("#ajax").on('submit', function() { $(".btn-submit").attr("disabled", true); }); }); When adding a Listener…
-
1
votes2
answers129
viewsA: Gulp + Bower - How to import Bower installed components for my final project
I don’t use Bower, but the Gulp allows you to designate more than one path to fetch the files where tasks will be performed, so you could do something like: // gulpfile.js // ...…
-
12
votes2
answers613
viewsQ: Dynamically delete multiple lines with PDO?
Let’s say I have a user table (id | nome) and that where they are listed (client-side) i can select several of them and delete them at the same time. How could I do this in a Mysql database using…
-
3
votes3
answers2341
viewsA: Good practices using CSS
One of the Patterns design most currently used in CSS is the so-called WELL. Well, the acronym for "Block, Element, Modifier" is nothing more than using standardized nomenclatures to help a…
-
8
votes3
answers1864
viewsQ: How to return key of object with higher value in Javascript?
Let’s say I have the following object: var obj = {"frutas": 50, "vegetais": 100, "carnes": 150 }; How could I return the key of the highest value item? Example: obj.maxKey(); // "carnes" I tested…
-
3
votes1
answer965
viewsQ: Is it possible to work with a local "community" repository in Git?
Imagine I have a remote repository on Github, but I’d also like to replicate it on a local server, thus allowing my team to work (and share code) even without remote access. And, for example, at the…
-
19
votes3
answers1826
viewsQ: How to calculate PI with "n" decimal places in Javascript?
Using the object Math of Javascript, I can return an PI value with fixed decimal places, example: Math.PI //3.141592653589793 But in case I need (yes, very unusual) calculate the same with more…
-
3
votes1
answer834
viewsA: Problem with clickable area of links in a diagonal layout
His element #header is getting above the #content, which makes only some parts of the squares interactive. A simple adjustment to the property z-index should solve the problem: #content{…
-
9
votes2
answers159
viewsQ: "1-----1-+-1" is a valid integer value in PHP?
I’m testing a PHP value filter function called filter_var(). And a of your filters, focused on values like int seems to accept any combination of numbers, + and -. Example: filter_var("1teste2",…
-
4
votes1
answer3981
viewsQ: How to generate millisecond timestamp in PHP?
The function time() PHP generates a UNIX timestamp in seconds, example: echo time() // 1420996448 But I would like to generate a Unix timestamp also with milliseconds, as I can do this?…
-
5
votes1
answer3981
viewsA: How to generate millisecond timestamp in PHP?
Using the function microtime() combined with round() you can return a timestamp in milliseconds, example: round(microtime(true) * 1000); As the function microtime() by default returns a string in…
-
13
votes1
answer1771
viewsQ: How to perform automatic pull with Git?
Imagine that I have a test environment for a web application, where there is a cloned Github repository that is directly inside the server, and any modification in it already results in a real-time…
-
4
votes4
answers9657
viewsA: How to open a <div> by clicking on a <a> link?
You can use the function .slideToggle() and a bit of CSS, example: function abreFecha(sel) { $(sel).slideToggle(); } #paises { display: none; } <script…
-
25
votes5
answers80372
viewsQ: How to "round" a float in Python?
I have this sum: total = 0.1 + 0.2 print total #retorna 0.30000000000000004 How would I "round" the decimal places and return only the number of places summed? Example: totalA = 0.1 + 0.2…
-
7
votes4
answers8045
viewsA: Create button with icon next to
Version with element only <button>: .facebook { background: #0870E3; padding: 8px 10px 8px 40px; /* 40px = tamanho :before + 10px */ color: #fff; border: none; font-size: 15px; position:…
-
5
votes5
answers1089
viewsA: Problem with <link rel="stylesheet/Less" ... >
It is important to remember that browsers do not understand LESS natively! So just adding the style in LESS format to your page wouldn’t work anyway. To get around this you have basically two…
-
4
votes4
answers10036
viewsA: Apply color to font in element clicked only with CSS
Another way would be to use the attribute tabindex, example: .trabalheSubEsqTitulo:focus { color: red; outline: none; } <div class="trabalheSubEsqTitulo" tabindex="0">Fale Conosco</div>…
-
4
votes1
answer1334
viewsA: float on some element, and div does not track content
You need to clean up the float for the parent element to assume the size of their children with float. There are several ways to do this, but the most modern nowadays would be using something like…
-
2
votes1
answer470
viewsQ: Listen to multiple events in jQuery
Is there any simplified way to make a selector listen to various types of events? Example: $('meu-seletor').on(['click','touchstart','keyup'],function(){ // minha ação aqui }); Currently the only…
-
24
votes5
answers910
viewsQ: Operator "||" in Javascript variables
Recently reading the plugin code, I noticed the definition of variables and objects using the operator || of Javascript. Example: function ola(nome){ nome = nome || "estranho"; return "Olá, " +…
javascriptasked Kazzkiq 11,493 -
2
votes3
answers805
viewsA: Does not add values
You can force the conversion of your variables to numerical by performing a sum that does not change the result of the variable, as in the examples below: var string = "10"; //retorna uma string var…
-
1
votes3
answers4578
viewsA: Create a comic balloon-like div
Another way of doing: .balao { background:blue; position:relative; } .balao:before { content:''; position:absolute; left:-10px; top:0; border-bottom: 10px solid transparent; border-right:10px solid…
-
2
votes2
answers290
viewsA: Center a Div between two others, one at each end
If you don’t have restrictions with older browsers, it’s worth using Flexbox of CSS3: .conteudo { display:flex; flex-direction:row; } .conteudo .meio { flex-grow:1; text-align:center; } .conteudo…
-
3
votes1
answer89
viewsQ: Which hash algorithms are already embedded in PHP?
Recently I was looking for hash algorithms that were not known md5, sha1 and sha2, and that generate smaller hashs than those cited. That’s when I found myself thinking, how can I know which hash…
-
4
votes1
answer89
viewsA: Which hash algorithms are already embedded in PHP?
PHP already comes with a range of hash algorithms available for use, including it has a specific function to show which algorithms are available, the hash_algos(). When rotating this function, it…
-
11
votes2
answers8294
viewsA: Can you change the vertical order of Divs by CSS?
If you don’t have problems with old browsers, you can use Flexbox. Assuming you have a parent element of these three other blocks, it would look like this: .elemento-pai { display: flex;…
-
2
votes4
answers787
viewsA: CSS transparency
You can do this by using pseudo-selectors to simulate a transparent background with CSS only and no extra elements in your DOM: .conteudo:before{ content:''; width:100%; height:100%;…
-
7
votes2
answers6417
viewsA: What are the advantages and disadvantages of generating HTML on the client or server?
Separate HTML or not (front-end) of back-end cannot be considered good or bad practice in a universal way, it depends on the scope of your project, the type of professionals you have at your…
-
30
votes6
answers1117
viewsQ: Algorithm against Brute-force
I’ve been thinking about an algorithm against attacks like Brute-force which, as we have seen in case of iCloud, can generate great headaches if treated with indifference. Initially I thought of…
-
56
votes3
answers8505
viewsA: What is the semantic difference between <em> and <Strong>? Do they replace <i> and <b>?
The tags <i>, <em>, <b> and <strong> end up being mistaken or used erroneously because, most of the time, they have the same type of rendering in the browser (the first two…
-
7
votes2
answers170
viewsA: Problems in PHP call
Avoid mixing server and client languages in the same code This practice makes it difficult to maintain and refreshes your code. Ideally, you separate the layers of code and pass the necessary…