False Gems

Some thoughts without any particular direction

There is a very convenient way to store files inside CouchDB and be able to get them directly from it.

Read more...

I make a decision to learn the Czech language and to procrastinate I've made up a problem for myself:

I need a deck for the Anki with the most frequently accrued words in that language.

Read more...

There is a way to get information about any process (with according permissions) using filesystem operations only. You need no additional tools besides what you already have on your system. In most cases cat will be enough.

Read more...

So, this will be my attempt to start and proceed with #100DaysToOffload. I'm not sure that I will have enough ideas or material to make really useful content and it could happen that there will appear posts like that: just random thoughts with not much sense.

My initial plan is to publish one post in 3 days and I think it is enough to come up with some idea and write not completely garbage text. Even this text takes more time than I expected but the process should improve soon.

Also, I believe, that it would be a good enough way to practice English writing skills. There will be not so many readers of that to be offended by its grammar or style. I'm still using grammarly just to be sure that there is no obvious misspelling and stuff. If you have any comments though, I will be glad to hear them.

My previous posts here are pretty crappy and contain only some code snippets. I've not decided yet, will be they rewritten as a new post, which could be considered as cheating, or just edited. Also, there is a question about how to store snippets. Right now it is built-in as a gist but maybe it will be better to move into the post as code block.

Wish me persistence and stubbornness.

def currency(value, group_sep=' ', decimal_sep='.'):
    """Format currency by digits.

    >>> currency(100)
    '100.00'
    >>> currency(3.1415)
    '3.14'
    >>> currency(31415)
    '31 415.00'
    >>> currency(3141500.1)
    '3 141 500.10'
    >>> currency(31415000.1)
    '31 415 000.10'
    """
    head,tail = ('%.2f'%value).split('.')
    l = len(head)
    return group_sep.join([head[r-3:l+r] for r in xrange(0,-l,-3)][::-1]) + decimal_sep + tail

Gist