ときどきの雑記帖 倒行逆施編

最新ページへのリンク
目次ページへのリンク

一つ前へ 2015年5月(上旬)
一つ後へ 2015年5月(下旬)

ホームへ

2015年05月20日

■_

Gのレコンギスタ。ほぼ三ヶ月(1クール)ズレで 本放送(TBS)→BS11→MXと放映してるのを観てる。 見落としていたこと、気がつかなかったことが結構あるので 三度目でも割と楽しいw

■_

2015年05月19日

■_

いっかいやすみ

2015年05月18日

■_

日曜深夜のMX での ウルトラQ や怪奇大作戦を毎週楽しみにしているのですが 深夜枠でも良いのでこういった雰囲気の新作作られないかなあ。などと。 いやまあこの二作品リメイクありますけど。

■_

2015年05月17日

■_

山手線のホームドア、だんだんと設置されてる駅が増えてきてますね。 秋葉原も今週末辺りに設置(稼働はまだ?)されるとかなんとか。 右上(笑)の方はよくわからないんですが、普段見かけるところは気がつけば結構あるなという感じです。 渋谷はまあ当然として、新宿、代々木、品川あたりがまだ未設置? JR山手線のホームドア整備状況と今後(大井町が追加) - Yahoo!知恵袋

JR山手線のホームドア整備状況と今後(大井町が追加) - Yahoo!知恵袋

山手線のホームドア使用開始計画(実績)

※使用開始とは、ホームドアが開閉動作を始める日(初電から)

2010年度:恵比寿、目黒

2012年度:大崎(2012年12月)、池袋(2013年3月)

2013年度:大塚4月、巣鴨6月、駒込8月、新大久保9月、目白11月、高田馬場12月、田町2014年3月

2014年度:御徒町、鶯谷、田端、有楽町、原宿、五反田、西日暮里

2015年度:神田、上野、秋葉原、代々木、日暮里

2015年度以降:(大規模改良予定)品川、浜松町、新橋、東京、新宿、渋谷

あ、代々木も今年度予定なんだ。 上記の一覧には2015年度の詳細がないけど、調べたところでは 6月に秋葉原で稼働開始、代々木の設置が11月、日暮里と上野もその辺りで、 神田が2016年に入ってからという感じらしい。 ところで浜松町ってまだだったのね。どこかと混同してたのかな。 大規模改良予定ともあるのは、新橋と併せてモノレール延伸でごにょごにょ?

そういえば、新宿のゴジラって山手線の車中からでも見えるんですね(一部だけど)。

その数式、プログラムできますか?
その数式、プログラムできますか? 某書店で先行販売されてたのを購入(原著持ってるのに…)。 ざざっと目を通したところとても面白そうです(原著持ってるのに何を)。 半群とかモノイドとか群とかあの辺が出てきて詳しい人に聞きたいこともあるんだけど 最近ご無沙汰だなあ色々。

あら。なんかすでにGoogleブックスに? その数式、プログラムできますか? - アレクサンダー・A・ステパノフ, ダニエル・E・ローズ - Google ブックス ま、いいやたとえば このため、Aは非可換加法半群(noncomutative additive semigroup) ということになります。 これは、可換性が要求されないのであって、許可されないのではありません。 つまり、すべての(可換)加法半群は非可換加法半群でもあります。 この辺りなんか頭の上に?が三つくらい浮かんでますw いやまあ日本語の「非」のイメージに引っ張られすぎだとは思うんですけど。

「ティンカリングをはじめよう」の原著ってこれかな Make: Tinkering - O'Reilly Media

がーん。配布してたの知らなかった○| ̄|_

■_

■_

これも先行販売だったのを買った。 知能の物語
知能の物語

ん、↑をAmazonリンクを探したときに見つかったこれなんか面白そう なぜ人類のIQは上がり続けているのか? --人種、性別、老化と知能指数
なぜ人類のIQは上がり続けているのか? --人種、性別、老化と知能指数

これも買ってた。 予定外だったけど(先行販売の弐冊だけのつもりだった)面白そうだったので 一人称研究のすすめ: 知能研究の新しい潮流
一人称研究のすすめ: 知能研究の新しい潮流

