News

Coffee rulz!

11UP Health facebookJumbo

When I was a kid, my parents refused to let me drink coffee because they believed it would “stunt my growth.” It turns out, of course, that this is a myth. Studies have failed, again and again, to show that coffee or caffeine consumption are related to reduced bone mass or how tall people are.
Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.

Good news!  Another vice becomes a virtue.  A survey of various studies and meta-studies suggest coffee (in it’s unadulterated, non-sugary, non-high-caloric form, e.g. black coffee) is good for you.
The article mentions some “coffee” drinks that are bad for you.  Like the  Large Dunkin’ Donuts frozen caramel coffee Coolatta (670 calories, 8 grams of fat, 144 grams of carbs).  A real cup of coffee has 5 calories.
This is all good news as I just bought a [amazon text=coffee grinder&asin=B00DS4767A] and [amazon text=maker&asin=B00O9FO1HK].
Or as I like to paraphrase Talleyrand

Black as the night, hot as hell; pure as an angel, bitter as love

Source: More Consensus on Coffee’s Benefits Than You Might Think

NYC

The Price of Nice Nails

NAILSTEST13 master1050

The typical cost of a manicure in the city helps explain the abysmal pay. A survey of more than 105 Manhattan salons by The Times found an average price of about $10.50. The countrywide average is almost double that, according to a 2014 survey by Nails Magazine, an industry publication.

With fees so low, someone must inevitably pay the price.

Ever wonder why getting you nails done in NYC is cheaper then just about everywhere else?  Doesn’t it seem incredible that one of the most expensive cities in the US could have a service that is cheaper then almost anywhere else?  This is a great expose in the NYT about how workers are exploited.
I particularly liked this map showing the number of Starbucks vs. nail shops:
Salons3 artboard 300

Source: The Price of Nice Nails

Politics

Atomic Labs Across the U.S. Race to Stop Iran

Interesting article in the NY Times about how scientists in nuclear research labs in the US aided the negotiations with Iran

It was over one of those dinners in Vienna last summer that several of the experts began wondering how they might find a face-saving way for Iran to convert its deep-underground enrichment plant at Fordo, a covert site exposed by the United States five years ago, into a research center. That would enable Iran to say the site was still open, and the United States could declare it was no longer a threat.“The question was what kind of experiment you can do deep underground,” recalled a participant in the dinner.

Source: Atomic Labs Across the U.S. Race to Stop Iran – NYTimes.com

Technology

Quote shell characters

Sometimes it’s nice to be able to display a command being run and do it in a form that can be repeated from a terminal window. Unfortunately, I’ll build a command in python like this:

args = ['somecmd', 'WHERE=$(DESTDIR)', '--message', "Lot's of text" ]

The trivial answer of ‘ ‘.join (args) produces something that can’t be passed to the shell:

>>> ' '.join (args)
"somecmd WHERE=$(DESTDIR) --message Lot's of text"

Here is a code fragment and some attached tests that provide better quoting. It’s used like this:

>>> import shquote
>>> args = ['somecmd', 'WHERE=$(DESTDIR)', '--message', "Lot's of text" ]
>>> print ' '.join ([shquote.shquote (a) for a in args])
somecmd 'WHERE=$(DESTDIR)' --message "Lot's of text"
#!/usr/bin/env python
def shquote (arg):
    """
    Quote a single argument in the most readable way so it is safe from
    shell expansion.
    """
    # Return an empty string as double quoted
    if not arg:
        return '""'
    special = """ t[]{}()'*?|;"""   # These need double quotes
    superspecial = """$"!"""        # These need single quotes
    quotechar = None
    # See if we need single quotes
    for c in superspecial:
        if c in arg:
            quotechar = "'"
            break
    # See if we need double quotes
    if not quotechar:
        for c in special:
            if c in arg:
                quotechar = '"'
                break
    # No quoting necessary
    if not quotechar:
        return arg
    # If quotechar is present then escape it by dropping out of quotes
    if quotechar in arg:
        arg = arg.replace (quotechar, "%s\%s%s" % (quotechar, quotechar, quotechar))
    return quotechar + arg + quotechar
if __name__ == '__main__':
    tests = [('',       '""'),
             ('*.cpp',  '"*.cpp"'),
             ('test.[ch]', '"test.[ch]"'),
             ('(',      '"("'),
             (')',      '")"'),
             ('a',      'a'),
             ('$',      """'$'"""),
             ('$a',     """'$a'"""),
             ('abc|def', '"abc|def"'),
             ('abc;def', '"abc;def"'),
             ('a b',    '"a b"'),
             ('"abc"',  """'"abc"'"""),
             ("""It's mine""", '"It's mine"'),
             ('abc | def ABC=$(XYC)', """'abc | def ABC=$(XYC)'"""),
             (""""That's impossible!" he said.""", """'"That'\''s impossible!" he said.'"""),
          ]
    for (input, expected) in tests:
        output = shquote (input)
        if output != expected:
            print 'input    = ', input
            print 'expected = ', expected
            print 'got      = ', output
        else:
            print "%-30s => %s" % (input, output)

And the result of running this:

bash-3.2$ ./shquote.py
                               => ""
*.cpp                          => "*.cpp"
test.[ch]                      => "test.[ch]"
(                              => "("
)                              => ")"
a                              => a
$                              => '$'
$a                             => '$a'
abc|def                        => "abc|def"
abc;def                        => "abc;def"
a b                            => "a b"
"abc"                          => '"abc"'
It's mine                      => "It's mine"
abc | def ABC=$(XYC)           => 'abc | def ABC=$(XYC)'
"That's impossible!" he said.  => '"That'''s impossible!" he said.'