Posts by Gabriel Gartz • 5,624 points
78 posts
-
2
votes2
answers340
viewsA: Modules vs Classes in Javascript
Before ES6 introduced class syntax in Javascript, there was a great discussion of what would be the best way to simulate this behavior of object-oriented languages in Javascript which is a language…
-
13
votes1
answer545
viewsQ: How does ES7 async/await work?
ES7 allows you to use a new syntax to work with Promises known as async/await functions. How I can use these functions and how they are compared to functions that use Promises to process sequential…
-
12
votes1
answer545
viewsA: How does ES7 async/await work?
The syntax of functions async are converted to Promises Javascript natives, making it compatible with existing implementations. To illustrate I will leave here two Promises that I will use: //…
-
5
votes2
answers164
viewsA: Check if a value exists but print another
What’s wrong with your code is that you’re trying to put a PHP tag inside a echo which is already a PHP print command. <?php if(!$this->seo_tags->spam) { echo '<span…
-
1
votes1
answer23
viewsA: Convert date with offset
You can calculate using Unix Timestamp that makes it very simple, for example: function horasDeslocamento(date, horas){ return new Date(date.getTime() + (horas * 60 * 60 * 1e3)); } Now you can use…
javascriptanswered Gabriel Gartz 5,624 -
4
votes1
answer248
viewsA: How to convert this derivation code into PHP for Javascript
To convert this PHP code to Javascript it doesn’t take much if you already have the lib to SHA1, just change the syntax and add the following function to your code: function substr(str, pos, len) {…
-
4
votes2
answers528
viewsA: setTimeout not executed in loop(each)
Knowing @bfavaretto I know that he used a didactic way to solve the problem and explain in a simple way how JS works. I will try to be a little more technical here I directly answer the question of…
-
3
votes2
answers6847
viewsA: How to avoid abrupt page breakage when printing an html table
You can use styles to prevent this behavior: <style type="text/css"> table { page-break-inside:auto } tr { page-break-inside:avoid; page-break-after:auto } thead { display:table-header-group }…
-
1
votes4
answers182
viewsA: Error javascript if
You’re comparing two different types of variables. Even though it is not a strict comparison, it will fail because they are not equal. == normal comparison, ex: 1 == true // verdadeiro === strict…
-
17
votes1
answer11808
viewsA: How does parseFloat()' function work?
In the example you gave, parseFloat is doing nothing because you are passing integer values into it. It serves to convert string in a floating point number value (boxes after the comma in…
javascriptanswered Gabriel Gartz 5,624 -
2
votes5
answers844
viewsA: What is the shortest and most performative way to write Fibonnaci in Javascript?
The shortest ways I got were: Recursive function: function f(n){return n<3?1:f(n-1)+f(n-2)} In case I am using direct return and applying a conditional operator to test if the value is less than…
-
10
votes5
answers844
viewsQ: What is the shortest and most performative way to write Fibonnaci in Javascript?
Javascript is a language that allows you to write the same thing in several different ways. The best answer should describe the syntax resources used to reach the goal which is a shorter function…
-
6
votes5
answers22471
viewsA: How do anonymous functions work?
Functions Anonimas they do not have an identification in the javascript execution scope, but can be assigned to variables, gaining access only when this variable is accessible. Example:…
-
77
votes5
answers86551
viewsA: Upload a file with AJAX
You can upload files using the method POST but shall include the Formdata with the property enctype defined as multipart/form-data for your files to be sent in the request. However, sending…
-
20
votes6
answers14122
viewsA: How to simulate a higher resolution screen to check the behavior of a website?
In the browser Chrome and Firefox there are options in the development tools that already come native with browsers to work with specific resolutions. Below are the tutorials on how to activate such…
-
11
votes4
answers1700
viewsA: Understanding Node and Applications in Real-Time
I have worked many years with PHP, today I work a lot with Python, Nodejs and Nginx. I have a slightly different point of view from those presented so far. Node replaces Apache and I have to choose…
-
20
votes1
answer3182
viewsQ: What is and how does context (this) work in Javascript?
Essential part of Javascript, every function has context (this). How it works, how to manipulate it and what changes in strictly speaking ('use strict')?…
-
9
votes3
answers267
viewsA: Have some problem playing the function for variable
In Javascript you can reference a variable to a function without problems. However the behavior will be different depending on the cases. Appointed function: When you define a named function…
-
8
votes4
answers1082
viewsQ: How to verify that the properties of the window object are native?
I’m using Shim that modifies several of the properties in the window object of browsers. At this point I need to validate whether one of the specified properties is native or a Shim. Because Shim…
-
11
votes2
answers424
viewsA: What forms of data transfer are available to Javascript?
There are several Apis that will allow you to carry data via Javascript. Some will only allow you to receive data, others will allow you to send and receive. Those that allow you to send and receive…
-
5
votes2
answers21001
viewsA: How to resolve java.net.Unknownhostexception error
I figured out how to fix the bug. In case the application is starting a host using the machine name localdomain and trying to access it by name, as this name has no related IP it is giving this…
-
3
votes2
answers21001
viewsQ: How to resolve java.net.Unknownhostexception error
I’m trying to install the sqldeveloper and datamodeler in my Fedora 20 and I’m having trouble with following error: java.net.UnknownHostException: localdomain: localdomain: Name or service not known…
-
3
votes2
answers1480
viewsA: What is the function of operators <<, >> and >>> in Javascript
The operations of binary displacement function by moving in a binary representation of the number. For example the value 2 0010 or 3 0011 when shifted to the right form the value 1 0001 because the…
-
16
votes2
answers1480
viewsQ: What is the function of operators <<, >> and >>> in Javascript
What is the function of mathematical operators <<, >> and >>> javascript? Examples: 0 or 1 >> 1 is 0 2 or 3 >> 1 is 1 4 or 5 >> 1 is 2 Same goes for negative…
-
20
votes4
answers6604
viewsQ: How to extract a file extension in Javascript?
There are some cases where I need to capture a file extension (that is, a string with the file address) in order to validate the extension via Javascript. For example of location: var path =…
-
22
votes4
answers6604
viewsA: How to extract a file extension in Javascript?
To get the file extension in a practical way use: var ext = path.split('.').pop(); In case the split divided the path into an array and the pop will remove and return the last element of this array,…
-
3
votes1
answer77
viewsQ: What is the difference between the Requirejs PATHS and MAP properties
In theory it seems that the two configuration properties of the Requirejs has as its focus the same action. Does anyone know the differences of how both settings work? PATHS: require.config({ paths:…
-
1
votes2
answers244
viewsA: Jquery iframe transport plugin works on IE10 cross Domain
Upload data via IFRAME to circumvent CORS when there is no possibility of a JSONP, it is a frivolous solution. In the specification browsers must block this type of feature allowing only if the site…
-
2
votes3
answers629
viewsQ: How to capture innerHTML from a documentFragment via Javascript?
The documentFragmentwhich is created using the document.createDocumentFragment() does not contain the properties innerHTML and outerHTML equal elements derived from HTMLElement has. But I need to…
-
10
votes3
answers4291
viewsA: What is the best way to select an option by the text and not by the value in jQuery?
In this case I would use the filter of jQuery which will return the first result it meets with the definitions of the function you determined. Example: $(document).ready(function () { // Armazena…
-
10
votes6
answers3344
viewsQ: How is an agile way to add and remove code comments in VIM?
I don’t want to remove the entire line of code in VIM, what I want is to work with the comment codes. I have 3 purpose cases: Comments with which open and close (usually multiple lines): /*…
-
0
votes5
answers213
viewsA: CSS Child selectors on IE8?
It is not a "lightweight" solution but there is a project that creates a Polyfill for IE8 to have more complete CSS3 support. Selectivize By native IE8 does not support both its "querySelector" and…
-
0
votes3
answers1343
viewsA: Empty multiple tables in a single run
There’s no way you can run a truncate for several tables, because there can be different triggers and different responses for each table and there would be no way the database would test the…
-
2
votes2
answers1082
viewsA: jQuery function with fancybox - I’m having refresh problem
Looking at your site, as there is a position reference using the address bar more specifically the area of hash of window.location what happens is that when you enter your fancybox it ends up…
-
1
votes7
answers3042
viewsA: Hide input value
Since you are using jQuery can write code this way: $(document).ready(function () { // armazena valor $('.pesquisa-class').get(0).defaultValue = $('.pesquisa-class').val(); // limpa valor…
-
2
votes5
answers21918
viewsA: How to replace the <img src> of a small image with a large image?
An easy way to solve your problem is to use Regular Expressions to change the image address without having to modify your code a lot. Example to find file name which is a number followed by .jpg:…
-
3
votes1
answer179
viewsA: How to list available events in an element in IE8?
I discovered, in fact IE8 it only makes a list in the debugger of properties recognized by it as an event, but these are all properties of the object’s own context. So to list the events available…
-
3
votes1
answer179
viewsQ: How to list available events in an element in IE8?
I’m making a Shim/polyfill to work with CustomEvents for IE8, but I’m having a problem detecting when the event is not standard. In IE8 each element can have a different list of available events,…
-
3
votes3
answers2718
viewsA: Javascript/Nodejs setInterval with programmed start, simple cron style
A simple cron script, I just made some fixes in the original code to work. /* Copyright (C) 2009 Elijah Rutschman This program is free software: you can redistribute it and/or modify it under the…
-
1
votes2
answers351
viewsA: How to Interact Javascript + jQuery with CSS
If you are wanting to add your formatting to a specific tag in your HTML, it would be something like this: $(document).ready(function () { $('font').addClass('codigo'); }); This will add your code…
-
9
votes5
answers18134
viewsA: Using jQuery, how to select elements with two CSS classes
In case it’s just div with .box1 and .destaque: $('div.box1.destaque'); In the order of selectors, the first can be the desired element, in the example div then you will specify some features of the…
-
2
votes2
answers7683
viewsA: How to upload images to a folder using ASP Classic?
In classic ASP you have no way to access the method Request.Form directly when you are receiving from a post with type multipart/form-data, then to interpret the data, it is necessary to parse the…
-
2
votes3
answers2806
viewsA: How to Change Windows Variable Records
It is possible using native windows application called reg.exe via command line. Reg.exe official documentation. Examples of use: Consulting: REG QUERY HKLM\Software\Microsoft\ResKit /v Version //…
windowsanswered Gabriel Gartz 5,624 -
1
votes3
answers2806
viewsQ: How to Change Windows Variable Records
It is fact that by programming for Windows, it is possible to store local variables, or in the environment, which in case are saved in windows records. How do you make change the windows registry…
windowsasked Gabriel Gartz 5,624 -
5
votes6
answers53653
viewsA: How to change PATH in Windows
Can be changed modifying the system record in all versions of Windows, this way making up permanent the change. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session…
-
2
votes6
answers53653
viewsA: How to change PATH in Windows
Windows 8 Drag the mouse pointer (Mouse) to the bottom Right corner of the screen Click the Search icon and type Control Panel Click -> Control Panel -> System -> Advanced Click Environment…
-
1
votes3
answers1621
viewsA: Is it possible to move Nodejs modules to be used offline?
Reading the comments, I understood something else, that the user who install packages Node offline and does not use them in the browser. As the previous answer proves useful to other users I will…
-
7
votes6
answers53653
viewsQ: How to change PATH in Windows
I wonder how I can change the variable PATH in the Windows environment. I am a linux user but I know that windows also allows the use of this environment variable to find its executables.…
-
2
votes3
answers1621
viewsA: Is it possible to move Nodejs modules to be used offline?
In the browser there is still no way for you to use the function require on Ode, so this is very important for understanding this issue. The staff of Commonjs documented some possible ways to work…
-
17
votes3
answers1400
viewsQ: What are the ways to apply Eval in Javascript
There is more than one way to make one eval() in javascript, problem is that it can be a danger for the user if misused. Internally some other methods also do Val, for example the setTimeout() which…