2010-01-01から1年間の記事一覧

引越ししました

このはてだから別のはてだへ引越しをしました。新しいところは↓です。 http://d.hatena.ne.jp/cafistar/

現在の timestamp と microsecond をつなげた文字列が欲しい

これで何かをするわけではないが、必要になったので書いた。 import datetime import time def __get_timestr_by_now(): now = datetime.datetime.now() micro_str = str(now.microsecond).zfill(6) time_str = str(int(time.mktime(now.utctimetuple()))) r…

文字列比較

気になったので比較して結果を確認した。 # -*- encode: utf-8 -*- if u'0' < u'1': print '0 < 1' if u'1' < u'2': print '1 < 2' if u'2' < u'3': print '2 < 3' if u'3' < u'4': print '3 < 4' if u'4' < u'5': print '4 < 5' if u'5' < u'6': print '5 <…

同じ値を複数の変数に代入する

もしかして邪道なのかな。 st1 = 'a' st2 = 'b' st3 = st4 = st1 print st1 # => 'a' print id(st1) # => 26430944 print st2 # => 'b' print id(st2) # => 26431008 print st3 # => 'a' print id(st3) # => 26430944 print st4 # => 'a' print id(st4) # =>…

指定したdatetime値でのfilter

ユーザー一覧の表示などする時には fetch() を使っていた。しかしこれでは1000件の壁にぶち当たる。そこで datetime 値での filter を使用した。 こんなモデルがあったとする from google.appengine.ext import db class Member(db.Model): insert_datetime …

管理したくないファイルを拡張子で指定

git

「*.pyc」ファイルは管理しなくていいだろ、ということで。 リポジトリに「.gitignore」ファイルを作成 「.gitignore」ファイルへ以下のように記載*/**/*.pyc コミット > cd C:\sample > echo '' > .gitignore ## .gitignore ファイル編集 ## Git 起動 $ cd …

git add した時に出る改行コードのwarning対応

ファイル内の改行コードが「LF」の際に出たワーニングに対応したメモ $ git add . warning: LF will be replaced by CRLF in appl/views.pyなにやら Git が改行コードを CRLF へ変更しようとするらしい。 で、以下を実行 $ git config --global core.autoCRL…