Fail safe

31 08 2008

По темата с доктор Стрейнджлав тази вечер изгледахме Fail Safe (2000). Много, много добър филм. И по-тежък от комедията на Кубрик. И ако ви се струва, че темата вече не е актуална, обърнете внимание, че конкретно този филм е създаден през 2000-та година и то доста основателно, струва ми се.

Ето няколко любими цитати от тази версия на Fail Safe (оригиналът е от 1964):
-I think I know what you're worried about.
Somebody goes nuts in here,
the bombs go off and the world blows up.
No way. We have checks upon checks.
Fail Safe procedures–

-That don't depend on humans.

-That's the scariest thing I've heard since I came in here.

- We make them as foolproof as we can.
- Maybe you ought to have a ''fool safe'' procedure. Protect us from the fools in the world.

-After Blue, we still have to go to
Condition Yellow, Condition Green…
…and then Condition Red.

-And Condition Red is?

-War.



Аз се чудя защо съм цъфнал и вързал

30 08 2008

А то било защото инфлацията била едноцифрена. Явно цената на пианата и виолончелатата пада…



Понякога PERL ме кефи повече от Python

26 08 2008

Идеята да мога програмно да публикувам в блога си ми хрумна когато въвеждам книги и филми в една програма каталог – gcstar. Та идеята е като въведа нова книга или нов филм вътре gcstar автоматично да публикува предефинирано съобщение за това че съм купил съответното нещо, или ако въведа коментар – да го публикува. Така ще ми спести доста време.
И понеже gcstar е писана на PERL, реших да проверя как стои въпросът с публикуване в livejournal чрез PERL.
Отидох на онлайн хранилището за pERL модули, наречено CPAN и намерих модула LJ-Simple-0.15. Чрез него програма, която публикува във вашия блог изглежда така:

use LJ::Simple;

LJ::Simple::QuickPost(
user => “test”,
pass => “test”,
entry => “Just a simple entry”,
) || die “$0: Failed to post entry: $LJ::Simple::error\n”;

Уникално, а?
Най-много ми харесва скоростта, с която се решават проблеми чрез CPAN. Трябва ти някаква функционалност, търсиш в CPAN, намираш нужния ти модул, инсталираш го, копираш примера от задължителната документация и имаш работещо решение. Гениално!



431

26 08 2008

Just a simple entry



‘110497′

26 08 2008

Just a simple entry



python livejournal

26 08 2008

Днес реших да потърся начин да публикувам в блога си програмно чрез Python. След тестване на различни кодове успях да модифицирам този – http://hewgill.com/ljdump/ и се получи следното приложенийце, с което публикувах предишния запис:

#!/usr/bin/python

#
# ljdump.py – livejournal archiver
# Greg Hewgill <greg@hewgill.com> http://hewgill.com
# Version 1.2
#
# $Id: ljdump.py 17 2006-09-08 08:46:56Z greg $
#
# This program reads the journal entries from a livejournal (or compatible)
# blog site and archives them in a subdirectory named after the journal name.
#
# The configuration is read from “ljdump.config”. A sample configuration is
# provided in “ljdump.config.sample”, which should be copied and then edited.
# The configuration settings are:
#
#   server – The XMLRPC server URL. This should only need to be changed
#            if you are dumping a journal that is livejournal-compatible
#            but is not livejournal itself.
#
#   username – The livejournal user name. A subdirectory will be created
#              with this same name to store the journal entries.
#
#   password – The account password. This password is never sent in the
#              clear; the livejournal “challenge” password mechanism is used.
#
# This program may be run as often as needed to bring the backup copy up
# to date. Both new and updated items are downloaded.
#
# LICENSE
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the author be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
#    claim that you wrote the original software. If you use this software
#    in a product, an acknowledgment in the product documentation would be
#    appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
#    misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# Copyright (c) 2005-2006 Greg Hewgill

import codecs, md5, os, pickle, pprint, re, sys, urllib2, xml.dom.minidom, xmlrpclib
from xml.sax import saxutils

def calcchallenge(challenge, password):
    return md5.new(challenge+md5.new(password).hexdigest()).hexdigest()

def flatresponse(response):
    r = {}
    while True:
        name = response.readline()
        if len(name) == 0:
            break
        if name[-1] == '\n':
            name = name[:len(name)-1]
        value = response.readline()
        if value[-1] == '\n':
            value = value[:len(value)-1]
        r[name] = value
    return r

def getljsession(username, password):
    r = urllib2.urlopen(Server+”/interface/flat”, “mode=getchallenge”)
    response = flatresponse(r)
    r.close()
    r = urllib2.urlopen(Server+”/interface/flat”, “mode=sessiongenerate&user=%s&auth_method=challenge&auth_challenge=%s&auth_response=%s” % (username, response['challenge'], calcchallenge(response['challenge'], password)))
    response = flatresponse(r)
    r.close()
    return response['ljsession']

