Dreams

All people dream, but not equally. Those who dream by night in the dusty recesses of their mind wake in the day to find that it was vanity.

But the dreamers of the day are dangerous people, for they may act their dream with open eyes to make it possible.

— D.H. Lawrence


Thinking Statue

Life · Stuff Comments 21. Jul

Spring Summer Fall Winter and Spring

His mind becomes cleaner and clearer.
He watches the sunset with no worries.
He recalls old memories and they do not trouble him.

Lotus

Life · Stuff Comments 20. Jul

Life doesn’t make sense

I don’t think that people accept the fact that life doesn’t make sense. I think it makes people terribly uncomfortable.
— David Lynch

David Lynch

Life · Stuff Comments 19. Jul

Steve Jobs

Design is not just what it looks like and feels like. Design is how it works.

Steve Jobs 1

Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma — which is living with the results of other people's thinking. Don't let the noise of other's opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

I was lucky — I found what I love to do early in life.

Steve Jobs 2

You can't just ask customers what they want and then try to give that to them. By the time you get it built, they'll want something new.

iPod

I'm the only person I know that's lost a quarter of a billion dollars in one year. It's very character-building.

I didn't see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.

Next logo

Being the richest man in the cemetery doesn’t matter to me. Going to bed at night saying we’ve done something wonderful, that’s what matters to me.

I was worth over $1,000,000 when I was 23, and over $10,000,000 when I was 24, and over $100,000,000 when I was 25, and it wasn’t that important because I never did it for the money.

iPad

People think focus means saying yes to the thing you’ve got to focus on. But that’s not what it means at all. It means saying no to the hundred other good ideas that there are. You have to pick carefully.

We don’t get a chance to do that many things, and every one should be really excellent. Because this is our life. Life is brief, and then you die, you know? And we’ve all chosen to do this with our lives. So it better be damn good. It better be worth it.

Steve with Apple

Design · Interesting · Life Comments 11. Jul

Dr. Gonzo

Dr Gonzo

He was one of God’s own prototypes: a high-powered mutant never even considered for mass-production. Too weird to live, too rare to die.
— Hunter S. Thompson

Design · Life · Stuff Comments 10. Jul

Simplistic vs. Simplicity

Simplicity is not what you think it is. Garr Reynold's presentation Simplistic vs. Simplicity in an eye opener for what it means to achieve simplicity. Here are my notes about his presentation, which you should watch here — it's highly recommended!

Simplistic vs. Simplicity

Simplicity is about subtracting the obvious and adding the meaningful.
— John Maeda

Dizzy Gillespie

It's taken me all my life to learn what not to play.
— Dizzy Gillespie

Any fool can make things complicated, but it requires a genius to make things simple.
— E. F. Schumacher

Koyoto Zen Garden

In the beginner's mind there are many possibilities. In the expert's mind there are few.
— Zen master Shunryu Suzuki

Aikido

Simplicity means the achievement of maximum effect with minimum means.
— Dr. Koichi Kawana

In most people's vocabularies, design means veneer. It's interior decorating. It's the fabric of the curtains of the sofa. But to me, nothing could be further from the meaning of design. Design is the fundamental soul of a human-made creation that ends up expressing itself in successive outer layers of the product or service.
— Steve Jobs

Imac

Out of clutter, find simplicity. From discord, find harmony. In the middle of difficulty lies opportunity.
— Zen master Albert Einstein

Albert Einstein

Design · Interesting · Stuff Comments 5. Jul

A Universe Not Made For Us

We long to be here for a purpose, but despite much self-deception, none is evident. The meaningless absurdity of life is the only incontestable knowledge known to man.

Life · Stuff Comments 3. Jul

Do epic shit

Do epic shit
Life · Stuff Comments 2. Jul

Implementing file locks using Python's with statement

File lock

I really love Python's with statement. It's great for implementing locks and transactions.

Today we had a problem where a script is run multiple times simultaneously. The easy way to solve this issue is via file locks.

The standard way of implementing a file lock could be like this:

import fcntl
def lockFile(lockfile):
    fp = open(lockfile, 'w')

    try:
        fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
    except IOError:
        return False

    return True

if not lockFile(".lock.pod"):
    sys.exit(0)

This works, but it can be much more beautiful and pythonic using the with statement.

Here is how a file lock implemented via with statement looks like:

import time

with file_lock('/tmp/my_script.lock'):
    print "I am here and I am sleeping for 10 sec..."
    time.sleep(10)

Here is the implementation (should be cross platform, but not tested):

import os, sys
from contextlib import contextmanager

@contextmanager
def file_lock(lock_file):
    if os.path.exists(lock_file):
        print 'Only one script can run at once. '\
              'Script is locked with %s' % lock_file
        sys.exit(-1)
    else:
        open(lock_file, 'w').write("1")
        try:
            yield
        finally:
            os.remove(lock_file)

Further reading:

Code · Code improvement · Code rewrite · Python · Tips Comments 30. Jun

Avoid Disaster: Script backups easily to Amazon S3

Avoid disaster

I released avoid_disaster today, it let's you do following things:
  • script backups easily via Python and upload them to Amazon S3
  • easily create daily, weekly or monthly backups
  • Amazon S3 is a cheap backup option and your backups are stored on 3 different data centers

The script is super simple, but it should be quite useful for anyone that wants to create cheap backups.

You are also welcome to fork the code on GitHub and supply extensions and patches :-)

Example usage

First install boto and avoid_disaster:

$ sudo easy_install boto
$ sudo easy_install avoid_disaster

Here is some example code that can get you started:

import os
from avoid_disaster import S3Uploader, gunzip_dir, generate_file_key

#--- Globals ----------------------------------------------
AWS_KEY = 'YOUR AWS KEY'
AWS_SECRET = 'YOUR AWS SECRET'

s3_uploader = S3Uploader(AWS_KEY,
                         AWS_SECRET,
                         'backups.your_domain.com')

#--- Easy usage ----------------------------------------------
#Daily
s3_uploader.compress_and_upload('test_dir/',
                                'test_dir.%(weekday)s.tgz',
                                replace_old=True)

#Monthly
s3_uploader.compress_and_upload('test_dir/',
                                'test_dir.%(month_name)s.tgz',
                                replace_old=True)

#Weekly
s3_uploader.compress_and_upload('test_dir/',
                                'test_dir.%(week_number)s.tgz',
                                replace_old=True)


#--- Generic usage ----------------------------------------------
file_key = generate_file_key('test_dir.%(weekday)s.tgz')
gz_filename = gunzip_dir('test_dir/', file_key)
s3_uploader.upload(file_key, gz_filename, replace_old=True)
os.remove(gz_filename)
Announcements · Python · Stuff · Todoist · Wedoist Comments 29. Jun

I think it's better to accept danger...

and live life to the fullest!

Calvin Hobbes Risk

Life · Stuff Comments 28. Jun
© 2000-2009 amix. Powered by Skeletonz.