トップ «前の日記(2010-07-11) 最新 次の日記(2010-07-13)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|04|

2010-07-12 :-)

_ 朝ッ

0520 起床

_ 仕事

0830 出勤

_ ,

そおいえばまだ長谷川さん(仮名)に挨拶してない

_ 居室に閉じ込められた

入室退室時に ID カードを出入り口に設置されているカードリーダーにかざして、入室と退室が必ず対(つい)になるようにしておく必要があるんだが

  1. 退室しようとしてかざす
  2. ( 扉の鍵が開く )
  3. 忘れ物を取りに自席へ戻る
  4. ( 扉閉まる )
  5. もう開かない

鍵を持ってるが外に出られないという事態に陥った。他の誰かに開けてもらうしかない。

追記: と思ったらリセットする方法があるらしい。ってそれ 3 年前にも聞いたな

_ [Python][デザインパターン][Singleton]Python でデザインパターン - Singleton

Ruby で書いたアレ[ 20090507#p05 ]を 1 対 1 で書き換える。

こんなんでいいのか?

#!/usr/bin/python
# -*- coding:utf8 -*-

# ruby コードを書き換える
# http://www.area51.gr.jp/~rin/diary/?date=20090507#p05
#

class Singleton:
    __instance = None

    def get_instance(self):
        if Singleton.__instance != None:
            return Singleton.__instance
        else:
            Singleton.__instance = 0
            return Singleton.__instance


print Singleton().get_instance()

ActiveState Code にこんなのがあった。ディクショナリを使ってる。

class Singleton(type):
    def __init__(self, *args):
        type.__init__(self, *args)
        self._instances = {}

    def __call__(self, *args):
        if not args in self._instances:
            self._instances[args] = type.__call__(self, *args)
        return self._instances[args]


class Test:
    __metaclass__ = Singleton
    def __init__(self, *args):
        pass

ta1, ta2 = Test(), Test()
assert ta1 is ta2

tb1, tb2 = Test(5), Test(5)
assert tb1 is tb2

assert tb1 is not tb2

_ [Python][デザインパターン][Command]Python でデザインパターン - Command

書き換え[ 20090507#p06 ]

#!/usr/bin/python
# -*- coding:utf8 -*-

# ruby コードを書き換える
# http://www.area51.gr.jp/~rin/diary/?date=20090507#p06
#

class Command:
    def execute(self):
        return

class Command1(Command):
    def execute(self):
        print "皇帝陛下ですね?"

class Command2(Command):
    def execute(self):
        print "そうだ。"

class Command3(Command):
    def execute(self):
        print "妹ロックブーケのカタキです。殺らせていただきます。"


class Noel:
    def __init__(self):
        self.slot = []

    def add(self, command):
        self.slot.append(command)

    def run(self):
        for c in self.slot:
            c.execute()


def main():
    noel = Noel()
    noel.add(Command1())
    noel.add(Command2())
    noel.add(Command3())
    noel.run()

main()