mnaydin | 3 years ago | on: Lesser known tricks, quirks and features of C
mnaydin's comments
mnaydin | 3 years ago | on: Lesser known tricks, quirks and features of C
while (1) {
calc(x++);
}
which is an infinite loop, since the expression x <= max is always truemnaydin | 5 years ago | on: Print this file, your printer will jam (2008)
Blank One line
0 Two lines
1 To first line of next page
+ No advancemnaydin | 5 years ago | on: The original source code of Microsoft GW-BASIC from 1983
mnaydin | 6 years ago | on: An introduction to data processing on the Linux command line
cat sales.csv | awk -F',' '{print $1}'
but I'd prefer cut -d, -f1 sales.csvmnaydin | 6 years ago | on: An introduction to data processing on the Linux command line
cat sales.csv | awk -F',' '{print $1}' | sort | uniq
can even be further simplified to cut -d, -f1 sales.csv | sort -umnaydin | 7 years ago | on: Textbook errors in binary searching (1988)
mnaydin | 7 years ago | on: Textbook errors in binary searching (1988)
mid = ((unsigned int)low + (unsigned int)high)) >> 1;
in the blog may still be wrong if the sum ((unsigned)low + (unsigned)high)) produces a carry.mnaydin | 7 years ago | on: Textbook errors in binary searching (1988)
One correct way would be
for (size_t i = len; i > 0; --i) {
// use i-1 as the array index
}
or, size_t i = len
while (i-- > 0) {
// use i as the array index
}mnaydin | 7 years ago | on: Problem solving with Unix commands
ls -1 | uniq -u -w4
using GNU uniq, for these special filenames. Unfortunately, Posix does not define -w option for uniq.mnaydin | 7 years ago | on: Inside the C Standard Library
The architecture does not have to be two's-complement. The value of the expression (size_t)(-1) will always be SIZE_MAX, the largest number that can be represented in the size_t type. The bit pattern may change depending on the architecture, but the value shall equal to SIZE_MAX.
mnaydin | 9 years ago | on: The Awk Programming Language (1988) [pdf]
If no expression is present, -print shall be used as the expression. Otherwise, if the given expression does not contain any of the primaries -exec, -ok, or -print, the given expression shall be effectively replaced by: ( given_expression ) -print
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/fi...
mnaydin | 9 years ago | on: The Awk Programming Language (1988) [pdf]
mnaydin | 9 years ago | on: The Awk Programming Language (1988) [pdf]
find /path/to/dir -type f -printf "%s\n" | awk ' { s += $0 } END { print s " bytes" } '
The find command has much powerful file filtering capabilities than that of the ls command and works better with weird characters in filenames.