Лекции по введению в психоанализ
2007-09-21 at 05:47 | In media, micro, review | Leave a CommentЗакончил перечитывать «Лекции» и «Новый цикл» Зигмунда Фрейда.
- Ссылка: Фрейд З. Лекции по введению в психоанализ и Новый цикл. — Фирма СТД, 2003. — urn:isbn:5-898-08028-7
- Оценка: 5/5
См. также:
Twitter: бесплатные SMS и микроблоггинг
2007-09-21 at 02:33 | In it, review, talk | 8 CommentsЧто такое Twitter — можно легко узнать в Википедии или на сайте Twitter.com. Здесь я напишу о двух уровнях восприятия Twitter.
Twitter позволяет (в частности) отправлять людям бесплатные SMS в любую страну. Для этого оба должны зарегистрироваться в Twitter и добавиться в контакты (followers). Если один человек зарегистрирует номер своего сотового в Twitter, то второй сможет слать ему бесплатные SMS через сайт Twitter.com или через IM (Jabber, ICQ?). Для этого используются т. н. прямые (direct) сообщения. Напирмер, я хочу отправить пользователю Twitter с именем foo сообщение SMS. Я просто шлю сообщение “d foo привет! как дела?” Jabber-боту twitter@twitter.com. Есть разные варианты получения сообщений: SMS/IM/Web, различные приватности, времена и т. д. Мне это показалось удобным: я попросил нескольких друзей зарегистрироваться и теперь быстро и бесплатно шлю им SMS :)
А теперь несколько слов об архитектуре Twitter. Эта система представляет собой социальную сеть, построенную по принципу «публикация-подписка» (Publish-Subscribe). Пользователи Twitter подписываются на микроблоги — новостные ленты с короткими записями других пользователей о том, что они делают и что интересного происходит вокруг. При этом архитектура развязывает каналы публикации сообщений-твитов и их получения.

Перечислю основные элементы архитектуры (см. диаграмму): компоненты, соединители и данные. Компоненты Twitter — клиенты в виде сотовых телефонов, мессенджеров и браузеров, шлюзы для приёма SMS, IM и веб-запросов и, наконец, сервер публикации-подписки, отправляющий опубликованные твиты всем подписчикам. В качестве соеднителей Twitter с внешним миром выступают, как сказано выше, протоколы доставки SMS (GSM), IM (Jabber/XMPP, AIM/OSCAR) и Web (HTTP). И, наконец, данные — это сообщения: текстовые строки Unicode, часть которых — это команды типа “@username” и “off”.
Оценка: 5/5
См. также:
Целочисленная оценка несуществующих отношений
2007-09-13 at 04:55 | In life, quote | 2 CommentsПустое множество этических оценок
Накроется заснеженной рябиною,
И разделяющих двух человеков стенок
Так много вновь стоит стеною длинною.
anrienord, 2007-01-04
P. S. Структурная логика об этике отношений.
Programmer’s Day! When?
2007-09-11 at 14:35 | In devel, it, lang:en, life | Leave a CommentWe all (hopefully) know that the programmer’s day is the 256th day of the year, i. e. 2007-256 in ISO 8601. But when should we celebrate it this year? This piece of code that uses the Python’s standard library (batteries included) will answer the question:
def pday(year):
return yday(year, 256)
def yday(year, day):
import datetime, time
t = time.strptime("%d-%03d" % (year, day), "%Y-%j")
return datetime.datetime(*t[0:6])
So, pday(2007) is 2007-09-13.
Dating Pools
2007-09-10 at 15:10 | In fun, lang:en, life, micro | 1 CommentTags: comics, xkcd

(via xkcd.com, go there to see the full-size image)
Did you know that:
Each [xkcd] comic also has a tooltip, specified using the title attribute in HTML. The text usually contains an afterthought or annotation related to that day’s comic.
Интуитивный логик Фрейд
2007-09-08 at 05:29 | In micro, quote, think | Leave a CommentНашей лучшей надеждой на будущее является то, что интеллект — дух научности, разум — со временем установит диктатуру в душевной жизни человека. Сущность разума является гарантией того, что тогда он отведёт достойное место человеческим чувствам и тому, что ими определяется.
Фрейд З. Лекции по введению в психоанализ и Новый цикл. — Фирма СТД, 2003. — urn:isbn:5-898-08028-7
Multi-threaded map() for Python
2007-09-05 at 04:39 | In devel, lang:en, talk | 8 CommentsTags: concurrency, gil, python
The idea of multi-processing map() for Python is quite nice. And what about multi-threaded one? Threads usually cause less overhead than processes. If a mapping function is quite side-effect free (even if it does some HTTP GETs — they are idempotent), you don’t rely on a parallel execution model you’ve selected. And when it isn’t, then such an approach is error-prone. I’ve implemented a very simple threaded exception-aware map() using one thread per call. This is the basic usage scenario:
@measured
def single_threaded():
return [urlopen(url) for x in range(count)]
@measured
def multi_threaded():
return map(lambda x: urlopen(url), range(count))
ps_s = single_threaded()
ps_m = multi_threaded()
The results for url = "http://ya.ru/" and count = 1000:
single_threaded() is finished in 121.333 s
multi_threaded() is finished in 29.692 s
A multi-threaded map() is rather useful, isn’t it?
P. S. The first exception in a map() thread will be re-raised (with its traceback) in the main thread while others will be suppressed.
List of Triples to Dict of Dicts
2007-09-03 at 04:45 | In devel, fun, lang:en, think | Leave a CommentSuppose you (a Pythonic person) have got a list of triples, and you need to convert it to a dict of dicts, where the first two items of a triple are the keys and third item is the value, e. g.:
l = [(lambda x: (x % 2, x, -x))(x) for x in range(6)]
This results in: [(0, 0, 0), (1, 1, -1), (0, 2, -2), (1, 3, -3), (0, 4, -4), (1, 5, -5)]. And you need something like this: {0: {0: 0, 2: -2, 4: -4}, 1: {1: -1, 3: -3, 5: -5}}.
Let’s say you like functional programming. So here is a Haskell-like function that you could write:
def mk_2d_dict(triples_list):
"list of triples to 2d-dictionary"
def mk(xs, t):
tk, tv = t[0], t[1:]
if tk in [xk for xk, kv in xs]:
return [(xk, xv) for xk, xv in xs if xk != tk]
+ [(xk, (xv + [tv])) for xk, xv in xs if xk == tk]
else:
return xs + [(tk, [tv])]
return dict((k, dict(v)) for k, v in reduce(mk, triples_list, []))
r = mk_2d_dict(l)
print r, r[1][3]
But in fact, if your keys are always used as a pair, then you could combine them into a single key! This leads to a very simple solution:
r = dict((x[:-1], x[-1]) for x in l)
print r, r[(1, 3)]
So think twice about your domain before starting to program! ;)
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.





