part II: Remove multiple whitespace-lines from a file
I was so annoyed that the simple idea with sed did not worked like I wanted, that I wrote a short full-fledged Qt-appp for it. Code follows. Just compile the main.cpp. Usage is also explained in the header of the file.
I know it’s like to break a butterfly on a wheel, but I need this functionality since I don’t want to do such a boring task like code-styling by myself ..
Update: first version had a small glitch! Found after applying it to some bigger files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
//! @brief lessWhite should remove all multiple empty lines (newline, whitespace, tabs, spaces, ...) from the given input. //! Based on the standard POSIX channels stdin, stdout, stderr. //! usage like: $ ./lessWhite < input.txt > output.txt //! terminal output will look like: "removed 67 lines!" //! @author mail@marcelpetrick.it //! @version 0.02 (bugfix for "output had one additional newline at the end") //! //! history: 0.01: initial state #include <QTextStream> #include <QString> int main(int argc, char *argv[]) { Q_UNUSED(argc); Q_UNUSED(argv); QTextStream stream(stdin); QString output; //the combined stuff: no checks for overflow QString line; bool lastWasEmpty(false); int removedLines(0); bool isVeryFirstLine(true); do { line = stream.readLine(); bool const currentIsEmpty(line.trimmed().isEmpty()); if(currentIsEmpty && lastWasEmpty) { removedLines++; //do nothing } else { if(!isVeryFirstLine) //prevent the bug with the last line == double newline { output.append("\n"); } else { isVeryFirstLine = false; //reset now } output.append(line); } lastWasEmpty = currentIsEmpty; } while(!line.isNull()); //output QTextStream cout(stdout); cout << output; //print to stdout QTextStream cerr(stderr); cerr << "removed " << removedLines << " lines!\n"; //print to stderr } |
Replace the Sansa Clip (Clip+ or Clip Zip) firmware to make it scrobbleable
Work of 5 min (?)
Maybe even less if you know how to handle a mouse, the keyboard and a browser … 😉
First step is to exchange the firmware with Rockbox. A very good OSS mp3-player software for several different device kinds which enhances the hardware. You can even play Doom on your player!
- set the device to MSC-mode (MTP or Auto does not work)
- get the firmware for you device: Firmware thread at the Sansa-forums
- get and run the rockbox-installer
- select device and mount-point; pick the firmware-binary; select your options (bootloader and firmware yes; no games, no themes, no fonts …): “finish”, done
The second step is to enable scrobbling:
- got to your players settings (after restarting it and select “Settings > Playback Settings > last.fm log” with “enable”)
Play some tunes and afterwards connect you device to the PC and run QTScrobbler (note: Qt not QT! We are not in a hurry ;))