■_

How I do my Computing HN でなんか流れてきたので(でも特段最近書かれた何かに対する反応ではなかった?) 読んでみた。

このあたりにちょっと興味を惹かれた。

How I do my Computing

My favorite programming languages are Lisp and C. However, since around 1992 I have worked mainly on free software activism, which means I am too busy to do much programming. Around 2008 I stopped doing programming projects. As a result, I have not had time or occasion to learn newer languages such as Perl, Python, PHP or Ruby.

I read a book about Java, and found it an elegant further development from C. But I have never used it. I did write some code in Java once, but the code was in C and Lisp (I simply happened to be in Java at the time).

By contrast, I find C++ quite ugly.

I skimmed documentation of Python after people told me it was fundamentally similar to Lisp. My conclusion is that that is not so. `read', `eval', and `print' are all missing in Python.

2015年05月16日

■_

すっげー古いスターウォーズのサントラを図書館で借りたんですよ。 んで、その解説書を読んでたら「ジェダイの騎士の最後の生き残りハン・ソロ」という一文が。 …え、そうだったっけ?

それはさておき インペリアル・マーチ - Wikipedia を聴きたかったのだけど 正式には『帝国のマーチ(ダース・ベイダーのテーマ)』 (英: The Imperial March (Darth Vader's Theme)) は、『スター・ウォーズ エピソード5/帝国の逆襲』で初めて使用された、ジョン・ウィリアムズ作曲の映画音楽の曲である。 ぐはっ。そうだった。

■_

2015年05月15日

■_

劉邦(上)
劉邦(上) 宮城谷さん劉邦書いてる(現在進行形)んだ。 去年、湖底の城の刊行が例年より遅い月だったのもこの影響?

■_

■_

Improving kernel string handling [LWN.net] で strscpy なる関数が紹介されているのだけど

Improving kernel string handling [LWN.net]

The handling and parsing of string data has long been acknowledged as a fertile breeding ground for bugs and security issues; that is doubly true when the C language — whose string model leaves a bit to be desired — is in use. Various attempts have been made to improve C string handling, both in the kernel and in user space, but few think that the problem has been solved. A couple of current projects may improve the situation on the kernel side, though.

String copying

The venerable strcpy() family of functions has long been seen as error-prone and best avoided. In most settings,
they are replaced with functions like strncpy() or strlcpy(). The last time your editor wrote about criticisms
of strlcpy(), he was treated to a long series of incendiary emails from one of its supporters. So, for the
purposes of this article, suffice to say that not all developers are fond of those functions. Even so, the kernel
contains implementations of both, and there are over 1,000 call sites for each.

That doesn't mean that there isn't room for improvement, though. Chris Metcalf thinks he has an improvement in
the form of the proposed strscpy() API, which provides two new functions:

    ssize_t strscpy(char *dest, const char *src, size_t count);
    ssize_t strscpy_truncate(char *dest, const char *src, size_t count);

で、strlcpyはというとこう strlcpy(3)

strlcpy(3)
SYNOPSIS
     #include <string.h>

     size_t
     strlcpy(char * restrict dst, const	char * restrict	src, size_t size);

     size_t
     strlcat(char * restrict dst, const	char * restrict	src, size_t size);

ふむ。strscpy はエラーのときに負の値を使うので戻り値の型が ssize_t だけど strlcpy は size_t だと。

そういえばこういうのもあったですね strcpy_s、wcscpy_s、_mbscpy_s

strcpy_s、wcscpy_s、_mbscpy_s

errno_t strcpy_s(
   char *strDestination,
   size_t numberOfElements,
   const char *strSource 
);
パラメーター

strDestination     追加先の文字列バッファーの場所。
numberOfElements   追加先の文字列バッファーのサイズ。
strSource          null で終わる元の文字列バッファー。

戻り値             正常に終了した場合は 0 を返し、それ以外の場合はエラーを返します。

■_

なぞのすくりぷと

irb(main):009:0> (0..31).collect{|e| [sprintf("%05b",e), e[0]+e[1]+e[2]*2+e[3]3+e[4]*5]}
=> [["00000", 0], ["00001", 1], ["00010", 1], ["00011", 2], ["00100", 2], ["00101", 3], ["00110", 3],
["00111", 4], ["01000", 3], ["01001", 4], ["01010", 4], ["01011", 5], ["01100", 5], ["01101", 6],
["01110", 6], ["01111", 7], ["10000", 5], ["10001", 6], ["10010", 6], ["10011", 7], ["10100", 7],
["10101", 8], ["10110", 8], ["10111", 9], ["11000", 8], ["11001", 9], ["11010", 9], ["11011", 10],
["11100", 10], ["11101", 11], ["11110", 11], ["11111", 12]]
irb(main):010:0>(0..31).collect{|e| [sprintf("%05b",e), e[0]+e[1]+e[2]*2+e[3]*3+e[4]*5]}.sort_by{|e| e[1]}
=> [["00000", 0], ["00001", 1], ["00010", 1], ["00100", 2], ["00011", 2], ["00101", 3], ["01000", 3],
["00110", 3], ["00111", 4], ["01001", 4], ["01010", 4], ["01011", 5], ["01100", 5], ["10000", 5],
["01110", 6], ["10010", 6], ["01101", 6], ["10001", 6], ["01111", 7], ["10011", 7], ["10100", 7],
["10101", 8], ["10110", 8], ["11000", 8], ["11010", 9], ["11001", 9], ["10111", 9], ["11011", 10],
["11100", 10], ["11110", 11], ["11101", 11], ["11111", 12]]

2015年05月14日

■_

はてなブックマーク - Less is more:プログラミング言語設計の進歩史 | POSTDYukihiro MatsumotoさんはTwitterを使っています: "link: Less is more: language features - http://t.co/eXNBj9cbq4" の、(日本語圏での)反応の違いを見ると色々と思うところが (わたしの見た範囲ではtwitterでも見かけるのが増えたのは翻訳記事が出てから)。

■_

■_

1バイトの都市伝説 あれ? こんな断り書き昼間見たときにはあったかな 「都市伝説シリーズ」は「教科書」ではありません。勿論「学術論文」でもありません。 「Wikipedia」でもなければ、「貴方のレポートを手助けするボランティア」でもありません。 「出典を明示せよ」とか「証拠を示せ」などという野暮な事を言うのは御遠慮下さい。 信じる信じないは貴方自身の自己判断でお願いします。 誤記(オクテッド(octed))も訂正されてた わざわざ純粋に8bitを表す言葉として「オクテット(octet)なる言葉までもが使われる様になりました。

まあそれはさておき ISO(国際標準化機構)やIEC(国際電気標準会議)が「1バイトは8bitとしましょう」 という意見を採択したのは2008年です。 の部分。てきとーにぐぐるとやっぱりうぃきぺ(英語)が上位で引っかかってきて

Byte - Wikipedia, the free encyclopedia

Byte - Wikipedia, the free encyclopedia

The size of the byte has historically been hardware dependent and no definitive standards existed that mandated the size. The de facto standard of eight bits is a convenient power of two permitting the values 0 through 255 for one byte. The international standard IEC 80000-13 codified this common meaning. Many types of applications use information representable in eight or fewer bits and processor designers optimize for this common usage. The popularity of major commercial computing architectures has aided in the ubiquitous acceptance of the 8-bit size.[3]

The unit octet was defined to explicitly denote a sequence of 8 bits because of the ambiguity associated at the time with the byte.[4]

ふむ。The unit octet was defined to と過去形使ってるのはそういうことなんですかね。 それから IEC 80000-13 てのが出てきたのでこれを辿ると…… payment wall の向こう側ですねえ。 IEC 80000-13:2008 - Quantities and units -- Part 13: Information science and technology

■_

さて「ゴミ捨て」の話。 もうちょっと状況を詳しく書くと、駅の構内にある公衆トイレに貼られていた注意書きにあったものです。 とすると、ペットボトルだとかスターバックスなんかのテイクアウト容器などをそこいらに放置していくな というのが主な目的である気がします。 なわけで「please」つけるのは丁寧すぎないかなあと考えたのでした。 throw away garbage も含めて直訳というか機械翻訳っぽく感じるし。

和英辞典で「捨てる」をひいたら、細かなニュアンスの違いは別として、 結構な数の単語(とイディオム)が出てきたのにちょっとびっくり。 捨てるの英語・英訳 - 英和辞典・和英辞典 Weblio辞書 あれ。持ってた電子辞書では「litter」もあったんだけどな。 litterの意味 - 英和辞典 Weblio辞書

2015年05月13日

■_

アナザーストーリーズ「アイルトン・セナ事故死 不屈のレーサー 最期の真実」 - NHK を観た。 この事故は1994年のことなのだけど、 (事故とは関係なく)その半月ほどあとから北米某所に長期出張に出たり (ちょうどワールドカップ米国大会の時期が被ってたのだけどさすがに行けなかったw そういえばメジャーリーグのストもこの年じゃなかったか)したのだけど、 それも含めてこの近辺の年(1992~1995くらい) は今振り返ると個人的にも色々あったなあ。などと。

1994年から1995年のMLBストライキ - Wikipedia アイルトン・セナ - Wikipedia

■_

■_

ああっ。「ここにごみを捨てないでください」の方見逃してた。ありがとうございます。 補足その他改めて書きます。 Island Life - 指数表記 Island Life - ここにごみを捨てないでください

2015年05月12日

■_

カタカナで「インフラ」と書くと、まあ infrastructure を指してるだろうことは確定的なんでしょうが、 最近(でもないか)よく見かける「インフラエンジニア」。 そもそも infra- (なぜかここでアルファベット表記に戻す)ってのは 接頭辞なわけで infra-engineer となると(ry

オライリーの近刊書籍にあった ティンカリングをはじめよう 978-4-87311-726-3 \3,024 2015年06月 の、ティンカリングってなんじゃらほいと思ったのだけど、 Tinkering | 理数工教室 池田塾 色々意味があるようですね。

■_

■_

遅いッ!遅すぎるッ!Java の正規表現のお話。 | Cybozu Inside Out | サイボウズエンジニアのブログ はてなブックマーク - 遅いッ!遅すぎるッ!Java の正規表現のお話。 | Cybozu Inside Out | サイボウズエンジニアのブログ これなんですが、 バックトラック(と '|'の合わせ技)の組み合わせ爆発が原因とか、 RE2/J を使おうといったところは文句ないんですが

Pattern (Java Platform SE 8 )

文字クラス
[abc] 	a、b、またはc (単純クラス)
[^abc] 	a、b、c以外の文字(否定)
[a-zA-Z] 	a - zまたはA - Z (範囲)
[a-d[m-p]] 	a - dまたはm - p: [a-dm-p] (結合)
[a-z&&[def]] 	d、e、またはf (交差)
[a-z&&[^bc]] 	a - z (bとcを除く): [ad-z] (減算)
[a-z&&[^m-p]] 	a - z (m - pを除く): [a-lq-z] (減算)
 

上記の説明にはそのものズバリな例はありませんが ひとつの [] の中に \w と _ (あるいは元々のデータにある -\\%_+!/=.でも)を まとめて置けるので、 | を使わず [\\w-\\%+!/=.]とできます。 これでも組み合わせ爆発による指数関数的な処理時間の増加は避けられます。

import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexTest {
    public static String dup(String str, int count) {
        StringBuffer buf = new StringBuffer();
        for (int i=0; i<count; ++i) {
            buf.append(str);
        }
        return buf.toString();
    }
    private static void regex_test(Pattern mail_regex, String text) {
        long t0 = System.currentTimeMillis();
        Matcher m = mail_regex.matcher(text);
        boolean matched = m.matches();
        System.out.println(matched ? m.group() : "no match.");
        long t1 = System.currentTimeMillis() - t0;
        System.out.println(String.format("%d : %s ms\n", text.length(), t1));
    }
    public static void main(String[] args) throws Exception {
        regex_test(Pattern.compile("(\\w|_){1,64}@"), dup("_", 10));
        regex_test(Pattern.compile("(\\w|_){1,64}@"), dup("_", 20));
        regex_test(Pattern.compile("(\\w|_){1,64}@"), dup("_", 30) + "@");
        regex_test(Pattern.compile("[\\w_]{1,64}@"),  dup("_", 64));
        regex_test(Pattern.compile("([\\w-\\%+!/=.]){1,64}@"), "foo-bar+hoge.fuga");
    }
}
>java RegexTest
pattern: (\w|_){1,64}@
input: __________
no match.
time: 9ms

pattern: (\w|_){1,64}@
input: ____________________
no match.
time: 795ms

pattern: (\w|_){1,64}@
input: ______________________________@
match text: ______________________________@
time: 2ms

pattern: ([\w-\%+!/=.]){1,64}@
input: foo-bar+hoge.fuga@
match text: foo-bar+hoge.fuga@
time: 2ms

pattern: ([\w-\%+!/=.]){1,64}@
input: foo-bar+hoge.fuga
no match.
time: 2ms

ということで。 Regular Expressions Will Stab You in the Back : programming Regular expressions will stab you in the back ←

■_

Nim Programming Language 0.11.0 released | Hacker News の中にあった

The argument of white space or braces is largely a religious one. Any argument for one case is equally valid for the other as well and it usually just boils down to people trying to justify personal preference. eg:

    Python: white space is a great way to keep things readable as more people touch the code.
    Perl / PHP / etc: braced blocks is a great way to keep things readable if the formatting breaks.
    Python: People can get lost in braces.
    Perl et al: People can forget to tab.

にちょっとウケた。

■_

Anti-Patterns Every Programmer Should Be Aware Of | Hacker News 9 Anti-Patterns Every Programmer Should Be Aware Of から。

List of anti-patterns covered:
    1   Premature Optimization
    2   Bikeshedding
    3   Analysis Paralysis
    4   God Class
    5   Fear of Adding Classes
    6   Inner-platform Effect
    7   Magic Numbers and Strings
    8   Management by Numbers
    9   Useless (Poltergeist) Classes

■_

difference - 言語比較 > 10のべき数を表す記号 > D / E / *10^ - Qiita D って FORTRAN 以外でも使ってた? んで、うぃきぺをみると Scientific notation - Wikipedia, the free encyclopedia

FORTRAN also uses "D" to signify double precision numbers. はともかくとして The ALGOL 60 programming language uses a subscript ten "10" character instead of the letter E, for example: 6.02214151023 The ALGOL 68 programming language has the choice of 4 characters: e, E, \, or 10. By examples: 6.0221415e23, 6.0221415E23, 6.0221415\23 or 6.02214151023. なんぞ。

■_

Go Lang: Comments Are Not Directives | Hacker News に、

Go 1.4 starts to use comments as directives. I think that is a realy bad path to go on the long run. You see its beginnings in following 3 examples:

  # used to set a canonical import path for a package: //import "foo"
  # used to generate code: //go:generate bar
  # used to document the result of a example function: //Output: foo
  

というのがあるんですが、そういえば コメントに埋め込まれたコンパイラディレクティブの起源ってなんだろうと。Turbo Pascal?

うぃきぺによると Directive (programming) - Wikipedia, the free encyclopedia

Directives date to ALGOL 68, where they are known as pragmats (from "pragmatic"), and denoted pragmat or pr; in newer languages, notably C, this has been abbreviated to "pragma" (no 't'). とか In Turbo Pascal, directives are called significant comments, because in the language grammar they follow the same syntax as comments. とか。最初に使われたのは ALGOL 68で、コメント中に埋め込まれたそれは Turbo Pascal。 ということで良いのかな?

2015年05月11日

■_

【NHKスペシャル】ここがヘンだよ生命大躍進 第1集「そして"目"が生まれた」 - Togetterまとめ 歴史もそうだけど、昔覚えたことがどんどん「時代おくれ」になるのねえ。 エディアカラ生物群 - Wikipedia バージェス動物群 - Wikipedia ミロクンミンギア - Wikipedia そういえばわしらががきんちょの頃は恐竜の歩き方も違っていたのだったなw

infra-

■_


一つ前へ 2015年5月(上旬)
一つ後へ 2015年5月(下旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp