Posts by cantoni • 6,602 points
149 posts
-
3
votes2
answers608
viewsA: Show zero in group by SQL Server
There is a very interesting and generic solution for these cases, where you want to display values that do not exist in the database. Values where JOINS do not solve, since there are no records in…
-
5
votes4
answers456
viewsA: Memory allocation for pointers
The pointer is a variable like any other, but it stores a memory address that references another place of memory where the content is. Examples: in C: int * a = malloc(10 * sizeof *a); in C++: int *…
-
1
votes1
answer3127
viewsA: Share virtual machine VPN connection with real machine
As stated in the comments, my problem was different from the one reported, because in my case, the VPN connection is on the real machine (host) and I need to share with a virtual machine (guest). I…
-
7
votes6
answers1655
viewsA: Heritage and Polymorphism
It all depends on how you map this heritage in the database. Basically, there are two options. The first consists of using a single table for the entire class hierarchy. The second uses a table per…
-
0
votes1
answer472
viewsA: Excel Convert Rows to Columns
Considering that everything is standardized, that is, that all contacts have all fields (NAME, SURNAME and PHONE), there is a very simple and fast solution. My explanation will be based on the image…
-
1
votes3
answers3464
viewsA: Average between 3 direct dates in sqlserver bank?
The SQL below performs the requested operation. It averages days between the dates of the last three purchases, called here A,B,C. Being A the oldest of the three and C the most recent of the three.…
-
0
votes2
answers1552
viewsA: SQL query with array type in Postgresql
One option is to use ANY or SOME (actually, SOME is an alias for ANY). SELECT * FROM X WHERE 'lunch' = ANY (Y)
-
3
votes1
answer366
views -
4
votes1
answer618
viewsA: SQL 2012 - replace (nolock) with(nolock)
Attention: Make a backup before your database. Ideally run this on a test basis. By SQL Management Studio graphical interface: Right-click on the database you want; Select the option Generate…
-
9
votes3
answers8471
viewsA: Is a subquery in SELECT calculated for each result or just once?
I believe that this question needs to be better explored. There is no general answer, as it depends on the implementation of each database engine. SQL is declarative. You say what whether and not as…
-
7
votes2
answers1683
viewsA: Convert a collection from Set to List type
Use the List.addAll() method. Like this: List<Object> list = new ArrayList<Object>; list.addAll(set); The addAll method accepts a Collection and every Set is a Collection.…
-
7
votes3
answers7920
viewsA: What is the difference between "git init" and "git init --Bare"?
What is: By initializing a repository as Bare you won’t be allowed to edit files (git add) and commit changes (git commit), since it doesn’t have a Working Tree. You should update a Bare repository…
-
5
votes2
answers1506
viewsA: What is the difference between assigning and comparing string variables with function or with assignment and comparison operator?
Since a vector is an element that occupies contiguous positions in RAM memory, it is sufficient to store the memory address of the first position of the same. The rest can be obtained by basic…
-
0
votes2
answers79
viewsA: Repeating code at listing time
Replace the following code snippet: requisitoFuncional.setStrNumRequisito(this.getStrNumItemAtual(i)); for String aux =…
-
1
votes1
answer59
viewsA: SQL JOIN - Build according to base
Based on the question and comment, I believe the doubt is in using INNER JOIN with LEFT JOIN in a Query only. This is possible and common. Below is a possible SQL based on the model and that uses…
-
1
votes1
answer493
viewsA: How to convert HTML code to a PDF file in java?
I do exactly that in an application developed with the Grails framework. I use a plugin called Rendering which in turn uses a Java library called Flying Saucer. I could post an Example in Grails,…
-
5
votes1
answer1243
viewsA: Pass multiple parameters to an SQL query
This is happening because your code field is BIGINT and you are trying to pass this value to it: "65568752877, 86924355382, 55317961378, 82331493146" This value cannot be converted to BIGINT, since…
-
2
votes2
answers111
viewsA: Combining column value with Mysql
I ran a test on SQL Server (for Mysql to see the end of the answer) with two versions, one with the type fields int and one with the guy bit. The version of the type int worked normally. I’ll leave…
-
3
votes3
answers747
views -
3
votes4
answers13678
viewsA: Rounding a decimal to a lower decimal
If you want x houses after the comma, you can do so: function arred(d,casas) { var aux = Math.pow(10,casas) return Math.floor(d * aux)/aux } Then simply call the function. Examples:…
-
5
votes3
answers1786
viewsA: What is the usefulness and importance of "do... while"?
Already do...while has verification at the end, ie the code of the... repeat structure is executed at least once. You answered it yourself. The do...while exists when we want to execute the code…
-
1
votes2
answers176
viewsA: As foreign key reference alternating tables
By the model presented, you will always have to provide a status, since ID_ESTADO is NOT NULL. I, in your case, would create a state called SEM_ESTADO or NA (NOT APPLICABLE) for each country, so it…
-
1
votes2
answers1512
viewsA: Convert a date and send to the bank
If in your textfield the date is in the dd/MM/yyyy format, then you must build a Simpledateformat-like object with this format, like this: SimpleDateFormat in = new SimpleDateFormat("dd/MM/yyyy")…
-
5
votes1
answer2466
viewsA: Update in date field updating calculated field
Your problem is not with the calculated fields, but with the format of the Date and the language of your database. In the question example, the Update in the Dtbehaviours field is: DtComportamento =…
-
2
votes3
answers775
viewsA: Is it possible to mount a server that works from my computer?
The short answer is: Yes. It’s perfectly possible to make that happen. You don’t need any specific application like Apache. All you need is a router, know your Public IP and redirect, on your…
-
4
votes2
answers90
viewsA: Error with Java arrays
Change this: String x = entrada.next(); therefore String x = entrada.nextLine(); Your code is not working because next() returns the next complete token. In this case, the first number before the…
-
3
votes1
answer260
viewsA: Incorrect information when loading bigdecimal entity
There is nothing incorrect. It turns out that 0.0000000000 is being represented by the scientific notation when viewed by debug. Anyway, this will not cause any errors, since it is only a…
-
2
votes1
answer1118
viewsA: VBA Excel - Change Cell between True and False
The problem is occurring because the code runs at two different times. As the variable changes is local, in the 2nd execution the value that was attributed to it, in the 1st execution, is no longer…
-
6
votes1
answer1949
viewsA: How to split a string`and then convert to int?
Some considerations regarding your code: You do not need to declare and instantiate a vector to receive the return of Split. Split itself already instance and returns an array of type String to you.…
-
0
votes2
answers1837
viewsA: Group column sum by quarter
The syntax below works on SQL Server, you could easily adapt it to MYSQL, the important here is the concept: select sum(case when month(data) in (1,2,3) then ifnull(det.quantidade,0) else 0 end)…
-
1
votes1
answer1201
viewsA: I must not show negative results
The expression that calculates PRECO_DIF can be simplified to: B.PR_PECA_ORIGINAL*(B.QT_PECA + B.VL_ICMS - FN_RETORNA_QTD(B.CD_PECA_APLICADA, M.BOOK_NO, M.PAGE_NO)) This shows that it is not enough…
-
1
votes1
answer221
viewsA: How to join files into folders, based on their prefixes?
Solution in Groovy language 2.4.4 Download Groovy: http://www.groovy-lang.org/download.html Java must be installed for Groovy to work. def folders = new File("/home/cantoni/Documents/Teste") def…
-
2
votes2
answers941
viewsA: Script or command to sum all directories and show full size
Do so: for i in $(cat lista.txt); do pastas="$i $pastas";done; du -hcs $pastas Explanation: in the loop, a variable called folders which is the attention (with space) of the directories contained in…
-
7
votes4
answers8564
viewsA: What good is a gists on the github?
Gists can be used to share snippets of code, an entire file, or even entire applications. They are widely used to share snippets of code (known in English as snippets). Imagine you have some piece…
-
3
votes1
answer270
views -
12
votes2
answers673
viewsA: When and in which columns should indexes be used?
The importance of indexes Imagine searching a word in a dictionary that is not ordered. Worse than that, imagine searching in a dictionary where words are randomly arranged. In the worst case…
-
0
votes1
answer2459
viewsA: VBA - excel does not recognize comma of external data
I don’t know this application (ESS), so it is difficult to help you in a more specific way. However, exsite something generic that you can do and that will most likely solve your problem, you will…
-
1
votes1
answer1011
viewsA: Problem importing text file via VBA
You should not use Commandtype for importing text files, as is the case for you. See Microsoft Translated Help: You can set the Commandtype property only if the value of the Querytype property of…
-
1
votes1
answer311
viewsA: Permission to shutdown now!
One of the alternatives is to edit the file /etc/sudoers and to include in this file the following line: user host = (root) NOPASSWD: /sbin/shutdown Where: user = user you want to give permission to…
-
4
votes1
answer7019
viewsA: Receive vector size
The array size can be obtained using the function Ubound. Note, however, that this function does not return the vector size, but the last accessible index. See the example below: Sub teste() Dim…
-
3
votes1
answer369
viewsA: Is it possible to prevent Wine from getting viruses? or is it already immune by running on Linux and Mac?
The answer is no. Using Wine does not make you immune to viruses. Any type of malware is code running on your computer and they can yes run on Wine. There is a page on the Wine Wiki showing what can…
-
1
votes3
answers11070
viewsA: BATCH SCRIPT - Automating website login
I believe that the most appropriate solution to your problem of automation of tasks related to a browser is to use tools made exactly for this. One of the best known is iMacros. It has plugin for…
-
1
votes1
answer304
viewsA: Sql Groovy, pass the value of an IN parameter
One way to solve this problem would be the following: def pessoaIds = [1, 2, 3, 4, 5] def inSql = "" //Monta uma variável String que será os itens da lista //pessoaIds separadas por vírgual…
-
2
votes2
answers1047
viewsA: Application separate authentication server
Consider using the CAS Central Authentication Service Basically, CAS is a Java application to which you delegate the authentication service. It integrates, for example, with Active Directory,…
software-architectureanswered cantoni 6,602 -
0
votes2
answers84
viewsA: Error accessing pointer
I see no sense in you declaring a variable as a pointer and fixing the size of the vector statically (i.e., in the variable’s own statement). Instead of doing this: int ** items[5]; You must do…
-
2
votes1
answer333
viewsA: How to install Imagemagick in windows 7 [ 32 bits ]?
For Windows 7, 32 Bits, use the following installation: Imagemagick for Windows 32 Bits Install normally, with the default options. After installing, go to Windows console (cmd). Type the following…
answered cantoni 6,602 -
4
votes3
answers621
viewsA: Service to resize uploaded images to a Wordpress site
According to the comments described in the question, I understood the problem and I believe that an interesting solution is to use Imagemagick, because of that I created this answer. There is…
-
6
votes2
answers4619
viewsA: Tic-tac-toe - Implement logic
since it is a school work, there is no more opportune time to learn. Some suggestions regarding your code: 1. Separation of Reponsabilities I’ve noticed that there’s still no business logic in your…
-
4
votes3
answers1760
viewsA: Performance issues using UPDATE
You should consider operations done in Bulk (batch) as discussed in this reply in English. Basically, you create a temporary table and populate it via Bulk. Once done, you update your table by doing…