by shigemk2

当面は技術的なことしか書かない

読書ノート

エキスパートPythonプログラミング イテレータ

iter組み込み関数にシーケンスを渡すと、イテレータを作成することが出来る。 シーケンスの要素をすべて取り出し終わると、StopIteration例外が発生する。 09-000237.py # -*- coding: euc-jp -*-" i = iter('abc') print next(i) # a print next(i) # b pri…

エキスパートPythonプログラミング 内包表記

07-190820.py # -*- coding: euc-jp -*-" # リストを操作するコードをループごとにインタプリタ上で処理している # カウンタの操作もループごとにインタプリタ上で処理する必要がある size = 10 L = [] i = 0 while i < size: if i % 2 == 0 and i != 4: L.a…

JavaScript Ninjaの極意 7 正規表現のエレガンス

文字列が特定のパターンと一致するかテストする <html> <head> <meta charset="utf-8"> <title>Listing 7.1</title> <script type="text/javascript" src="../scripts/assert.js"></script> <link href="../styles/assert.css" rel="stylesheet" type="text/css"> </head> <body> <script type="text/javascript"> function isThi…</body></html>

JavaScript Ninjaの極意 4 オブジェクト

関数はプロパティを持つことが出来、メソッドを持つことが出来、変数やプロパティに 代入することができるが、「呼び出すことが出来る」という特殊能力ももつ。 <html> <head> <meta charset="utf-8"> <title>Listing 4.8</title> <script type="text/javascript" src="../scripts/assert.js"></script> <link href="../styles/assert.css" rel="stylesheet" type="text/css"> </head> …</html>

ノウアスフィアの開墾14 ノウアスフィア的所有権となわばりの動物行動学

Webページを持つプロジェクトは、ノウアスフィアで近所を探検している人にずっと認知されやすい。リンクする人もいるだろうし、サーチエンジンにもひっかかる。Webページは、だから広告としても優れているし、パフォーマンス行為としても有効だし、領土主張…

JavaScript Ninjaの極意 2 テストとデバッグの装備

