The unpacking assignment assigns elements of a tuple/list to variables at once.
Runtime Paths in Python
__file__
is the path of the Python script.
Note that if you make a sybolic link to a Python script and run the symbolic link,
then __file__
is the path of the symbolic link.
Of course, you can use os.path.realpath
to get real path of files.
pathlib.Path …
Select Columns from Structured Text Files
Python pandas
My first choice is pandas in Python. However, below are some tools for quick and dirty solutions.
q
q -t -H 'select c1, c3 from file.txt'
cut
cut -d\t -f1,3 file.txt
awk
awk -F'\t' '{print $1 "\t" $3}' file.tsv
Note: neither cut …
Run JAR Applications
If there is only 1 class with a main method or if there is a Main-Class defined for the JAR, you can use the following command to run the application.
java -jar app.jar
If you there are multiple classes with main methods in the JAR, you can execute any …
An IO Bug in R
I encountered an input/output bug in R in Linux system. The symptom is that input and output are not displayed in the terminal and the warning message "An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report()" is shown. I found that though …
A Bug in Mathematica
Mathematica is a very intelligent and powerful math software. I use it in my study and research a lot. Mathematica's ability to take derivative and to calculate limit is obvious powerful–way much beyond many mathematician's ability. Mathematica's ability to calculate integral is also powerful. There are many integrals than …