Posts by Fábio Perez • 1,662 points
42 posts
-
4
votes1
answer9644
viewsQ: How to copy a Python file?
How to copy a file fonte to an archive destino in Python?
-
7
votes1
answer9644
viewsA: How to copy a Python file?
shutil.copyfile import shutil shutil.copyfile(fonte, destino) It is possible to use os.path to obtain paths that work for several operating systems. For example, to move the file arquivo.txt to the…
-
2
votes3
answers12149
viewsQ: How to check if a number is within a range in Python?
In Python, I would like to check if a number is within a range. There is a more pythonic way than the following code? if n >= 100 and n <= 200: ...
-
4
votes3
answers12149
viewsA: How to check if a number is within a range in Python?
Use the following syntax: if 100 <= n <= 2000: ...
-
0
votes1
answer137
viewsA: Help with shell script and regular expressions
You are iterating the file line by line with the while read line;do, but is applying the grep entire file. The following modification should fix this problem: pos=$(echo "$line" | grep -oP…
shell-scriptanswered Fábio Perez 1,662 -
2
votes2
answers3954
viewsQ: How to list all remote repositories in Git?
How to get a list of all remote repositories associated with a local Git repository?
-
2
votes2
answers3954
viewsA: How to list all remote repositories in Git?
Use the command git remote -v. $ git remote -v bakkdoor https://github.com/bakkdoor/grit (fetch) bakkdoor https://github.com/bakkdoor/grit (push) cho45 https://github.com/cho45/grit (fetch) cho45…
-
6
votes1
answer7886
viewsQ: How to view two files side by side in Notepad++?
You can view two files side by side on Notepad++? For example, in the vim, the command :split does that.
notepad++asked Fábio Perez 1,662 -
11
votes1
answer7886
viewsA: How to view two files side by side in Notepad++?
Right-click a tab, then select Move to another screen (Move to Other view).
notepad++answered Fábio Perez 1,662 -
1
votes2
answers61
viewsQ: How to print build and link commands in Cmake?
I have a project that uses the Cmake and would like to print the build commands generated by it. How to do this?
-
1
votes2
answers61
viewsA: How to print build and link commands in Cmake?
If you want the build commands at all times are printed, place the following line in the CMakeLists.txt: SET(CMAKE_VERBOSE_MAKEFILE ON) If you want to print the build commands only a few times,…
-
1
votes1
answer31
viewsQ: How to parallelize the compilation with make?
The compilation process is parallelizable, but by default the program make runs one recipe at a time. How to parse the build with make?
-
2
votes1
answer31
viewsA: How to parallelize the compilation with make?
The option -j (or --jobs) sets how many commands should be executed in parallel. For example, make -j8 will execute 8 commands in parallel. To set this behavior as default, modify the environment…
-
6
votes2
answers12917
viewsQ: What is the difference between a symbolic link and a hard link?
In the Unix context, what is the difference between a symbolic link (soft link) and a hard link and which commands are used to create them?
-
11
votes2
answers12917
viewsA: What is the difference between a symbolic link and a hard link?
A symbolic link (soft link) behaves as a "shortcut" to another file or directory. That is, it pretty much only points to this other file. When deleting the original file, the symbolic link will…
-
5
votes2
answers10495
viewsQ: How to get the number of processors and cores from the terminal?
How to check the number of processors (Cpus) and cores by the Linux terminal?
-
6
votes2
answers10495
viewsA: How to get the number of processors and cores from the terminal?
To print the number of processing units, use the program nproc. For more details, use the program lscpu, which displays information such as architecture, number of Cpus, number of sockets, threads…
-
3
votes1
answer307
viewsQ: How to remove an alias in bash?
No bash, how to remove an alias? For example, after doing alias man="man -a", I just want to execute man instead of man -a.
-
5
votes1
answer307
viewsA: How to remove an alias in bash?
To remove an alias: unalias man To ignore any alias with the command name, put \ before the command: \man
-
1
votes1
answer316
viewsQ: How do I remove a file from a Git repository without deleting it locally?
I would like to remove a file or directory that was sent to the Git repository erroneously, but without removing it from my local files. Which command git executes such an action?…
gitasked Fábio Perez 1,662 -
1
votes1
answer316
viewsA: How do I remove a file from a Git repository without deleting it locally?
Pass the parameter --cached to the git rm: git rm --cached arquivo.txt For directories, recursively remove with -r: git rm --cached -r diretorio…
gitanswered Fábio Perez 1,662 -
4
votes2
answers7228
viewsQ: How to remove spaces at the beginning and end of a string?
How to remove any number of spaces at the beginning or end of a C string#?
-
10
votes2
answers7228
viewsA: How to remove spaces at the beginning and end of a string?
Utilize String.Trim(): " aaa ".Trim() // "aaa" To remove only spaces in beginning of the string, use String.Trimstart() " aaa ".TrimStart() // "aaa " To remove only spaces in end of the string, use…
-
0
votes2
answers316
viewsA: What is the strategy to identify a right answer, without exact comparison of String?
It depends on how flexible you want the answers to be. This is a design question that depends on your product. A few ideas: Convert string to bottom (lower case) Omit accents (normalisation) Skip…
-
3
votes1
answer13858
viewsQ: jQuery: How to check if an element is hidden?
How to check if an element is visible or hidden in jQuery? For example, an element can be hidden using .hide(), visible using .show() or switch between hidden/visible with .toggle().…
-
4
votes1
answer13858
viewsA: jQuery: How to check if an element is hidden?
Use the selectors :visible: and :hidden. [1] var isVisible = $( "#myDiv" ).is( ":visible" ); var isHidden = $( "#myDiv" ).is( ":hidden" ); In addition, you can use them directly on the selector: $(…
-
1
votes1
answer933
viewsQ: How to convert a string to a number in Lua?
In Lua, how to convert a string type value to the number type (integer, float etc.)?
-
1
votes1
answer933
viewsA: How to convert a string to a number in Lua?
The Moon performs a automatic conversion among the types string and number and vice versa at execution time. > print(1+"20") 21 > print(1 .. "2") 12 In case you want to convert explicitly one…
-
6
votes1
answer10284
viewsQ: How to remove a remote branch in Git?
To delete a local Git branch, just use the command git branch -d <branch>, but how to get this same branch removed on the remote server?
gitasked Fábio Perez 1,662 -
9
votes1
answer10284
viewsA: How to remove a remote branch in Git?
To remove a remote branch, use the following command: git push origin --delete <branch> Note that this command only works for the Git v1.7.0 or later. For older versions, use: git push origin…
gitanswered Fábio Perez 1,662 -
1
votes1
answer253
viewsQ: How to verify register values by gdb?
How to check the value of all registrars in gdb? Also, how to check the value of a specific registrar in gdb?
-
1
votes1
answer253
viewsA: How to verify register values by gdb?
To check the values of all registers in gdb, use the command info all-registers (or i all). This includes floating point and vector registers. The command info registers (or i r) does not display…
-
1
votes1
answer57
viewsQ: How to define a breakpoint in gdb for all functions of a certain file?
Is it possible to set a breakpoint for all functions of a particular file in gdb? An application, for example, would check if the program passes by certain file during its execution.
-
1
votes1
answer57
viewsA: How to define a breakpoint in gdb for all functions of a certain file?
Use the rbreak, that defines breakpoints according to a regular expression. To set breakpoints in all file functions arquivo.c, use the following command: (gdb) rbreak arquivo.c:. More information…
-
4
votes1
answer69
viewsQ: How to see the value of a define or macro in gdb?
I have the following line of code: int a = MAX(b,c); How to verify macro definition MAX(b,c)? Sometimes, the same macro is defined in several different ways in a code (for example, depending on the…
-
5
votes1
answer69
viewsA: How to see the value of a define or macro in gdb?
First, Compile the program with the flag -g3, to ask gcc to include all levels of debugging information, including macro expansions. In gdb, use the command macro expand to expand the macro. For…
-
3
votes1
answer1596
viewsQ: Check if a value is present in a Ruby array
How do I check if a certain value is contained in a Ruby array? For example, I want to know if 'A' is present in the vector ['A','B','C'].
-
2
votes1
answer1596
viewsA: Check if a value is present in a Ruby array
Use the method include?. a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false…
-
0
votes2
answers2109
viewsQ: Automatically indent all code in vim
It is possible to automatically make vim indent an entire file? For example, in Eclipse you can use the shortcut Ctrl+A + Ctrl+I.
-
0
votes2
answers2109
viewsA: Automatically indent all code in vim
To indent an entire file in vim, just type the command gg=G. However, this command causes the cursor position to change to the first line of the code. To avoid this, use the command gg=G'' or…
-
7
votes1
answer1470
viewsQ: How to commit only to a piece of a file in Git?
When modifying multiple parts of a file, you can commit to just one piece (for example, a new function)?
-
8
votes1
answer1470
viewsA: How to commit only to a piece of a file in Git?
Utilize git add --patch <nome_do_arquivo> (or git add -p <nome_do_arquivo>). In this way, the git will allow the user to interactively define which part of the code will be added to the…