非同期テストの例 <html> <head> <title>Test Suite</title> <script> (function() { var queue = [], paused = false, results; this.test = function(name, fn) { queue.push(function() { results = document.getElementById("results"); results = assert(true, name).appendChild( document</head></html>…

ノウアスフィアの開墾13 どれほどすばらしい贈り物?

仲間内の評判を戻すやりかた 期待させられたほどきちんと機能しないなら、それはダメーどんなに巧妙でオリジナリティ豊かなものであっても 既存の機能する領域を複製する作業よりは、ノウアスフィアを拡張する仕事のほうがいい 主要ディストリビューションに…

ノウアスフィアの開墾12 評判ゲームが持つ分野全体としての意義

評判ゲーム分析は、一見するとわかりにくいものかもしれない含蓄をもっと持っている。その多くは、既存のプロジェクトに協力するより成功プロジェクトを創始するほうが名声が高まるという事実から派生するものだ 人はハッカーを名乗ればハッカーになれるわけ…

ノウアスフィアの開墾11 謙虚さの美徳

ハッカー文化の報酬メカニズムにおいて名声が中心的なものだということがはっきりしたので、今度はなぜこの事実が半ば隠されて、ほとんど公認されないのかが重要と思われていたのかを理解しなけりゃならない。 いちばんすてきな自慢は、「とにかく動く」コー…

ノウアスフィアの開墾10 エゴの問題

ハッカー文化は意識的にエゴ中心主義と、エゴに基づく動機づけを信用せずに軽蔑する。自己宣伝は、コミュニティがそこから何か得るものがあるように見えるときでさえ、容赦なく批判されることが多い

ノウアスフィアの開墾9 所有権と評判によるインセンティブ

ノウアスフィアの開墾からの収益はわかった。それはハッカーの贈与文化における仲間内の評判だ。 他人が自分の作業を不当に横取りしたり、変な加工をしたりすれば、自分の評判が不当に落ちることになる 非公式パッチへの批判はそれがバグ追跡をものすごく難…

ノウアスフィアの開墾8 評判のさまざまな相貌

なぜ仲間内の評判(名声)が勝ち取るに足るものなのかにうちては、あらゆる贈与文化に共通する理由がある。 1 仲間内のよい評判はそれ自体が重要な報酬だからだ 2 名声は他人の注目を集めて協力を得るのにすごく有効な方法だ 3 もし贈与経済が交換経済や上意下…

ノウアスフィアの開墾7 ハッキングのよろこび

希少性の経済が働かないなら、仲間内の評価以外の尺度なんかありえないだろう。どうも、職人気質文化は結局のところ、評価ゲームを通じて組織されるしかないんじゃないか ハッカーが自分の行動を評判ゲームの一部として理解しているかどうかによらず、かれの…

継続的webサービス改善ガイド

なぜ「継続的webサービス改善」が必要なのか 何年続くwebサービスを構築し、ユーザに価値を提供しつづけるため 開発を行うべきかどうかを判断する尺度=価値/コスト→得られる価値を増大させる 費されるコストを減少させる 価値を増大させつつ、コストを減少さ…

ノウアスフィアの開墾4 所有権とオープンソース

ある物件が無限に複製可能で、いくらでも変えられて、そしてそれをとりまく文化が脅せるような権力関係や財の希少性に基づく経済に基づいていないとき、なにかの「所有権を持つってのはどういうことだろうか。 実はオープンソース文化に関するかぎり、この質…

ノウアスフィアの開墾3 贈与経済としてのハッカー文化

人間がもつ組織化の方法上意下達方式(希少な財の配分は中央権力が行い、それが軍事力でバックアップされる) 交換経済(交換と自発的な協力によって非中心的に行われる) 贈与経済(希少性ではなく過剰への適応)

97 Things Every Programmer Should Know 97 Your Customers Do Not Mean What They Say

The problem is that customers don't always tell you the whole truth. They generally don't lie, but they speak in customer speak, not developer speak. They use their terms and their contexts. Just interact with them more. Remember: they did…

97 Things Every Programmer Should Know 96 You Gatta Care About the Code

Good programming is not born from mere technical competence. You want to write good code. You want to be a good programmer. So, you care about the code: In any coding situation, you refuse to hack something that only seems to work. You str…

ノウアスフィアの開墾5 ロックと土地所有権

突然の英米系哲学とコモンロー。 ハッカーあちが暗に主張している所有理論は、英米慣習法における土地所有権の理論とほとんどまったく同じなんだ! 開墾(homesteading)することで所有権を獲得できる。つまり、自分の労働を所有されていない土地に混ぜ込み、囲…

97 Things Every Programmer Should Know 95 Write Tests for People

YOU ARE WRITING AUTOMATED TESTS for some or all of your production code. Good tests act as documentation for the code they are testing. Describe the context, starting point, or preconditions that must be satisfied Illustrate how the softwa…

97 Things Every Programmer Should Know 94 Small Functions Using Examples

WE WOULD LIKE TO WRITE CODE THAT IS CORRECT, and have evidence on hand that it is correct. It can help with both issues to think about the "size" of a function. One way to find out what those types should be is to find the examples to chec…

97 Things Every Programmer Should Know 93 Write Code As If You Had to Support It for the Rest of Your Life

All advice is good, all principles are sound, and all stories are compelling, but where do you start? More important, once you have started, how do you keep up with all the best practices you've learned, and how do you make them an integra…

97 Things Every Programmer Should Know 92 When Programmers and Testers Collaborate

SOMETHING MAGICAL HAPPENS when testers and programmers start to collaborate. There is less time spent sending bugs back and forth through the defect tracking system. Less time is wasted trying to figure out whether something is really a bu…

Dive Into Python 3 1

Python2にはユニコード文字列と文字列があるが、Python3はバイト列と文字列の2つがある。 今やすべての文字列はユニコード文字列であり、バチオのかたまりを扱いたい場合は、bytes型を扱う必要がある。

97 Things Every Programmer Should Know 91 WET Dilutes Performance Bottlenecks

THE IMPORTANCE OF THE DRY PRINCIPLE (Don't Repeat Yourself) is that it codifies the idea that every piece of knowledge in a system should have a singular representation. In other words, knowledge should be contained in a single implementat…

97 Things Every Programmer Should Know 90 Verbose Logging Will Disturb Your Sleep

WHEN I ENCOUNTER A SYSTEM that has already been in development or production for a while, the first sign of real trouble is always a dirty log. Too much logging can be as useless as none at all. In general, the best indication that everyth…

97 Things Every Programmer Should Know 89 Use the Right Algorithm and Data Structure

Sometimes novice programmers just start typing away without really thinking, and suddenly they have "invented" bubble sort. They may even be bragging about it. Programmers should not reinvent the wheel, and should use existing libraries wh…

97 Things Every Programmer Should Know 88 The Unix Tools Are Your Friends

IF, ON MY WAY TO EXILE ON A DESERT ISLAND, I had to choose between an IDE and the Unix toolchest, I'd pick the Unix tools without a second thought. Here are the reasons why you should become proficient with Unix tools. Furthermore, while I…

97 Things Every Programmer Should Know 87 Ubuntu Coding for Your Friends

SO OFTEN, WE WRITE CODE IN ISOLATION and that code reflects our personal interpretation of a problem, as well as a very personalized solution. It is easy to overlook the social side of software creation. Creating software is a technical ex…

97 Things Every Programmer Should Know 86 Two Wrongs Can Make a Right (and Are Difficulut to Fix)

CODE NEVER LIES, BUT IT CAN CONTRADICT ITSELF. Consider a function that returns a completion status. Imagine that it returns false when it should return true. Now imagine that the calling function neglects to check the return value. Everyt…