Susan Cain: The power of introverts

Great TED talk by Susan Cain on the power of introverts.

For more, have a look at her recent book, Quiet: The Power of Introverts in a World That Can’t Stop Talking.

Posted in Uncategorized | Leave a comment

Simple Process Timer in Python.

Profiling code is important.

In python, the easiest way to time your code is to do the following:

from datetime import datetime
start = datetime.now()
# Some long-running process
end = datetime.now()
print "process run in %s" % (end - start)

This solution works, but it can be annoying to write, and you’ll have to remove the debug lines before you ship your code to production. Once or twice, this is okay. But doing it over and over again can get annoying.

Do this in one line:

with timer() as t:
    print "Hello, world!"
    # Some long-running process.

which returns

Hello world!
process run in 0:00:00.001030

It’s cleaner, and you can easily toggle it if your application is off of DEBUG mode. Code below:

from datetime import datetime
import time
 
class timer:
    def __enter__(self):
        self.start = datetime.now()
        return self
 
    def __exit__(self, type, value, traceback):
        self.end = datetime.now()
        print "time: %s" % (self.end - self.start)
 
with timer() as t:
    print "Hello, World!"
    time.sleep(2)

or gist.

Posted in python | Leave a comment

On The Edge of Chaos

On the edge of chaos.

via Creative Emergence

Posted in ideas | Leave a comment

Dawson on “The Gains of Drudgery”

Came across an interesting post this morning that related to some thoughts I’ve been having about my own personal work ethic. It takes from a piece written by William James Dawson, called The Gains of Drudgery. I’ll paste the first paragraph here, the rest is after the fold.

By drudgery, I mean work that in itself is not pleasant, that has no immediate effect in stimulating our best powers, and that only remotely serves the purpose of our general advancement. Such a definition may not be perfect, but it expresses with reasonable accuracy what we usually understand by the term.

Read More »

Posted in links, quotes | Leave a comment

Interesting Article from good.is on the “Information Arms Race”

[...] The rise of microtargeting is a function of new logarithms—and computers fast enough to process them—that are able to capture all this trash and turn it into gold. Over the years, the data-mining industry has become adept at recycling information about the websites we visit and the products we buy. Rumor has it that some high-end companies, including Omaha Steaks, can now make more money by selling their customer pedigrees to data-mining firms than they can from selling their product

via good.is.

Interesting read. It’s a bit higher-level than I would have hoped, but it does a great job introducing some of the many ways that organizations are leveraging seemingly minute, uncorrelated data in ways that will add values to organizations.

Posted in business, links | Leave a comment

There exists a continuous rail service that goes between Moscow & Vladivostock. It spans 9,259km.

And Google Maps knows about it. In fact, it recommends it if you ask for Public Transit directions between the aforementioned cities.


View Larger Map

Brilliant. In the words of Kurt Vonnegut, ”bizarre travel plans are dancing lessons from God.” More info on the railway on Wikipedia.

Posted in quotes, travel | Leave a comment

Thin Python Cache Decorator

def cache(func):
""" A thin middleware that caches based on function name and arguments. """
    def _inner(*args, **kwargs):
        a_str = "&".join([str(a) or None for a in args])
        kw_str = "&".join(["%s=%s" for key, val in kwargs.iteritems()])
        key_name = slugify("%s:%s:%s" % (func.__name__, a_str, kw_str))
        cached = cache.get(key_name)
        if not cached:
            cached = func(*args, **kwargs)
            cache.set(key_name, cached)
        return cached
    return _inner

This is designed with django in mind, but you can replace cache.set and cache.get with any cache cache framework of your choice. Also, I use slugify because many cache frameworks don’t like spaces in cache key names. Slugify replaces them with dashes.

Usage is simple:

@cache
def expensive_method(a,b=True):
    ...
Posted in Uncategorized | Leave a comment

On Meditation

Third, meditation can help a man “be his own man” and feel comfortable in his own skin.  That constant stream of input we face each day often carries messages of what we’re supposed to think or feel.  Talking-heads spout off opinions as if they were facts. Advertisers try to convince us that buying such-and-such product will make us feel more virile and manly. Meditation allows us to be alone with our own thoughts and discover what we really think about the world and ourselves.

via Art of Manliness

Posted in Uncategorized | Leave a comment

Focus Time Hack (OSX)

Block facebook and reddit on your Mac; focus longer and get work done instead.

Open up a terminal, copy and paste this:

sudo echo "127.0.0.1\tfacebook.com\n127.0.0.1\treddit.com" >> /etc/hosts


										
Posted in Uncategorized | Leave a comment

User Interfaces that Involve Uncertainty

Marco Polo

I installed Marco Polo today. It seems like a useful application, but it left me wondering. What are some ways to represent decisions that involve uncertainty in user interfaces?

The first mental framework that came to mind was the different types of measurement scales. An ordinal scale might make sense, but it’s hard to order things when there might not be an inherent ordering. Ratio and Interval wouldn’t do the trick here. At the same time, this nominal scale just doesn’t work in my mind.

iTunes has a nice interface for building playlists.

iTunes Smart Playlist

It’s an interface for defining and setting rules; maybe this would be more appropriate for Marco Polo’s interface? To go a little bit deeper, what does it mean to have 50% confidence that my Monitor is Color LCD?

I’m curious about this now. What are some other common UIs that involve making decisions based on uncertainty?

Posted in design | Leave a comment