Posts by Felipe Avelar • 9,507 points
190 posts
-
6
votes2
answers7137
viewsA: What does KWARGS in Python mean?
In fact, as can be seen in Soen’s reply, the question is more related to the syntax of an asterisk and two asterisks. When you use two asterisks, you will pass one dict, as you yourself quoted. The…
-
7
votes1
answer3608
viewsA: Run Python file with arguments
To run a script as bat or directly from the console, simply put the following command: python arquivo.py [arg1 arg2 ...] Remembering that in the case of Windows, the folder in which python is…
-
4
votes8
answers794
viewsA: Mapping an array with possible subarrays as elements
What you want to do seems to be a flat. For that just do the following: function flat(arr){ var ret = []; for(var i = 0; i < arr.length; i++){ if(arr[i] instanceof Array){ ret =…
-
3
votes3
answers392
viewsA: Why in Python can we define an index of a Dict as a Tuple?
To access, we only use the tuple as key, following his example: print test[(1,2,3)] #Isso retornará ('um', 'dois', 'tres') The usefulness of this will depend on its implementation. For example,…
-
3
votes2
answers533
viewsA: Create a type corresponding to a playing card
Man, in my conception the ideal would be to create a class Carta, class Baralho containing a vector of 52 cards and two enums, one for Suits and one for Valor. Within the Deck class, you would have…
c#answered Felipe Avelar 9,507 -
1
votes2
answers123
viewsA: Destroy multiple sliders at once
Based on your comment, I’m going to make a change that might solve your problem by putting this code inside your if: while($(".owl-carousel-linhas").length > 0){…
-
23
votes2
answers3644
viewsQ: What is the use of using?
My question is about the difference between: //Bloco 1 using (var memoryStream = new MemoryStream()) { //código } //Bloco 2 { var memoryStream = new MemoryStream(); //código } Deep down they seem to…
c#asked Felipe Avelar 9,507 -
2
votes1
answer94
viewsQ: How to fire an event when a List is changed?
I wanted to know if it’s possible and, if so, how to trigger an event when a List shall be amended as follows:: An element is removed; An element is added; An element has its index changed; Is there…
c#asked Felipe Avelar 9,507 -
0
votes1
answer379
viewsA: Unity 5 : Animator: I can’t delete.
I imagine you are following a tutorial of Unity 4, in Unity 5 it is impossible to delete these states.
unity3danswered Felipe Avelar 9,507 -
2
votes1
answer70
viewsA: For x in range(y) does not return right
He will always enter the else because you don’t have any break. The Else for for for works as follows, if the condition you want is satisfied, leave with the break, otherwise it will perform the…
-
1
votes1
answer49
viewsQ: How to stop a pivot when the Holding event is triggered?
I’m hoping that when the event Holding is fired, I can block the movement of my pivot. I’ve tried using the properties IsEnable and IsHitTestVisible, however I can still accomplish the Swipe during…
-
1
votes1
answer17
viewsA: How to use the Useoptimizedmanipulationrouting property?
After researching a lot, I discovered that this property is not present in Windows Run Time, only in the Silverlight. It is therefore not possible to use this property in Run Time applications.…
-
1
votes1
answer17
viewsQ: How to use the Useoptimizedmanipulationrouting property?
I’m trying to use the property UseOptimizedManipulationRouting in a GridView, however, when I try to adjust it to False, it is returned that Gridview does not possess such property, despite of that…
-
9
votes3
answers31330
viewsA: How to edit an incorrect commit message in Git?
Just perform a --amend: git commit --amend It will open the text editor with the last commit message and you can update the message.
gitanswered Felipe Avelar 9,507 -
3
votes1
answer95
viewsA: Cryptography does not read spaces
The problem is that the operator >> eliminates all blank spaces (line breaks, spaces, tabs). That is, in the case you are only taking the first word, up to the space. The ideal would be to…
c++answered Felipe Avelar 9,507 -
9
votes1
answer12600
viewsA: How to remove python-installed packages
As can be seen in that SOEN response, you need to remove the files manually. If you do not know what these files are, you can use the parameter --record during the setup to list these files, as in…
-
3
votes3
answers4053
viewsA: How to add list values in tuples?
You can do something like: x= [('y', [1, 2]), ('y', [3,4]), ('y', [5, 6])] soma = [0]*2 for t in x: soma[0] += t[1][0] soma[1] += t[1][1] print soma This will return: [9,12] Edit To fit the answer…
-
14
votes5
answers31170
viewsA: What are Try/Catch Blocks for and when should they be used?
Blocks of try/catch are blocks to treat exceptions that the programmer has no way to predict that will happen, runtime errors, that there is no way for the programmer to control, as for example, the…
-
2
votes1
answer117
viewsQ: Editing Exif of an image
I need to edit the information exif of an image, such as location and date, for example, but I’m not able to find any library that does this with Python 3.4 and Windows. The most I got was using…
-
2
votes2
answers1044
viewsA: How to invert the values of the main diagonal of a 5x5 matrix?
I prefer to go only once the following way: int TAMANHO_MATRIZ = 5; for(int i = 0; i<TAMANHO_MATRIZ/2; i++ ){ int aux = Matriz[i][i] Matriz[i][i] = Matriz[TAMANHO_MATRIZ-i-1][TAMANHO_MATRIZ-i-1];…
-
6
votes1
answer1843
viewsA: How to add string numbers
You can do the following if the string contains only numbers: sum([int(x) for x in a]) This line creates a list of string characters converted to number and then sums each element of the list.…
python-2.7answered Felipe Avelar 9,507 -
5
votes1
answer858
viewsQ: How to work with environment variables?
I am developing an application that works with files (save and upload) and have to work with system variables to determine where to save these files. My question is: Is there any way to use…
-
4
votes3
answers10600
viewsA: Generate random data within a range
You are not changing the return value because you do not change the receive value, to change it you should change the while to the following: while(recebe >= maior && recebe <= menor)…
-
3
votes3
answers2877
viewsA: Javascript function returning Undefined
What is happening is that you are getting the return of the function verificaExistente and as it returns nothing, the result is undefined. What is returning true/false is the function associated…
-
5
votes1
answer729
viewsA: What is string.maketrans for?
The maketrans is used to map characters so that they match. First you pass a string with the characters that will be "translated", then the mapping of it, where the position of the map, corresponds…
pythonanswered Felipe Avelar 9,507 -
2
votes1
answer534
viewsA: How to call a Python script in a C++ code in Qt Creator?
Based in that reply, the way to call any python script by Qt is: QProcess p; p.start("python", "script.py"); Remember that it is necessary to have python in the Path of the machine.…
-
0
votes1
answer179
viewsQ: Error while trying to connect smack to openfire
I am trying to perform a simple example to connect to an openfire server using the smack library 4.0.6 and have the following code: ConnectionConfiguration configuration= new…
-
16
votes3
answers10940
viewsA: How to recover the previous commit?
You can use the following command: git reset HEAD~1 This will return to the last commit, but leaving the changes in the file in status unstaged. If you want to delete the changes, the command is:…
gitanswered Felipe Avelar 9,507 -
1
votes2
answers729
viewsA: Encrypt source code Ruby on Rails?
As I mentioned in my comments, I believe it is better to provide the service than the program itself. Not least because obfuscating the code does not prevent reverse engineering processes from being…
-
3
votes1
answer1283
viewsQ: How to make a screen recorder?
I am wanting to make a screen recorder. What I thought to do was the following: From the recording event hit 30 screenshots per second and then join them in sequence to form a video. At this point…
-
9
votes4
answers4816
viewsA: Check Old Play Winner
You can wear bows for to check at the end of each round (from the third round) the winner, I would do as follows: 1. Fora do for verifica diagonais são iguais 2. Verifica se linha i todas as colunas…
-
15
votes5
answers3666
viewsQ: How do I know the last commit to move the same file as my commit?
I actually read the question How do I see which commits change a certain file? It’s almost what I need, in case what I want to know is if it’s possible I get the last commit that changed any file…
gitasked Felipe Avelar 9,507 -
1
votes1
answer89
viewsA: Copy incoming SMS messages from iPhone
As can be seen in that reply, cannot intercept/read SMS due to privacy issues, at least in a sample that has not gone through the jailbreak process. The only thing your app can do related to SMS,…
-
7
votes2
answers883
viewsQ: When to convert a bitmap to string Base64?
I know that in the past it was necessary to convert an image to string, because of limitations with SMTP. My doubts are: What is the use of this practice today? Is there any performance gain…
base64asked Felipe Avelar 9,507 -
5
votes1
answer903
viewsQ: How to check SQL backup integrity
I’m using MySQL and, to back up the banks, I am using the mysqldump. My question is whether and how I can check if the file generated by the dump is intact automatically, without having to "upload"…
-
4
votes2
answers343
viewsA: Using Flash Professional, how to import classes from an Actionscript file?
The Flash import system (in the case of Actionscript 3.0) works by searching in two folders and their subfolders (you can add more folders in the project preferences in the library section): The…
-
2
votes2
answers336
viewsA: How to check the number of users who have accepted an event on facebook using the Graph API
From what I read in documentation, the correct way to use would be with the /a/attending, where a is the {event-id}. This will return you a list of objects User, to know the number of people, just…
-
1
votes4
answers9378
viewsA: Algorithm Factorization in C
The if(cont==2) has to be outside the for(j=1;j<10000;j++), or he will divide by i whenever he finds his second divider. For example: let’s say my i is 4, when j = 2, cont = 2, soon it will make…
-
3
votes2
answers841
viewsA: Extra Fields Don’t Save With Devise
The Devise uses Strong Parameters, that is, it has to take care when you want to add new fields to the sign_up and sign_in. In this case, I will explain how it should be done for the record…
-
2
votes3
answers307
viewsA: How do I use Python to search and store data from the Stack Overflow API?
Beyond the answers of bfavaretto and of Renan, giving a quick search on Stackapps, found that question, linking to the pyso, that works properly for Python 2.6 and already provides various methods…
-
2
votes1
answer790
viewsA: Dynamic calculations in Rails
The resolution I would make would be to use a created field (which according to your comment will be created later) or the created_at and based on the resolution creation date (considering you have…
-
2
votes1
answer771
viewsA: How to run audio file using Audiotrack class?
The only way to play some audio by AudioTrack is a streaming PCM, as can be seen in documentation: The AudioTrack class manages and plays a single audio Resource for Java Applications. It Allows…
-
2
votes2
answers634
viewsA: How to group text file according to first line parameters in C#?
Using the question code, it should look like this: static void Main(string[] args) { string diretorio = @"C:\teste"; String[] listaDeArquivos = Directory.GetFiles(diretorio); if…
-
3
votes2
answers3773
viewsA: Group and add array in Javascript
I imagine what you want to do is this: var arr = [{ servicos: 0, remessa: 503, materiais: 0 , retorno: 598, entrada: 0, date: new Date("2011/12/20") }, { servicos: 302, remessa: 0, materiais: 412 ,…
-
2
votes2
answers270
viewsA: Order by on a Count in another table
Taking advantage of @bfavaretto’s reply, in case you have Avaliacao one belongs_to :item, you should do the following for the ruby-on-Rails:…
-
0
votes1
answer117
viewsA: PDF Password and Custom Footer
With a quick google search, I found Gem Prawn seems to solve your problem. Some of the characteristics of this: Security features such as encryption and password protection; Repeated content…
-
5
votes1
answer394
viewsA: DIV activating scroll in another DIV even with different sizes
An approximate idea would be to use percentages. First you need to know how many px the scroll source moved down, so we make the following rule of 3: scrollTopSource = x (scrollHeigthSource -…
-
2
votes1
answer984
viewsQ: How to send daily email?
I have an application in Ruby on Rails that I need to send a daily email. I thought to use the own class Mailer of rails. What I do not know is if it is possible to check the time to perform…
-
3
votes3
answers949
viewsA: How does the Xor Swap algorithm work?
What the exclusive disjunction operation (XOR) does is this: Let’s say we have a variable X and Y. When I do a XOR between X and Y, what happens is, when the values are different, returns a true…
-
2
votes2
answers2344
viewsA: How to create a robot using Java requests?
To make requests HTTP in Java, you need to use the HTTP connection class provided by jdk. An example is the Httpurlconnection. It is still possible to use some apache packages intended for this…