def dochallenge(params, password):
    challenge = server.LJ.XMLRPC.getchallenge()
    params.update({
        'auth_method': “challenge”,
        'auth_challenge': challenge['challenge'],
        'auth_response': calcchallenge(challenge['challenge'], password)
    })
    return params

config = xml.dom.minidom.parse(“ljdump.config”)
Server = config.documentElement.getElementsByTagName(“server”)[0].childNodes[0].data
Username = config.documentElement.getElementsByTagName(“username”)[0].childNodes[0].data
Password = config.documentElement.getElementsByTagName(“password”)[0].childNodes[0].data

m = re.search(“(.*)/interface/xmlrpc”, Server)
if m:
    Server = m.group(1)

print “Fetching journal entries for: %s” % Username
try:
    os.mkdir(Username)
    print “Created subdirectory: %s” % Username
except:
    pass

ljsession = getljsession(Username, Password)

server = xmlrpclib.ServerProxy(Server+”/interface/xmlrpc”)

newentries = 0
newcomments = 0
errors = 0

lastsync = “”
lastmaxid = 0
try:
    f = open(“%s/.last” % Username, “r”)
    lastsync = f.readline()
    if lastsync[-1] == '\n':
        lastsync = lastsync[:len(lastsync)-1]
    lastmaxid = f.readline()
    if len(lastmaxid) > 0 and lastmaxid[-1] == '\n':
        lastmaxid = lastmaxid[:len(lastmaxid)-1]
    if lastmaxid == “”:
        lastmaxid = 0
    else:
        lastmaxid = int(lastmaxid)
    f.close()
except:
    pass
origlastsync = lastsync

r = server.LJ.XMLRPC.login(dochallenge({
    'username': Username,
    'ver': 1,
    'getpickws': 1,
    'getpickwurls': 1,
}, Password))
userpics = dict(zip(r['pickws'], r['pickwurls']))
userpics['*'] = r['defaultpicurl']

r = server.LJ.XMLRPC.syncitems(dochallenge({
        'username': Username,
        'ver': 1,
        'lastsync': lastsync,
    }, Password))
    #pprint.pprint(r)
e = server.LJ.XMLRPC.postevent(dochallenge({
                    'username': Username,
                    'ver': 1,
                    'selecttype': “one”,
                    'event': 'please work',
                    'subject':'test',
                    'year':'2008',
                    'mon':'8',
                    'day':'26',
                    'hour':'12',
                    'min':'8' 
                }, Password))



test

26 08 2008

please work



Dr. Strangelove

18 08 2008

или как и аз спрях да се притеснявам и заобичах бомбата…
Филмът на Кубрик от 1964 е истински шедьовър, макар че да си призная на мен въобще не ми беше смешно, прекалено реалистично ми беше всичко. Ако искате да знаете за какво става въпрос, мислете за него като за първообраза на Fail safe, само че с по-гротескни образи.
Ако си падате по Кубрик, черно-белите филми и сте се замисляли или искате да се замислите за един възможен край на света – гледайте го.

Също така, ако смятате да гледате филма може би е по-добре да прочетете част от любимите ми цитати от филма в последствие.
“Goldie, how many times have I told you guys that I don't want no horsing around on the airplane? ”
“Gentlemen, you can't fight in here! This is the War Room. ”
“Gee, I wish we had one of them doomsday machines. ”
“I can no longer sit back and allow Communist infiltration, Communist indoctrination, Communist subversion and the international Communist conspiracy to sap and impurify all of our precious bodily fluids. ”
“- There's nothing to figure out, General Turgidson. This man is obviously a psychotic.
- We-he-ell, uh, I'd like to hold off judgement on a thing like that, sir, until all the facts are in. “



Не че нещо за българските жени, ама…

17 08 2008

нали…
Връща се мъж от командировка в столицата и разказва на приятел:

- Вървя си аз по “Дондуков”. Гледам табела “Публичен дом”. Естествено влязох. А вътре две врати – “Професионалистки” и “Аматьорки”. Аз разбира се влизам при професионалистките. Вътре нови две врати – “Брюнетки” и “Блондинки”. Влизам при блондинките. Там нови две врати – “Слаби” и “Дебели”. Аз влизам при слабите. Нови две врати – “С извращения” и “Без извращения”. Естествено, влизам при извращенията.

- Е, и какво?

- Нищо, отново се озовах на “Дондуков”!



И турците няма да ги стигнем скоро

14 08 2008

http://www.pardus.org.tr/eng/index.html