Berkeley CSUA MOTD:2013:April:09 Tuesday <Wednesday>
Berkeley CSUA MOTD
2013/4/9-5/18 [Consumer/Camera, Consumer/CellPhone] UID:54645 Activity:nil
4/9     'Government probes case of texting helicopter pilot' (
        'The pilot ... exchanged 20 text messages, over a span of less than
        two hours preceding the helicopter crashed ... Most of the messaging
        was with an off-duty female co-worker with whom he had a "long history"
        of "frequent, intensive communications," and with whom he was planning
        to have dinner that night ..."
        Texting kills.  Mistress kills.
2013/4/9-5/18 [Recreation/Celebrity/MichaelJackson] UID:54646 Activity:nil
4/8     Margaret Thatcher, Annette Funicello, who's next? They always
        die in threes.
        \_ Yeah.  Michael Jackson and Farrah Fawcett died on the same day also.
           I still recall that when I was driving in the afternoon that day,
           KCSM was playing Dave Brubeck sound tracks non-stop for half an hour
           without the DJ saying anything.  So I thought Brubeck died on that
           day too.
           \_ Robert Edwards is number three. Really strange.
           \_ YOU.
2013/4/9-5/18 [Academia/Berkeley/CSUA, Computer/SW/Mail] UID:54647 Activity:nil
4/8     What's a good free e-mail provider? I don't want to use Gmail,
        Yahoo, Outlook, or any of those sites with features I never use that
        track my personal info and keep changing their interface. I want just
        simple e-mail without privacy issues or all the baggage these large,
        for-profit companies are adding. I might even be willing to pay.
        \_ Not free though.
        \_ soda has been very consistent for the past few decades,
           why don't you use soda?
           \_ I thought soda stopped hosting mail years ago.  -- !OP
        \_  -- completely insecure, but great for throwaway
           email accounts.
2013/4/9-5/18 [Reference/Religion] UID:54648 Activity:nil
4/8     "Do We Need God to be Moral?"
        "The seeds for moral behavior preceded the emergence of our species
        by millions of years, ..."
2013/4/9-5/18 [Uncategorized] UID:54649 Activity:nil
4/8     RIP Margaret Thatcher.
2013/4/9-5/18 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Apps, Computer/SW/Languages/Perl] UID:54650 Activity:nil
4/04    Is there a good way to diff 2 files that consist of columns of
        floating point numbers, such that it only tells me if there's a
        difference if the numbers on a given line differ by at least a given
        ratio?  Say, 1%?
        \_ Use Excel.
           1. Open foo.txt in Excel.  It should convert all numbers to cells in
              column A.
           2. Open bar.txt in Excel.  Ditto.
           3. Create a new file in Excel.
           4. In cell A1 of the new file, enter this:
              =IF(foo.txt!A1=0, IF(bar.txt!A1=0, "same", "different"), IF(ABS((b\
ar.txt!A1-foo.txt!A1)/foo.txt!A1)<1%, "same", "different"))
           5. Select cell A1.  Hit Ctrl-C to copy.
           6. Select the same number of cells as the number of cells that exist
              in foo.txt or bar.txt.  Hit Ctrl-V to paste.
           7. Hit Ctrl-F.  In "Find what:", enter "different".  In "Look in:",
              choose "Values".  Click "Find All".
           Another way is to write a C program to read the two files using
           fscanf("%f") an do the arithmatic.
        \_ does this help?
import sys

threshold = float(sys.argv[3] if len(sys.argv) > 3 else 0.0000001)
list1 = [float(v) for v in open(sys.argv[1]).readlines()]
list2 = [float(v) for v in open(sys.argv[2]).readlines()]

line = 1
for v1, v2 in zip(list1, list2):
    if abs((v1 - v2) / v1) >= threshold:
        print "Line %d different (%f != %f)" % (line, v1, v2)
    line += 1
        \_ Something like this might work ($t is your threshold):
           $ perl -e '$t = 0.1 ; while (<>) { chomp($_); ($i,$j) =
             split(/ \t/, $_); if ($i > ((1+$t)*$j) || $i < ((1-$t)*j)) {
             print "$_\n"; }}' < file
Berkeley CSUA MOTD:2013:April:09 Tuesday <Wednesday>