Bookmark and Share
Posted Sat Mar 7 02:37:38 2015 Tags:

Some interesting Web sites to check out on this very special day -- Pi day:

Posted Mon Mar 9 05:08:15 2015 Tags:
Posted Tue Mar 17 06:50:27 2015

In Wolfram Language / Mathematica, there are the following escaped characters that end with Space:

$WhiteSpaceCharacters = {
"\[AutoSpace]",
"\[COMPATIBILITYKanjiSpace]",
"\[InvisibleSpace]",
"\[LetterSpace]",
"\[MediumSpace]",
"\[NegativeMediumSpace]",
"\[NegativeThickSpace]",
"\[NegativeThinSpace]",
"\[NegativeVeryThinSpace]",
"\[NonBreakingSpace]",
"\[RawSpace]",
"\[ThickSpace]",
"\[ThinSpace]",
"\[VeryThinSpace]"
}

These can be found by evaluating ?\[*Space] in a Mathematica notebook.

To actually obtain these in copiable text was not straightforward for me as I did not find a programmable way to generate the above list. Instead, I copied the cell expression out (by selecting the output cell, pressing Ctrl+Shift+E, and copying out the text), and then run ack to extract any strings that start is sandwiched with \[ and ]:

17:09:43 meng@meng2maclap:~/Temp$ ack -o "\\\\\\\\\[.*Space\]" cellexpr.txt | sort | uniq

AutoSpace
COMPATIBILITYKanjiSpace
InvisibleSpace
LetterSpace
MediumSpace
NegativeMediumSpace
NegativeThickSpace
NegativeThinSpace
NegativeVeryThinSpace
NonBreakingSpace
RawSpace
ThickSpace
ThinSpace
VeryThinSpace

Curiously, only \[AutoSpace], \[NonBreakingSpace], \[RawSpace] satisfy StringMatchQ[#, RegularExpression["[[:whitespace:]]"]]&.

See the CDF file for details.

Posted Tue Mar 17 06:50:27 2015 Tags:

I usually use Bash for fairly trivial and/or ad-hoc tasks. But sometimes when a Bash program become complex, leveled logging can be useful for debugging and monitoring program states. By leveled logging, I mean printing messages grouped by different tags such as DEBUG and INFO and controlling which of the groups are printed by a "level" parameter. This is roughly what's supported by java.util.logging.Level and org.apache.log4j.Level in Java.

To do this in Bash, I simply defined a set of level constants that is the union of the two schemes given above:

LEVEL java.util.logging.Level org.apache.log4j.Level
9 (off) (off)
8 n/a FATAL
7 SEVERE ERROR
6 WARNING WARN
5 INFO INFO
4 CONFIG n/a
3 FINE DEBUG
2 FINER TRACE
1 FINEST ALL

Direct data download

and define a mengLog function that print a message if the message's logging level is same or higher than a global logging level $mengLOGGING_LEVEL. So the logging level can be understood as an indication of priority, the higher the level is, the higher the priority. For instance, when $mengLOGGING_LEVEL=6, messages with level equal or higher than 6 has an enough priority or even higher priority to be printed, and therefore, WARNING/WARN, SEVERE/ERROR, FATAL messages are printed in the example leveled-logging_example.sh.

Code:

Posted Thu Mar 19 07:49:38 2015 Tags:
blog comments powered by Disqus