「BEGIN」を含む日記 RSS

はてなキーワード: BEGINとは

2010-01-23

PostgreSQL 9.0 の DO 命令が面白そうだ

今までは関数定義しないとストアドプロシージャができなかったけど、

DO命令を使えば匿名コードブロックが書けるっぽい。

毎回コードが異なるトランザクション処理、特にBEGIN/COMMITをアプリケーション側で制御したくない場合には便利だな、と。

ホット・スタンバイの陰に隠れてしまったのがもったいない

2010-01-14

http://anond.hatelabo.jp/20100114003544

34分

現役のときに比べて腕が鈍ってるなあ

ソースは汚いよ


同じところを二回訪れないことに注意して、次の状態をキューに入れていけばいいだけ

隣は距離1なのでただのFIFOでいい

重み付きのグラフならpriority queueを使う


dequeなんちゃらの前までが入力で、while の中が重要コード

答えはSとGも塗り潰しちゃったのを出力してる

サンプルの入力で最短距離であることを確認してる


増田できれいにC++を出力するにはどうすればいいんだろう?

#include <map&gt;
#include <string&gt;
#include <iostream&gt;
#include <vector&gt;
#include <iterator&gt;
#include <deque&gt;
#include <set&gt;

using namespace std;
typedef pair<int, int&gt; P;

int dir_x[] = {0,1, -1, 0};
int dir_y[] = {1, 0, 0, -1};

int main() {
  string line;
  vector<string&gt; input;

  while (getline(cin, line)) {
    input.push_back(line);
  }
  const int X = input.size();
  const int Y = input.begin()-&gt;size();

  vector<P&gt; start;
  P goal;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      if (input[i][j] == 'S') {
        start.push_back(P(i, j));
      }
      else if (input[i][j] == 'G') {
        goal = P(i, j);
      }
    }
  }

  deque<vector<P&gt; &gt; Q;
  set<P&gt; visited;
  Q.push_back(start);

  while (!Q.empty()) {
    vector<P&gt; p = Q.front();
    Q.pop_front();

    if (visited.find(p.back()) != visited.end()) { continue; }
    visited.insert(p.back());

    if (p.back() == goal) {
      for (int i = 0; i < p.size(); i++) {
        input[p[i].first][p[i].second] = '$';
      }
      copy(input.begin(), input.end(), ostream_iterator<string&gt;(cout, "\n"));
      break;
    }

    for (int i = 0; i < 4; i++) {
      P next = P(p.back().first + dir_x[i], p.back().second + dir_y[i]);
      if (input[next.first][next.second] == '*') { continue; }
      vector<P&gt; new_state(p.begin(), p.end());
      new_state.push_back(next);
      Q.push_back(new_state);
    }
  }
  return 0;
}

2009-08-07

JavaScriptラムダ式

function returner() {
    return 100;
}

function profiler(aFunction) {
    var begin = new Date();
    for (var i = 0; i < 500000; ++i) {
        aFunction();
    }
    var end = new Date();

    return end - begin;
}

function profileLambdaExpression() {
    // lamda expression
    print("lamda expression : " +
          profiler(function () returner())
         );

    // equal to above expression
    print("normal form : " +
          profiler(function () {
                       return returner();
                   })
         );

    // not return the value
    print("return no value : " +
          profiler(function () {
                       returner();
                   })
         );    
}

profileLambdaExpression();

&gt;&gt; lamda expression : 1521

&gt;&gt; normal form : 1436

&gt;&gt; return no value : 1431

SpiderMonkey 1.8.0 pre

2009-05-21

http://anond.hatelabo.jp/20090521185817

http://www.geocities.jp/jazzdoriura/karaoke/intro.html

ジャズスタンダードを歌いたい人にとっては、いつも『All Of Me』や『Take The A Train』、『Route 66』というわけにはいかず、かといって『The Shadow Of Your Smile』『The Girl From Ipanema』『Begin The Beguine』なんかはちょっと違うし…と悩むところかもしれません。

この辺はあるらしいな。よー知らんが。

2009-04-01

G20開幕なんでもう一回貼っておきますね

Practically speaking, the April 2009 G20 Summit is probably the last chance to put on the right tracks the forces at play, i.e. before the sequence of UK and then US defaults begin (2).

http://www.leap2020.eu/GEAB-N-32-is-available!-4th-quarter-2009-Beginning-of-Phase-5-of-the-global-systemic-crisis-phase-of-global-geopolitical_a2805.html

基軸通貨どうするかで対立とかしてる場合じゃないんだけどねー。

まあ無理だろうね。終わりが始まる。

2009-03-10

http://anond.hatelabo.jp/20090310004034

Practically speaking, the April 2009 G20 Summit is probably the last chance to put on the right tracks the forces at play, i.e. before the sequence of UK and then US defaults begin (2).

http://www.leap2020.eu/GEAB-N-32-is-available!-4th-quarter-2009-Beginning-of-Phase-5-of-the-global-systemic-crisis-phase-of-global-geopolitical_a2805.html

2009-02-25

http://anond.hatelabo.jp/20090225205005

25~11個

24 from know 

23 who because with 

22 economy

21 an new people plan so

20 by every health

19 us

18 America care they time

17 do

16 also that's these

15 all Americans It's must years your

14 about education energy here jobs make no

13 budget if

12 cost country one recovery than there tonight we've why

11 crisis how out reform those when

10個

at banks college Congress don't future money nation next responsibility some tax what where world

9個

children deficit even just me meet need put up work year

8個

afford back cannot down economic end first help lending my see take times was way

7個

again businesses confidence days each ensure get government high history invest issue million once only power right system

6個

already another been begin bring buy century challenges clean come credit debt fact families financial goal helping largest long-term made most over president recession save schools still support through too

5個

address any ask bad before business called chamber commitment cut cuts effort ever family finally global home its job keep last lead like loans many market necessary never off opportunity other programs provide spend united we'll were would

4個

able accountable across act action administration am asked can't could critical cyber cycle cynical difficult does dollars easy force four-year he homes investment Iraq let longer may men moment national nearly old pay percent price private problems promise receive renewable restore say security send sense she should single soon stand States street struggle technology tell think values war well well-being we're without words workers worse yet

3個

ability absolutely after auto bank begins beyond breaks build cause change child comes community compete comprehensive concern confront costs created decade decisions Democrats depend depends didn't dime done efficient enough entrepreneurs everyone federal forward foundation given good govern great half her higher hold hope housing I'm includes industry inherited insurance into I've lay layoffs legislation letter life long lost major makes Medicare move nor often part passed place problem progress protect pushed regulations Republicans resources restart return root said same savings says seen Sen. sent serve simply solar solve speak spirit step struggling students taxpayer thank then today together training understand use wait want watching ways whatever which women won't working young

2個

abuse accounts affordable Afghanistan agenda allow along amid appointed approach areas around arrived assistance assure away balance become begun being believe benefits best billions bless boldly both bought built burden car career Carolina cars children's citizens clear close committed common company complete continue continued corporations countries creating crushing debates decline demand did different diploma directly disease doctors doesn't dollar doors dreams eliminate enterprise era example expand expanded extremism face failure far fastest-growing father few fiscal forces forge found four fraud full fully generation generations getting give God Greensburg had hard haven't healthy held helped highest him his historic households ideas ignore important industries innovation inspiration instead invented kind lasting launched law laying lift line lines list living loan look lose lower massive millions months mortgage much nations neighbor nobody office oil open order ordinary ourselves overseas own pass paychecks payment payments places policies priorities probably process program prosperity provided public quality quick quickly quitters quitting rates real rebuild recover reflects renewed require responsible re-start result revive rewards rules sacrifice safe second secure seek serious service set ship sitting small Social something source South spending spur state stock stopped stores strength strengthen strong stronger submit suffering surely takes teacher teachers term terrorists third though thousands threats three told tomorrow took tough trust trying tuition turn under upon very Vice view wake walk Wall waste wasteful weakened went what's wind worthy yourself

変化とか無視した。1個なんて載せられるかー!

2009-02-18

Beginning of Phase 5 of the global systemic crisis

http://www.leap2020.eu/GEAB-N-32-is-available!-4th-quarter-2009-Beginning-of-Phase-5-of-the-global-systemic-crisis-phase-of-global-geopolitical_a2805.html

the next four months, before summer 2009. Practically speaking, the April 2009 G20 Summit is probably the last chance to put on the right tracks the forces at play, i.e. before the sequence of UK and then US defaults begin (2).

It is high time for the general population and socio-political players to get ready to face very hard times during which whole segments of our societies will be modified (4), temporarily disappear or even permanently vanish.

去年あたり『経済大丈夫に決まってんだろwww歴史を見ていままで大丈夫だったじゃねーかwww馬鹿な悲観論乙wwばーかばーかwww』とか言ってた馬鹿増田共が今頃どんな顔をしてるのか見てみたい。

2009-01-21

毎朝読対訳:就任演説(7)

http://anond.hatelabo.jp/20090121144441

 Recall that earlier generations faced down fascism and communism not just with missiles and tanks, but with sturdy alliances and enduring convictions.

(M)先人がミサイル戦車を使うのみならず、信念と確固たる同盟をもってファシズム共産主義に勇敢に立ち向かったことを思い出そう。

(A)先人たちがファシズム共産主義を屈服させたのは、ミサイル戦車によってだけではなく、頼もしい同盟国と強固な信念によってでもあることを思い起こしてほしい。

(Y)前の世代は、ファシズム共産主義と、ミサイル戦車だけではなく、強固な同盟と強い信念を持って対峙(たいじ)したことを思い出してほしい。

 They understood that our power alone cannot protect us, nor does it entitle us to do as we please.

(M)先人は軍事力だけが我々を守るのではないことや、またそれを好き勝手に使えないことを知っていた。

(A)彼らは自らの力だけが自分たちを守ったのではないことも、その力が、自分たちが好きなように振る舞う資格を与えたのでもないことを理解していた。

(Y)彼らは、我々の力だけでは我々を守れず、好きに振る舞う資格を得たのではないことも理解していた。

 Instead, they knew that our power grows through its prudent use; our security emanates from the justness of our cause, the force of our example, the tempering qualities of humility and restraint.

(M)代わりに、彼らは慎重にそれを使うことで力が増し、安全は目的の正しさや、他国の手本となる振る舞い、謙虚さや自制心から発することを知っていた。

(A)その代わりに先人たちは、自らの力は慎重に使うことで増大し、自らの安全は、大義の正しさ、模範を示す力、謙虚さと自制心から生まれると知っていた。

(Y)代わりに、慎重に使うことで力が増すことを理解していた。我々の安全は、大義の正当性や模範を示す力、謙虚さ、自制心からいずるものだ。

 We are the keepers of this legacy.

(M)我々はこの遺産を引き継ぐ。

(A)私たちはその遺産の継承者だ。

(Y)我々は、この遺産の番人だ。

 Guided by these principles once more, we can meet those new threats that demand even greater effort - even greater cooperation and understanding between nations.

(M)これらの原理に再び導かれ、解決により一層の努力が求められる新しい脅威に対抗できる。

(A)いま一度こうした原理に導かれることにより、私たちはより厳しい努力、つまり、より強固な国際的協力と理解を必要とする新たな脅威にも立ち向かうことができる。

(Y)こうした原則にもう一度導かれることで、我々は、一層の努力や、国家間の一層の協力や理解が求められる新たな脅威に立ち向かうことができる。

 We will begin to responsibly leave Iraq to its people, and forge a hard-earned peace in Afghanistan.

(M)我々は責任を持ってイラクから撤退し始め、イラク人に国を任せる。そしてアフガンでの平和を取り戻す。

(A)私たちは、責任ある形でイラクをその国民の手に委ねる過程を開始し、アフガニスタン平和構築を始める。

(Y)我々は、責任ある形で、イラクイラク国民に委ね、苦労しながらもアフガニスタン平和を築き始めるだろう。

 With old friends and former foes, we will work tirelessly to lessen the nuclear threat, and roll back the specter of a warming planet.

(M)古くからの友人とかつての敵と共に、核の脅威を減らすために絶えず努力し、さらに地球温暖化とも戦う。

(A)また古くからの友好国とかつての敵対国とともに、核の脅威を減らし、地球温暖化の恐れを巻き戻す不断努力を行う。

(Y)古くからの友やかつての敵とともに、核の脅威を減らし、地球温暖化を食い止めるためたゆまず努力するだろう。

 We will not apologize for our way of life, nor will we waver in its defense,

(M)我々の生き方について言い訳はしないし、それを断固として守る。

(A)私たちは、私たちの生き方を曲げることはなく、それを守ることに迷いもしない。

(Y)我々は、我々の生き方について謝らないし、それを守ることを躊躇(ちゅうちょ)しない。

 ,and for those who seek to advance their aims by inducing terror and slaughtering innocents, we say to you now that

(M)無実な人々を殺したり、脅迫自己目的の実現を図る者に対し、告げる。

(A)自分たちの目的を進めるためにテロ引き起こし、罪のない人々を虐殺しようとする者に対し、私たちは言おう。

(Y)テロ引き起こし、罪のない人を殺すことで目的の推進を図る人々よ、我々は言う。

 our spirit is stronger and cannot be broken;

(M)我々の意思の方が強く、我々の意思を曲げることはできない。

(A)いま私たちの精神は一層強固であり、くじけることはない。

(Y)我々の精神は今、より強固であり、壊すことはできないと。

 ; you cannot outlast us, and we will defeat you.

(M)我々の方が長く生き、そして打ち負かす。

(A)先に倒れるのは君たちだ。私たちは君たちを打ち負かす。

(Y)あなたたちは、我々より長く生きることはできない。我々は、あなたたちを打ち破るだろう。

 For we know that our patchwork heritage is a strength, not a weakness.

(M)我々の多様な出自は強みであり、弱みではない。

(A)なぜなら、私たちの多様性という遺産は、強みであり、弱点ではないからだ。

(Y)我々のつぎはぎ細工の遺産は強みであって、弱みではない。

 We are a nation of Christians and Muslims, Jews and Hindus - and non-believers.

(M)キリスト教徒イスラム教徒ユダヤ教徒、ヒンズー教徒、そして無宗教者の国だ。

(A)私たちの国はキリスト教徒イスラム教徒ユダヤ教徒、ヒンドゥー教徒、そして無宗教者からなる国家だ。

(Y)我々は、キリスト教徒イスラム教徒ユダヤ教徒、ヒンズー教徒、それに神を信じない人による国家だ。

 We are shaped by every language and culture, drawn from every end of this Earth;

(M)地球上の津々浦々から来たあらゆる言語と文化で形作られている。

(A)世界のあらゆる所から集められたすべての言語と文化に形作られたのが私たちだ。

(Y)我々は、あらゆる言語や文化で形作られ、地球上のあらゆる場所から集まっている。

 ; and because we have tasted the bitter swill of civil war and segregation, and emerged from that dark chapter stronger and more united,

(M)内戦南北戦争)や人種差別という苦い経験もしたが、その暗い時代をへて、我々はより強くなり、きずなも深くなった。

(A)私たちは、南北戦争人種隔離という苦い経験をし、その暗い歴史の一章から、より強く、より結束した形で抜け出した。

(Y)我々には、南北戦争人種隔離の苦い経験があり、その暗い時代から出てきて、より強く、より団結するようになった。

 , we cannot help but believe that the old hatreds shall someday pass; that the lines of tribe shall soon dissolve;

(M)かつての憎しみはいずれ消え、我々を分け隔てた壁はいずれ消える。

(A)それがゆえに、我々は信じる。古い憎悪はいつか過ぎ去ることを。種族的な境界は間もなく消え去ることを。

(Y)我々は信じている。古くからある憎しみはいつかなくなり、民族を隔てる線も消えると。

  ; as the world grows smaller, our common humanity shall reveal itself;

(M)世界が小さくなるにつれ、我々が共通に持つ人類愛が出現する。

(A)世界がより小さくなるにつれて、共通の人間性が姿を現すことを。

(Y)世界が小さくなる中で、我々に共通の人間愛が現れることになると。

; and that America must play its role in ushering in a new era of peace.

(M)そしてアメリカ平和の時代をもたらす役割を果たさねばならない。

(A)そして、アメリカは、新たな平和の時代を導く役割を果たさなければならないことを。

(Y)米国が、新しい平和の時代に先駆ける役割を果たさねばならないと。

毎朝読対訳:就任演説(4)

http://anond.hatelabo.jp/20090121123006

 This is the journey we continue today.

(M)この旅を今日、我々は続けている。

(A)これが、私たちが今日も続けている旅だ。

(Y)これが今日、我々が続けている旅なのだ。

 We remain the most prosperous, powerful nation on Earth.

(M)我々は今でも地上で最も繁栄し強力な国だ。

(A)私たちは地球上で最も繁栄した、強力な国であり続けている

(Y)米国依然として地球上で最も繁栄し、力強い国だ。

 Our workers are no less productive than when this crisis began.

(M)我々の労働者は今回の危機が始まった時と同様、生産性は高い。

(A)私たちの労働者は、この(経済)危機が始まったときと比べ、生産性が落ちたわけではない。

(Y)我々の労働者は今回危機が始まった時と同様、生産性は高い。

 Our minds are no less inventive, our goods and services no less needed than they were last week or last month or last year.

(M)発明心に富み、商品サービスは先週、先月、昨年と同様に求められている。

(A)先週、先月、昨年と比べ、私たちの創造性が低くなったのでもなければ、私たちの商品サービスが必要とされなくなったのではない。

(Y)我々は相変わらず創意に富み、我々が生み出す財やサービスは先週や先月、昨年と同様、必要とされている。

 Our capacity remains undiminished.

(M)我々の能力は落ちていない。

(A)私たちの能力は衰えていない。

(Y)能力も衰えていない。

 But our time of standing pat, of protecting narrow interests and putting off unpleasant decisions - that time has surely passed.

(M)だが、過去に固執し、狭い利益しか守らず、面倒な決定は後回しにする時代は終わった。

(A)ただ、同じところに立ち止まり、狭い利益を守り、不快決断を先延ばしする時代は明らかに過ぎ去った。

(Y)しかし、同じ手を用いるだけで、狭い利益にこだわり、面倒な決定を先送りする、そんな時代は確実に終わった。

 Starting today, we must pick ourselves up, dust ourselves off, and begin again the work of remaking America.

(M)今日からは、我々は立ち上がり、ほこりを払い、アメリカ再建の仕事に取りかからねばならない。

(A)私たちは今日から、自らを奮い立たせ、ほこりを払い落として、アメリカ再生する仕事を、もう一度始めなければならない。

(Y)今日から我々は立ち上がり、ほこりを払って、米国を作り直す仕事に取りかかろう。

2008-12-06

対訳:人を動かす

http://ja.wikipedia.org/wiki/%E4%BA%BA%E3%82%92%E5%8B%95%E3%81%8B%E3%81%99

http://en.wikipedia.org/wiki/How_to_Win_Friends_and_Influence_People

  • Fundamental Techniques in Handling People(人を動かす三原則)
    • Don't criticize, condemn or complain.(批判も非難もしない。苦情もいわない。)
    • Give honest and sincere appreciation.(卒直で、誠実な評価を与える。)
    • Arouse in the other person an eager want.(強い欲求を起こさせる)
  • Six Ways to Make People Like You(人に好かれる六原則)
    • Become genuinely interested in other people.(誠実な関心を寄せる。)
    • Smile.(笑顔で接する。)
    • Remember that a man's Name is to him the sweetest and most important sound in any language.(名前は、当人にとって、最も快い、最も大切な響きを持つことばであることを忘れない。)
    • Be a good listener. Encourage others to talk about themselves.(聞き手にまわる。)
    • Talk in the terms of the other man's interest.(相手の関心を見抜いて話題にする。)
    • Make the other person feel important and do it sincerely.(重要感を与える―誠意をこめて。)
  • Twelve Ways to Win People to Your Way of Thinking(人を説得する十二原則 )
    • Avoid arguments.(議論に勝つ唯一の方法として議論を避ける。)
    • Show respect for the other person's opinions. Never tell someone they are wrong.(相手の意見に敬意を払い、誤りを指摘しない。)
    • If you're wrong, admit it quickly and emphatically.(自分の誤りをただちにこころよく認める。)
    • Begin in a friendly way.(おだやかに話す。)
    • Start with questions the other person will answer yes to.(相手が即座に'イエス'と答える問題を選ぶ。)
    • Let the other person do the talking.(相手にしゃべらせる。)
    • Let the other person feel the idea is his/hers.(相手に思いつかせる。)
    • Try honestly to see things from the other person's point of view.(人の身になる。)
    • Sympathize with the other person.(相手の考えや希望に対して同情を持つ。)
    • Appeal to noble motives.(人の美しい心情に呼びかける。)
    • Dramatize your ideas.(演出を考える。)
    • Throw down a challenge.(対抗意識を刺激する。)
  • Be a Leader: How to Change People Without Giving Offense or Arousing Resentment(人を変える九原則 )
    • Begin with praise and honest appreciation.(まずほめる。)
    • Call attention to other people's mistakes indirectly.(遠まわしに注意を与える。)
    • Talk about your own mistakes first.(まず自分の誤りを話した後、相手に注意を与える。)
    • Ask questions instead of giving direct orders.(命令をせず、意見を求める。)
    • Let the other person save face.(顔を立てる。)
    • Praise every improvement.(わずかなことでも、すべて、惜しみなく、心からほめる。)
    • Give them a fine reputation to live up to.(期待をかける。)
    • Encourage them by making their faults seem easy to correct.(激励して、能力に自信を持たせる。)
    • Make the other person happy about doing what you suggest.(喜んで協力させる。)

Seven Rules For Making your Home Life Happier(幸福な家庭を作る七原則)は日本語訳無し。

2008-11-11

勉強することができる奴、これ最強

大学の6年生なんだが、今更ながら『勉強することができる奴、これ最強』ということに気付いた。

勉強ができる、ということは、自分の能力を状況に応じてカスタマイズしていくことができる、ということだ。

高校までの勉強は基礎教養であること以上に、勉強する力を身につけることに意味がある。数学が出来て将来何の役に立つんですか?という中二の問いには、数学は君の生活を支えている大切な学問だ、という答えよりも、数学が出来るようになる過程で勉強の仕方を身につけることが必要なんだ、という答えの方が適切だろう。前者理科系の素養を持つ中二にしか響かないが、後者はより一般的な答えとなりうるからである。

勉強をするスキル』がこの過程で身に付いていれば、向き不向きはあるにしてもほとんどどんな職業にも就くことが出来るだろう。また、環境の変化にも強くなれる。環境が変化してもそれに応じて必要なことを勉強すればいいだけの話なのだから。しかし『勉強をするスキル』が身に付いていなかったら?単調労働等の誰にでも出来る仕事しか出来ないだろうし、環境の変化に対応することも難しいだろう。

そしてこのスキルは、若いうちから身につけるのが一番お得であり効率もいい。というより多分、若いうちに習慣づけておかないとどうしようもない。小中高の宿題を9割以上踏み倒した奴が大学生になって、たとえ単位留年がかかっていてもいきなりレポートをしっかり提出できるようになるわけがないのだ(体験談)。

この文章を高校生までの若年層が読むかどうかは分からないが、もし読んでいたらどうか心に留めておいてほしい。

勉強することができる奴、これ最強』

=begin

しかし勉強の出来不出来で人を分類する方法ってよく考えついたなー、と思う。社会の役割分担としての適材適所がかなりの程度自発的に(創発的に?)行われるからだ。教育の大切さというのは一人の人間を育てるための大切さだけでなく、社会全体を上手く回すための大切さでもあるのだ。

あとこんなこと書いたけど、勉強の出来不出来で決まるのはあくまで社会の中での自分の立ち位置であり、幸せ人生をおくれるかどうかはまた別問題だよ。だからもしかしたら本当に大切なのは、『勉強をするスキル』よりも『どんな勉強をするのか、またはしないのか』を見極めることかもしれんね。

=end

2008-11-01

http://anond.hatelabo.jp/20081101031143

pc@ubuntu-vm:~$ mobirc/mobirc

Could not load class (App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS) because : Can't locate XML/LibXML.pm in @INC (@INC contains: /home/pc/mobirc/lib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /home/pc/mobirc/lib/App/Mobirc/Plugin/HTMLFilter/DoCoMoCSS.pm line 5.

BEGIN failed--compilation aborted at /home/pc/mobirc/lib/App/Mobirc/Plugin/HTMLFilter/DoCoMoCSS.pm line 5.

Compilation failed in require at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 151.

at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 133

Class::MOP::load_first_existing_class('App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS') called at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 157

Class::MOP::load_class('App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS') called at /usr/local/share/perl/5.8.8/MooseX/Plaggerize.pm line 20

App::Mobirc::load_plugin('App::Mobirc=HASH(0x8d7e490)', 'HASH(0x8d7536c)') called at /home/pc/mobirc/lib/App/Mobirc.pm line 44

App::Mobirc::_load_plugins('App::Mobirc=HASH(0x8d7e490)') called at /home/pc/mobirc/lib/App/Mobirc.pm line 35

Class::MOP::Class:::around('CODE(0x8ab5250)', 'App::Mobirc', '/home/pc/mobirc/config.yaml') called at /usr/local/lib/perl/5.8.8/Class/MOP/Method/Wrapped.pm line 129

Class::MOP::Method::Wrapped::__ANON__('App::Mobirc', '/home/pc/mobirc/config.yaml') called at /usr/local/lib/perl/5.8.8/Class/MOP/Method/Wrapped.pm line 89

App::Mobirc::new('App::Mobirc', '/home/pc/mobirc/config.yaml') called at mobirc/mobirc line 36

pc@ubuntu-vm:~$ sudo mobirc/mobirc

Could not load class (App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS) because : Can't locate XML/LibXML.pm in @INC (@INC contains: /home/pc/mobirc/lib /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at /home/pc/mobirc/lib/App/Mobirc/Plugin/HTMLFilter/DoCoMoCSS.pm line 5.

BEGIN failed--compilation aborted at /home/pc/mobirc/lib/App/Mobirc/Plugin/HTMLFilter/DoCoMoCSS.pm line 5.

Compilation failed in require at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 151.

at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 133

Class::MOP::load_first_existing_class('App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS') called at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 157

Class::MOP::load_class('App::Mobirc::Plugin::HTMLFilter::DoCoMoCSS') called at /usr/local/share/perl/5.8.8/MooseX/Plaggerize.pm line 20

App::Mobirc::load_plugin('App::Mobirc=HASH(0x8d799e0)', 'HASH(0x8d7089c)') called at /home/pc/mobirc/lib/App/Mobirc.pm line 44

App::Mobirc::_load_plugins('App::Mobirc=HASH(0x8d799e0)') called at /home/pc/mobirc/lib/App/Mobirc.pm line 35

Class::MOP::Class:::around('CODE(0x8ab4390)', 'App::Mobirc', '/home/pc/mobirc/config.yaml') called at /usr/local/lib/perl/5.8.8/Class/MOP/Method/Wrapped.pm line 129

Class::MOP::Method::Wrapped::__ANON__('App::Mobirc', '/home/pc/mobirc/config.yaml') called at /usr/local/lib/perl/5.8.8/Class/MOP/Method/Wrapped.pm line 89

App::Mobirc::new('App::Mobirc', '/home/pc/mobirc/config.yaml') called at mobirc/mobirc line 36

イミフ

2008-10-18

real street angels から mechanize を使って動画を取ってきてEmacsで見てみるよ

せっかく書いたから匿名でのせてみるよ

使い方は

  • 動画を取ってきたいよ
    • config.yamlユーザとかを設定するよ
    • ids.txt に取ってきたいIDを書くよ
    • sangels.bat を実行するよ
  • Emacs動画を見たいよ
    • sangels.el を load するよ
    • M-x sangels だよ

必要なものを gem で取ってくるにはこうすればいいよ

  • gem install -r log4r
  • gem install -r -v 0.6 hpricot
  • gem install -r mechanize

長すぎてelispが消えたから続きがあるよ

sangels.bat - 起動用バッチファイル

@echo off
setlocal
set WD=%~dp0
cd /d %WD%

ruby get_movies.rb
ruby get_images.rb
ruby create_m3u.rb

ruby

config.yaml - 設定ファイル
user: ユーザID
password: パスワード
ids_file: ids.txt
done_file: ids_done.txt
movies_dir: movies

log4r_config:
  pre_config:
    global: INFO
  loggers:
    - name: app
      type: Log4r::Logger
      level: INFO
      outputters:
        - STDOUT
        - FILE
  outputters:
    - name: STDOUT
      type: Log4r::StdoutOutputter
      formatter:
        type: Log4r::PatternFormatter
        pattern: "%d [%l] %C - %M"
        date_pattern: "%H:%M:%S"
    - name: FILE
      type: Log4r::FileOutputter 
      filename: "#{LOGDIR}/sangels.log"
      formatter:
        type: Log4r::PatternFormatter
        pattern: "%d [%l] %C - %M"
        date_pattern: "%Y-%m-%d %H:%M:%S"
get_movies.rb
require 'fileutils'
require 'logger'
require 'mechanize'

BASEDIR = File.dirname($0)
require "#{BASEDIR}/util"
require "#{BASEDIR}/sangels"

$config = load_config(BASEDIR)
prepare_logger(BASEDIR)
$log = new_logger("get_movies")
WWW::Mechanize.log = new_logger("mechanize")
WGet.log = $log

class IDFile
  def initialize(file)
    @file = file
    unless File.exist?(@file)
      Fileutils.touch(@file)
    end
  end

  def ids(contains_comment = nil)
    File.open(@file) {|io|
      io.to_a.map {|x|
        x.chomp
      }.select {|x|
        if x.empty?
          nil
        elsif contains_comment
          true
        else
          not /^\s*\#/ =~ x
        end
      }
    }
  end

  def add(id)
    ids = ids(true)
    unless ids.any? {|x| x == id}
      write(ids + [id])
    end
  end

  def delete(id)
    ids = ids(true)
    if ids.any? {|x| x == id}
      write(ids - [id])
    end
  end

  def write(ids)
    File.open(@file, "w") {|io|
      ids.each {|x| io.puts x}
    }
  end
end


$log.info("BEGIN #{$0} ================")
exit_code = 0
begin
  ids_file = IDFile.new($config.ids_file)
  done_file = IDFile.new($config.done_file)
  movies_dir = $config.movies_dir
  wget = WGet.new

  sangels = SAngels.new
  sangels.login($config.user, $config.password)
  ids_file.ids.each {|id|
    begin
      movies = sangels.movies(id)
    rescue SAngels::Movies::InvalidMoviesError
      $log.warn("invalid movie id: #{id}")
      next
    end
    dir = File.expand_path(id, movies_dir)
    movies.each {|link|
      wget.retrieve(link.href, dir)
    }
    expected = movies.movie_links.map{|x| File.basename(x.href)}
    actual = Dir.glob("#{dir}/*").map {|x| File.basename(x)}
    if (expected - actual).empty?
      done_file.add(id)
      ids_file.delete(id)
    end
  }
rescue => e
  $log.error(e)
  exit_code = 1
end

$log.info("END #{$0} (#{exit_code}) ================")
exit exit_code
get_images.rb
require 'fileutils'
require 'logger'
require 'mechanize'
require 'ostruct'

BASEDIR = File.dirname($0)
require "#{BASEDIR}/util"
require "#{BASEDIR}/sangels"

$config = load_config(BASEDIR)
prepare_logger(BASEDIR)
$log = new_logger("get_images")
WWW::Mechanize.log = new_logger("mechanize")
WGet.log = $log

$log.info("BEGIN #{$0} ================")
exit_code = 0
begin
  movies_dir = $config.movies_dir
  sangels = SAngels.new
  sangels.login($config.user, $config.password)
  thumbnails = sangels.thumbnails

  Dir.glob("#{movies_dir}/*").each {|dir|
    next unless File.directory? dir
    id = File.basename(dir)

    url = thumbnails.url(id)
    unless url
      $log.warn("#{id} is not found")
      next
    end
    path = File.expand_path("00_thumbnail#{File.extname(url)}", dir)
    next if File.exist? path

    $log.info("retrieving #{url}")
    thumbnail = thumbnails.get_file(id)
    File.open(path, "wb") {|io| io.write(thumbnail)}
  }
rescue => e
  $log.error(e)
  exit_code = 1
end

$log.info("END #{$0} (#{exit_code}) ================")
exit exit_code
create_m3u.rb
BASEDIR = File.dirname($0)
require "#{BASEDIR}/util"

$config = load_config(BASEDIR)
movies_dir = $config.movies_dir
Dir.glob("#{movies_dir}/*") {|dir|
  next unless File.directory? dir
  name = File.basename(dir)
  files = Dir.glob("#{dir}/*.wmv").sort

  File.open("#{movies_dir}/#{name}.m3u", "w") {|io|
    files.each {|file|
      io.puts "#{name}/#{File.basename(file)}"
    }
  }

  File.open("#{dir}/00_movies.m3u", "w") {|io|
    files.each {|file|
      io.puts "#{File.basename(file)}"
    }
  }
}
sangels.rb
require 'mechanize'
require 'hpricot'

BASEDIR = File.dirname($0)
require "#{BASEDIR}/util"

class SAngels
  HOST = "real2.s-angels.com"
  LOGIN_URL = "http://#{HOST}/member/"
  INFO_URL = "http://#{HOST}/teigaku/item.php"
  THUMBNAILS_URL = "http://#{HOST}/teigaku/"
  THUMBNAIL_URL = "http://#{HOST}/images/default/thumb/"

  def initialize()
    @agent = WWW::Mechanize.new
  end

  def login(user, password)
    login_form = @agent.get(LOGIN_URL).forms.find {|form|
      form.fields.any? {|field| field.name == "frmLoginid"}
    }
    login_form.frmLoginid = user
    login_form.frmPw = password
    @agent.submit(login_form)
  end

  def movies(id, no_validate = nil)
    Movies.new(@agent, id, !no_validate)
  end

  def thumbnails
    Thumbnails.new(@agent)
  end

  class Thumbnails
    def initialize(agent)
      @agent = agent
      doc = Hpricot(@agent.get_file(THUMBNAILS_URL))
      elems = doc.search("div[@class=realthum]/a")
      @links = Hash(
        elems.map {|elem|
          href = elem["href"]
          id = $1 if /ID=(.+)/ =~ href
          url = elem.search("img")[0]["src"]
          [id, url]
        })
    end

    def get_file(id)
      @agent.get_file(url(id))
    end

    def url(id)
      @links[id]
    end

    def exist?(id)
      url(id)
    end
  end

  class Movies
    class InvalidMoviesError < StandardError
    end

    def initialize(agent, id, no_validate)
      @agent = agent
      @id = id
      if !no_validate &amp;&amp; !valid?
        raise InvalidMoviesError
      end
    end

    def info_page_url
      "#{INFO_URL}?ID=#{@id}"
    end

    def info_page
      @agent.get(info_page_url)
    end

    def movies_page
      @agent.click(info_page.links.find {|link| /P=10/ =~ link.href})
    end

    def movie_links
      movies_page.links.select {|link|
        /wmv$/ =~ link.href
      }.sort {|a, b|
        File.basename(a.href) <=> File.basename(b.href)
      }
    end

    def valid?
      info_page.uri.to_s == info_page_url
    end

    def each(&amp;block)
      orig_links = movie_links
      orig_links.each {|orig_link|
        link = movie_links.find {|l| File.basename(l.href) == File.basename(orig_link.href)}
        block.call(link)
      }
    end
  end
end
util.rb
require 'log4r'
require 'log4r/yamlconfigurator'
require 'singleton'
require 'fileutils'
require 'ostruct'

def Hash(a)
  Hash[*a.flatten]
end

def load_config(basedir)
  OpenStruct.new(File.open("#{basedir}/config.yaml") {|io| YAML.load(io)})
end

def new_logger(name)
  Log4r::Logger.new("app::#{name}")
end

def prepare_logger(basedir, logdir = nil)
  logdir ||= basedir
  Log4r::YamlConfigurator["LOGDIR"] = logdir
  Log4r::YamlConfigurator.load_yaml_file("#{basedir}/config.yaml")
end

class NullObject
  include Singleton
  def method_missing(message, *arg)
    NullObject.singleton
  end
end

class WGet
  class << self
    attr_accessor :log
    def initialize
      super
      @log = NullObject.singleton
    end
  end
  
  def log
    self.class.log
  end

  def retrieve(url, dir)
    FileUtils.mkdir_p(dir)
    file = File.expand_path(File.basename(url), dir)
    if File.exist?(file)
      log.info("already retrieved #{url}")
      return true
    end

    tmp = "#{file}.part"
    log.info("retrieving #{url}")
    ret = system("wget", "-c", "-O", tmp, url)
    if ret
      log.info("retrieving succeeded #{url}")
      File.rename(tmp, file)
    else
      if $? == 0x020000 # Ctrl-C
        exit($?)
      else
        log.error("retrieving failure #{url} (#{$?})")
      end
    end
    return ret
  end
end

2008-08-07

rubyダメな2つの理由

1. イテレータの |x| のセンス。縦棒!?

2. begin ... end のセンス。

2008-07-28

笑顔のまんま

辛い時でも 笑ってられる
そんなアンタは ホンマにアホや
先の事など 考えないまま
ペース配分さえ 出来ないで走る

悲しい時こそ おどけてばかり
そんなアンタは やっぱりアホや
惚れてふられて また繰り返す
学ばないまま 明日を迎える

だけどそんなアンタを アンタを見てると
なぜか優しい風が吹き抜けてゆく
湿った心は笑いで乾く

笑顔のまんま(笑顔のまんま)
笑顔のまんま(笑顔のまんま)

そんな人生 生きてるだけで丸儲け

笑顔のまんま(笑顔のまんま)
笑顔のまんま(笑顔のまんま)

そうさTHAT WAS THAT
あの時はあの時さ

笑顔のまんま(笑顔のまんま)
笑顔のまんま(笑顔のまんま)

そうさ人生 生きてるだけで丸儲け

笑顔のまんま(笑顔のまんま)
笑顔のまんま(笑顔のまんま)

そうさTHAT WAS THAT
あの時はあの時さ

僕が笑い(僕が笑い)
君にあげるから(君にあげるから)

君の笑顔を僕にください

---

作詞作曲 BEGIN

from FNS27時間テレビ

2008-07-02

http://anond.hatelabo.jp/20080701213733

アセンブリ言語は構文が単純な(1行1命令)為、m4 のようなマクロプロセッサがあればとりあえずアセンブルの真似事はできるという点が重要な気がします。

(じっさいそういう本があったはず、SPARC Architecture, Assembly Language Programming, and C ISBN:9780130255969)

他のもっと高機能な言語は brace / begin-end で文脈自由言語になってたり、BASIC でさえ変数定義/抹消を管理しなければならないので。

追記:いやもちろんバイナリは吐けないよ、とか、ELFローダ作るのは大変だよ、とか(Linkers & Loaders ISBN:4274064379 でも

実用的なローダを作るようにはなってなかった)そういう話は沢山あるのですが

2007-11-05

君は実にバカだな

http://anond.hatelabo.jp/20071102195139

チンパンジーおもちゃとしてタイプライターを与えて、

ガチャガチャ打ち続けたものが、いつかはシェークスピア

同じ文章を生み出すかっていう、そういう話?

「どうしようもなくバカだ」

船井は重ねて言った。君はむっとして、途方も無く長くまっすぐな廊下を先に歩く禿頭を睨んだ。

ランダムアルファベットの中に、いくらシェークスピアの文章が現れようとも、他のノイズから切り出すことをしなければ、それはやはりランダムノイズにしか過ぎんのだ。この場合シェークスピアを取り出す作業こそを創作と、取り出す主体を知性というのではないかね」

船井は振り返りもしないで喋る。

「それにだ、なんでチンパンジーなんだね。ニホンザルだっていいじゃないか。むしろニホンザルの方が。ああ、君は100匹目の猿の話をしらないのか。こういうことだ。ある日宮崎幸島の一匹の猿が芋を洗うようになった。それを真似した猿が100匹を数えたとき、それは突如として群れ全体の習性となり、更に位置的につながりの無いはずの高崎山の猿までが芋を洗い始めた。集合無意識のなせる現象だな」

船井は突き当たりのドアの前で足を止めた。ドアを開ける。

「ということでだ。芋でもなんでもいい、餌で釣ってタイプライターを叩かせるように仕向けた猿を百匹集める。すると距離を超越して何匹もの猿がタイプライターを叩くようになる。それを集めて意味のある文章を叩いた猿に餌をやると果たしてどうなるか。そんな猿が100万匹いたら?」

船井が半身引いて見せた室内を君は覗き込む。獣の匂いが鼻につく薄暗い部屋は、反対側の壁が消失点の彼方にあって果てが無く、同様に左右の壁も判別できない。規則正しく置かれた机は格子模様を描き、部屋の広さを強調している。ひとつの机につきひとつのタイプライター、一匹の猿。キーキーと鳴き喚く声、カタカタとタイプ、チーンとリターンの音。君は息を止める。

部屋のドアが開いたのがわかると、猿達はタイプライターに叩きつけていた手を止めた。猿は紙を機械から抜き取るとそれを手に扉口に――君のほうに向かって殺到してきた。君は立ちすくむが、船井は目の前で紙を手にギャアギャアと飛び跳ねる猿めらをにこやかに見渡す。差し出される紙をいちいち受け取って目を通すと、あるものにはポケットから豆を出してやって褒めてやり、またあるものには首を振って紙をさし返す。豆をもらった猿はすぐさま空いた机にとって返し、豆をぼりぼり齧りながらまたタイピングを始める。もらえなかった猿は怒って紙をびりびりに引き裂くと、これまた机を探して占領しタイピングを始めた。もらえなかった猿の中には紙を破っても怒りが収まらず、あたりかまわず糞を投げつけるものもいた。その飛沫を浴びても船井は笑みを崩さず、猿どもの差し出す紙の検査を続けている。そして一段落つくと君のほうを見ていう。

「名作とそうでない物の判別をして、猿に餌をやるだけの簡単なお仕事です」

君は袋いっぱいの豆を手渡される。本当に100万匹いそうなこの部屋の猿に一袋では足りない。ならば本当に選別を、などと思っている間に第二波殺到。差し出される紙にはいずれもアルファベットが打たれており、「Stately, plump Buck Mulligan came from the stairhead, bearing a bowl of lather on which a mirror and a razor lay crossed.」「MARLEY was dead: to begin with. There is no doubt whatever about that.」「In 1913, when Anthony Patch was twenty-five, two years were already gone since irony, the Holy Ghost of this later day, had, theoretically at least, descended upon him.」などと書いてはあるものの君には何のことやらわからず、君がよく知るシェークスピアであるところの「To be, or not to be」だとかは探そうとしても、猿にせっつかれて見つけている余裕が無い。適当意味のある英文に見えるものに豆を与えていたら、周囲は徐々に剣呑な空気になり、そういえばさっきつき返した紙にはキリル文字が書いてあったんじゃないかということに思い至るも、東欧文学まで原文でフォローできている君であろうはずは無く、殺気立っている猿達に奪われるようにして豆を与えているので袋の豆も尽き、いよいよ進退窮まったと助けを求めて船井の方を見れば、そこにはただ一匹の巨大な猩々がにまにまといやらしい粘着質の笑いを浮かべているだけで、君は脛に飢えた猿の歯が食い込むのを感じて倒れ、毛深い無数の腕が掴みかかり……夢でさえあればそこで目が覚めるはずだったのだけれど。

だから私が代わりにこれを


ファック文芸部杯参加作 http://neo.g.hatena.ne.jp/objectO/20071117

2007-10-03

恥ずかしい思い出を思い切って晒す

ことで、さっさと忘れるという魂胆。

  • ある田舎駅の前の、民家の入り口にずっとおばちゃんが座ってるので、てっきり店かと思って入ってしまった。「炭酸飲料ありますか」と聞いてしまったし

_| ̄|     ((○

  • 歌を一人で熱唱しているのを家族に見られた

_| ̄|○

  • 寝坊という理由だけで、嘘をついて学校を休んだことがある((たまにはつらくても行くときあるけど))

_| ̄|   ((○

  • 駅の立ち入り禁止区域に入ってしまい、運転士に指摘された((もちろん悪意ないし知った時点でその場から離れたけど))

_| ̄|        ((○

_| ̄| ((○

ここからDelphi

  • Delphiをはじめたとき、何も読まずにprocedure Form1.OnClick(Sender: TObject);に「a = "はじめの第一歩"」とか打ってエラーが出たので、やっと調べたが、型と変数の定義という初歩で挫折し、アンインスコしたことがある((ちなみに今では普通に何も読まなくても簡単なメモ帳作れるレベル))

_| ̄|   ((○

  • Delphiの初歩を少し覚えたとき、自分でプロシージャ作ったら、フォームに置いてあるコントロールアクセスできなくて、3日迷って、思い切って2chで質問。そんでもって30分で解決((ちなみにこれが生まれてはじめての2chへの書き込み))

_| ̄|       ((○

ちなみにこんな感じのプロシージャだった

procedure test;

begin

Label1.Caption := 'テストだよん!';

end;

ちなみに語尾が「だよん」だとかのなのは、今もやってる個人的なルールっぽいもの。

_| ̄|  ○

あーすっきりした!

2007-09-07

ようこそ、℃-uteLisp の世界へ

発祥: http://ex23.2ch.net/test/read.cgi/morningcoffee/1188654905/

はじめに

Scheme という Lisp 語族言語を用いて ℃-ute相関関係プログラムし、様々な角度から関係性を分析する手法を紹介していきます(ソースコードは最後に張ります)。

まずは、メンバー間の関係を「リスト」というデータ型で表現します。例えば「栞菜->愛理」という関係

(kanna . airi)

という形で表すことができます。これに、「大好き」という情報を付加し、ついでにその関係の性質を数値化したものを加えると

((kanna . airi) (desc "大好き") (score . 1))

のようになり、関係図における一つの矢印の情報データ化できたことになります(暫定的に、好意は 1、良好・中立は 0、険悪は -1 の3段階で表すことにします)。

メンバー間の全ての関係性をこのデータ単位で定義し、データベース化しておくことで、色んな条件に基づいた検索やスコア計算などが可能となります。

例 1: リンク状況の調査

ここで相関関係図における矢印を「リンク」と呼ぶことにして、あるメンバーから他のメンバーへどのようにリンクし、またリンクされているかを調べることができます。

関係の中からリンクの起点を抽出してソートしてみると

(sort-nodes (number-list (from-links)))

結果:

((kanna . 6) (saki . 5) (maimi . 4) (erika . 3) (mai . 3) (chisato . 3) (airi . 2))

栞菜ちゃんがメンバー全員にリンクを張っていることが分かり、℃-ute ラブっぷりが伺えます。なっきーにも同様の事が言えます。例の「女の子が好き」発言を数値的に裏付ける結果と言えるかもしれません。

ただ、データ不足でリンク件数がまだ少ないのと、リンクの性質(好意/反感など)までは分からない点を考慮する必要があるでしょう。

例 2: 被リンク状況の調査

同様に、リンクの終点の件数を調べてみます。

(sort-nodes (number-list (to-links)))
((chisato . 5) (erika . 5) (kanna . 4) (maimi . 4) (airi . 4) (mai . 3) (saki . 1))

えりかちゃんと千聖ちゃんが高ポイントです。メンバーからの人気や注目度の高さを示すデータですが、千聖ちゃんの場合敵対的なリンクが2件含まれている点に注意してください。

なっきーの被リンク数が極端に少ないですが、単純にデータ不足のためだと思われます。はぶら(ryとか言わないようにお願いします。

例 3: 愛情度の評価

リンクに付随するスコアを計算することで、愛情の度合いを測ることができるのではないか、という考えに基づく研究です。

まず、全ての関係性を対象として、スコアマイナス関係を抽出してみます。

(filter-nodes (lambda (n)
		(< (score-relation n) 0)))

結果:

(((kanna . chisato) (desc "愛理に手出すんじゃねぇよ") (score . -1))
 ((saki . chisato) (desc "愛理に手出すんじゃねぇよ") (score . -1)))

件数だけを得ると

(length (filter-nodes (lambda (n)
			(< (score-relation n) 0))))
2

僅か2件です。

良好・中立的な関係

(length (filter-nodes (lambda (n)
			(= (score-relation n) 0))))
8

愛に満ちた関係

(length (filter-nodes (lambda (n)
			(> (score-relation n) 0))))
16

非常に多いです。舞美ちゃんの「℃-ute同士でラブラブなんですよ」発言(例のラジオ)を数値的に裏付ける結果と言えるんじゃないでしょうか。

次に、メンバーごとのスコアを算出してみます。Lisp 的には以下のようにフィルタリングと畳み込み (fold) で計算することができます。例えば

(foldr (lambda (n acc)
	 (+ (get-score n) acc))
       0
       (filter-nodes (cut to? <> 'kanna)))

栞菜ちゃんに対するリンクスコアが得られます。結果:

3

上式を一般化して一挙にメンバー全員に適用してみると

(sort-nodes (map (lambda (x)
		   (cons x (score-loved x)))
		 (all-members)))

結果:

((airi . 4) (kanna . 3) (mai . 2) (erika . 2) (maimi . 2) (saki . 1) (chisato . 0))

愛理ちゃんが好意を寄せられやすい傾向が伺えます。

今度は逆方向のスコアを計算してみると

(sort-nodes (map (lambda (x)
		   (cons x (score-loving x)))
		 (all-members)))
((kanna . 3) (maimi . 3) (chisato . 2) (airi . 2) (saki . 2) (mai . 1) (erika . 1))

まいまいえりかちゃんが特に堅い・一途だという傾向を読み取ることができます。

例 4: 相性の調査

今度は組み合わせ(カップリング)の評価です。

2点間相互のリンクスコアを加算したものを「相性」と考えられるものとします。最大値 (互いに好意を寄せている場合の数値) は現在スコアリング方式では 2 です。例えば

(score-between 'kanna 'airi)

の値は

2

となります。1 であれば一方通行と考えます。

関係性が未定義の場合もあるので 0 のものを除外して算出すると

(sort-nodes (filter (lambda (n)
		      (not (= (cdr n) 0)))
		    (map (lambda (n)
			   (cons n (apply score-between n)))
			 (all-combinations))))
(((chisato mai) . 2)
 ((chisato airi) . 2)
 ((airi kanna) . 2)
 ((saki kanna) . 2)
 ((kanna maimi) . 2)
 ((erika maimi) . 2)
 ((saki airi) . 1)
 ((saki erika) . 1)
 ((kanna mai) . 1)
 ((maimi airi) . 1)
 ((saki chisato) . -1)
 ((kanna chisato) . -1))

となります。若干ピンとこない部分もあるかも知れませんが、計算上は矛盾無くデータの内容を表しています。

参考までに、スコア 1 の相互関係の中身を見てみると

(map (lambda (p)
       (find-relation (cons (caar p) (cadar p))
		      identity))
     (filter (lambda (n)
	       (= (cdr n) 1))
	     (map (lambda (n)
		    (cons n (apply score-between n)))
		  (all-combinations))))
(((kanna . mai) (desc "喰ってやるよ") (score . 1))
 ((saki . airi) (desc "好き") (score . 1))
 ((maimi . airi) (desc "良き妹") (score . 1))
 ((saki . erika) (desc "彼氏にしたい") (score . 1)))

のようになります。

まとめ

以上の調査を経て気になった問題点を列挙してみます。

特に最初の点に関して、「百合的」なるものの質的評価がなかなか難しいと感じました。例えば「大好き」も「良き妹」も同じ 1 と評価してしまっているのが妥当かどうか、といったことです。

また、スレにて与えられた情報を評価・分析する方法としては有効だとしても、逆方向のフィードバックの手段がなかなか見つからないというのが三つ目の問題です(技術力不足とも言います)。(注:画像化の方法が分かりました。追記参照)

最後に、プログラムソースを示します。実行には PLT Scheme が必要です。文字コードUTF-8 で保存した上で、(load "c-ute.ss") としてください。文字化けする場合はターミナルUTF-8 を表示できるよう設定する必要があります。がんばってください。

プログラム

c-ute.ss:

(require (lib "etc.ss")
         (lib "list.ss")
         (lib "26.ss" "srfi")
         (lib "delete.ss" "srfi" "1"))

;;; Utilities

(define true? (compose not not))

(define (ignore _) #f)

(define fif
  (case-lambda
    ((predicate consequent)
     (fif predicate consequent ignore))
    ((predicate consequent alternative)
     (lambda (x)
       (if (predicate x)
           (consequent x)
           (alternative x))))))

(define (concat! xs) (apply append! xs))

(define (mapconcat f lst sep)
  (let lp ((str (f (car lst)))
           (lst (cdr lst)))
    (if (null? lst)
        str
        (lp (string-append str sep (f (car lst)))
            (cdr lst)))))

(define (slice-string str len)
  (let lp ((res '())
           (str str))
    (if (<= (string-length str) len)
        (reverse! (cons str res))
        (lp (cons (substring str 0 len) res)
            (substring str len)))))

(define (break-string str len)
  (mapconcat identity (slice-string str len) "\\n"))

;; NOTE: input and output ports have to be either file-stream or #f
;; (i.e., cannot be a string port)
(define (run exe opt in out)
  (let-values (((p p-i p-o p-e)
                (subprocess out in #f exe opt)))
    (subprocess-wait p)
    (close-input-port p-e)))

;;; Database

;; http://ja.wikipedia.org/wiki/%E2%84%83-ute

(define names
  '((erika . "えりか") (maimi . "舞美") (saki . "早貴") (airi . "愛理")
    (chisato . "千聖") (mai . "舞") (kanna . "栞菜")))

(define (symbol->name sym)
  ((fif true?
        cdr)
   (assq sym names)))

(define nodes '())
(define edges '())

(define (relate from to desc score)
  (let ((n (cons from to)))
    (or (find-relation n
                       (lambda (r)
                         (let ((d (assq 'desc r))
                               (s (assq 'score r)))
                           (set-cdr! d (cons desc (cdr d)))
                           (set-cdr! s (+ score (cdr s))))))
        (begin
          (set! nodes (cons n nodes))
          (set! edges (cons (cons n `((desc ,desc)
                                      (score . ,score)))
                            edges))))))

(define (find-relation n k)
  ((fif true? k)
   (assoc n edges)))

(define (related? x y)
  (find-relation (cons x y) (lambda (_) #t)))

(define (from? n x)
  (eq? (car n) x))

(define (to? n x)
  (eq? (cdr n) x))

(define flip-relation
  (case-lambda
    ((n)
     (and (related? (cdr n) (car n))
          (cons (cdr n) (car n))))
    ((n k)
     ((fif true? k)
      (flip-relation n)))))

(define (get-score n)
  (cdr (assq 'score n)))

(define (get-description n)
  (cdr (assq 'desc n)))

(define (describe-relation n)
  (find-relation n get-description))

(define (score-relation n)
  (or (find-relation n get-score) 0))

(define (print-node . ns)
  (for-each (cute find-relation <>
                  (lambda (r)
                    (display
                     (format "| ~a => ~a  (~a)~%"
                             (caar r) (cdar r)
                             (mapconcat (lambda (s)
                                          (string-append "\"" s "\""))
                                        (cdr (assq 'desc r))
                                        ", ")))))
            ns))

(define (iter-nodes k)
  (let lp ((nodes nodes))
    (unless (null? nodes)
      (k (car nodes))
      (lp (cdr nodes)))))

(define (filter-nodes p)
  (let ((ns '()))
    (iter-nodes (fif p
                     (cut find-relation <> (lambda (n)
                                             (set! ns (cons n ns))))))
    ns))

(define (from-links)
  (map car nodes))

(define (to-links)
  (map cdr nodes))

(define (all-members)
  (delete-duplicates! (from-links)))

(define (all-pairs) nodes)

(define (ordered-pairs)
  (concat! (map (lambda (x)
                  (map car
                       (sort (filter-nodes (cute to? <> (car x)))
                             (lambda (x y)
                               (> (get-score x) (get-score y))))))
                (sort-nodes (map (lambda (x)
                                   (cons x (score-loved x)))
                                 (all-members))))))

(define (all-combinations)
  (let lp ((cs '()) (ns nodes))
    (if (null? ns)
        cs
        (let ((n (car ns)))
          (lp (if (member (list (cdr n) (car n))
                          cs)
                  cs
                  (cons (list (car n) (cdr n)) cs))
              (cdr ns))))))

;; number-list :: [a] -> [(a . Int)]
(define (number-list ls)
  (let lp ((ns '()) (ls ls))
    (if (null? ls)
        ns
        (let ((x (car ls)))
          (lp ((fif not
                    (lambda (_) (cons (cons x 1) ns))
                    (lambda (n)
                      (set-cdr! n (add1 (cdr n)))
                      ns))
               (assq x ns))
              (cdr ls))))))

;; sort-nodes :: [(a . Int)] -> [(a . Int)]
(define (sort-nodes ns)
  (sort ns (lambda (x y)
             (> (cdr x) (cdr y)))))

(define (diff-nodes ms ns)
  (let lp ((ds '()) (ns ns))
    (if (null? ns)
        (sort-nodes ds)
        (lp (let* ((n (car ns))
                   (m (assq (car n) ms)))
              (cons (cons (car n)
                          (- (cdr m) (cdr n)))
                    ds))
            (cdr ns)))))

(define (get-total-score x p)
  (foldr (lambda (n acc)
           (+ (get-score n) acc))
         0
         (filter-nodes (cut p <> x))))

(define (score-loved x)
  (get-total-score x to?))

(define (score-loving x)
  (get-total-score x from?))

(define (score-between x y)
  (+ (score-relation (cons x y))
     (score-relation (cons y x))))

(define (-> x)
  (display (format "~%Links from [~a]~%" x))
  (iter-nodes (fif (cut from? <> x)
                   print-node)))

(define (<- x)
  (display (format "~%Links towards [~a]~%" x))
  (iter-nodes (fif (cut to? <> x)
                   print-node)))

(define (<-> x)
  (display (format "~%Reciprocal links for [~a]~%" x))
  (iter-nodes (fif (cut to? <> x)
                   (lambda (n)
                     (flip-relation n
                                    (lambda (m)
                                      (print-node m n)))))))

(define (<=> x)
  (display (format "~%Reciprocal matches for [~a]~%" x))
  (iter-nodes
   (fif (cut to? <> x)
        (lambda (n)
          (flip-relation n
                         (lambda (m)
                           (if (ormap (lambda (x)
                                        (ormap (lambda (y)
                                                 (equal? x y))
                                               (describe-relation m)))
                                      (describe-relation n))
                               (print-node m n))))))))

(define (<?> x)
  (let ((to (assq x (number-list (from-links))))
        (from (assq x (number-list (to-links)))))
    (display (string-append
              (format "~%Link statistics for [~a]~%"
                      x)
              (format "| ~a => ~a (love ~a)~%"
                      x
                      (cdr to)
                      (score-loving x))
              (format "| ~a => ~a (love ~a)~%"
                      (cdr from)
                      x
                      (score-loved x))))))

(define (info x)
  (for-each (cut <> x)
            (list <- <-> <=> -> <?>)))

;;; GraphViz (http://www.graphviz.org/) support

(define graphviz "C:/Program Files/ATT/Graphviz/bin/dot.exe")

(define (nodes->dot ns)
  (string-append "digraph cute {\n"
                 ;;"\tordering=out;\n"
                 ;;"\trankdir=LR;\n"
                 "\toverlap=true;\n"
                 "\tnode[fontname=\"msgothic.ttc\"];\n"
                 "\tedge[fontname=\"msgothic.ttc\",fontsize=9];\n"
                 (let lp ((str "") (ns ns))
                   (if (null? ns)
                       str
                       (let* ((n (car ns))
                              (s (score-relation n)))
                         (lp (string-append
                              str
                              (format "\t\"~a\" -> \"~a\""
                                      (symbol->name (car n))
                                      (symbol->name (cdr n)))
                              (format "[label=\"~a\",color=\"~a\","
                                      (break-string
                                       (car (describe-relation n))
                                       7)
                                      (cond ((> s 0) "red")
                                            ((= s 0) "green")
                                            (else "blue")))
                              (format "style=\"bold~a\"];\n"
                                      (if (and (not (= s 0)) (< s 1) (> s -1))
                                          ",dashed"
                                          "")))
                             (cdr ns)))))
                 "}"))

(define (write-dotfile dot file)
  (and (file-exists? file) (delete-file file))
  (with-output-to-file file
    (lambda ()
      (display dot)))
  file)

(define (dot->png dot png)
  (call-with-input-file (write-dotfile dot "c-ute.dot")
    (lambda (in)
      (and (file-exists? png) (delete-file png))
      (call-with-output-file png
        (lambda (out)
          (run graphviz "-Tpng" in out)))))
  'done)

;;; Setup database

;; Based on:
;; http://ex23.2ch.net/test/read.cgi/morningcoffee/1188654905/116-142
(begin
  (relate 'maimi 'erika "大好き" 1)
  (relate 'maimi 'kanna "良き妹" 1)
  (relate 'maimi 'airi "良き妹" 1)
  (relate 'maimi 'mai "姉妹" 0)
  (relate 'erika 'maimi "一番可愛いよ" 1)
  (relate 'erika 'kanna "仲間" 0)
  (relate 'erika 'chisato "おソロパジャマ" 0)
  (relate 'kanna 'erika "仲間" 0)
  (relate 'kanna 'maimi "好き" 1)
  (relate 'kanna 'saki "喰ってやるよ" 1)
  (relate 'kanna 'mai "喰ってやるよ" 1)
  (relate 'kanna 'airi "大好き" 1)
  (relate 'kanna 'chisato "愛理に手出すんじゃねぇよ" -1)
  (relate 'saki 'maimi "荷物整理" 0)
  (relate 'saki 'erika "彼氏にしたい" 1)
  (relate 'saki 'kanna "興味がある" 0.5)
  (relate 'saki 'chisato "愛理に手出すんじゃねぇよ" -1)
  (relate 'saki 'airi "好き" 1)
  (relate 'airi 'kanna "受け入れる" 1)
  (relate 'airi 'chisato "最近親密" 1)
  (relate 'mai 'erika "保護者" 0)
  (relate 'mai 'maimi "姉妹" 0)
  (relate 'mai 'chisato "恋人" 1)
  (relate 'chisato 'erika "おソロパジャマ" 0)
  (relate 'chisato 'mai "恋人" 1)
  (relate 'chisato 'airi "最近親密" 1))

;; query relations / draw graphs

(if (file-exists? graphviz)
    (dot->png (nodes->dot (ordered-pairs))
              "c-ute.png")
    (for-each info (all-members)))

追記(グラフ描画について)

Graphviz というソフトによって関係図を可視化できる、ということを教えていただきました(既に上プログラムを実行すると自動的に関係画像を作成するようにしてあります)。ここでは技術的な観点から幾つか注意点を挙げておきます。

まず、Scheme プログラムから Graphviz を動かす方法について。コマンドラインからの起動のように、プログラムへのオプション文字列で入出力ファイルを指定する方法ではどうも上手く行きませんでした。調査の結果、入出力ファイルポートScheme 側で用意しておく必要があるようです。処理系によって異なりますが、PLT Scheme の場合 subprocess という関数を次のように呼び出します。

(subprocess output-port input-port #f "/path/to/dot.exe" "-Tpng")

ここで output-port は png画像ファイルへの出力ポート。input-port は dot ファイルグラフの定義ファイル)の入力ポートです。エラーポートは必要無いでしょう (#f)。

dot という名前の実行ファイルが、関係図のような有向グラフを描画するプログラムです。最後にオプション文字列として出力形式を指定します(png, jpeg, gif, etc.)。

次に dot ファイルScheme で書く方法ですが、以下の基本的な有向グラフの書式

digraph g {
  A -> B;
  B -> C;
  C -> A;
}

を理解すれば、後は実直に Schemeデータを当てはめて format 関数等で変換するだけです。

(string-append
 "digraph g {"
 (format "~a -> ~a;" (car node) (cdr node))
 "}")

問題は、ノードを配置する順番によって出来上がる画像が変わってくる、ということです。

より見た目に分かりやすくするための工夫としては、相互にリンクするノード同士が dot ファイル上でも近接して出力されるようにすると良いでしょう。関連の強いものが画像の上でも近くに表示されるようになります。

また上述(特に例3)のスコア概念を応用し、スコアの低いものが後に出力されるようにすることで、重力感覚に一致するような関係図を得ることができるでしょう。

2007-07-13

KEREM SHALOM, Israel, July 11 ?? Real life has a way of intruding into the airy absolutes of the Israeli-Palestinian conflict. Each side may deny the other’s historical legitimacy, or plot the other’s demise, but somehow, the gritty business of coexistence marches on.

Skip to next paragraph

Enlarge This Image

Rina Castelnuovo for The New York Times

An Israeli man signaled for a truck to move toward Gaza at Sufa on Wednesday. Commerce continues despite the Hamas takeover.

The New York Times

For the past month, since the Islamic militants of Hamas took over the Gaza Strip, Israel has kept the main commercial crossing point at Karni shuttered, squeezing the life out of the limp Gazan economy. Israel bans contact with Hamas, and Hamas seeks Israel’s destruction, making border crossing etiquette more precarious than elsewhere.

Yet at this small crossing near the Egyptian border on Wednesday, between mortar attacks by Hamas and other militants, about 20 truckloads of milk products, meat, medicines and eggs passed from Israel into Gaza, part of the effort to keep basic commodities reaching the 1.5 million Palestinians of the largely isolated strip. Most of the supplies are not humanitarian relief, but are ordered by Palestinian merchants from Israeli suppliers, relying on contacts built up over years.

The mechanics of the crossover manage to answer Israel’s security needs while avoiding contact with Hamas. At Kerem Shalom, Israeli trucks transfer their goods to what Israeli military officials describe as a “sterile” Palestinian truck. Driven by a carefully vetted Palestinian driver, the truck never leaves the terminal, carrying the goods to the Palestinian side, where they are transferred onto ordinary Palestinian trucks that drive into Gaza.

Kerem Shalom, which means “vineyard of peace,” is surrounded by fences and concrete barriers. It can process only about 20 trucks a day, so it is reserved for products that require refrigeration.

The hardier goods, which make up the bulk of the supplies, go through another crossing, at Sufa, to the north. About 100 Israeli trucks a day come from Israel, swirling up clouds of dust before dumping thousands of tons of dry products, bales of straw and crates of fruit on “the platform,” a fenced-in patch of baked earth. At 3 p.m. the Israeli suppliers leave. Like drug dealers picking up a “drop,” the Gaza merchants send in trucks from a gate on the other side and take the products away.

Other products make their way into Gaza with virtually no human interaction. At the fuel depot at Nahal Oz, Israeli tankers pour diesel, gasoline and cooking gas into Gaza through pipes that run beneath the border. And even at Karni, the main crossing that closed for normal operations on June 12, the Israelis have adapted a 650-foot-long conveyor belt, which was previously used for gravel, to send in grain.

“It is better all around from a security point of view that commodities go in,” said Maj. Peter Lerner of the Coordination and Liaison Administration, the Israeli military agency that deals with the civilian aspects of the Gaza border. “More despair doesn’t serve anyone.”

Israeli officials cite security reasons for having shut Karni, the only crossing equipped to send containers into Gaza, or to handle exports out of the strip. “Karni was based on the concept of two sides operating together,” said Col. Nir Press, the head of the coordination agency.

Colonel Press noted that in April 2006, a vehicle loaded with half a ton of explosives got through three of four checkpoints on the Palestinian side of Karni, and was stopped at the last security position by members of the American-backed Presidential Guard, loyal to the Palestinian president, Mahmoud Abbas of Fatah.

But the Presidential Guard is no longer there, having been routed, along with all other Fatah forces in Gaza, by Hamas.

Instead, the military wing of Hamas and other Palestinian factions have been firing mortar shells at Kerem Shalom. On Tuesday, 10 of them landed in and around the terminal as two trucks of milk were passing. The crossing was closed for the rest of the day. [Another barrage of mortar shells hit areas around Kerem Shalom on Thursday.]

Hamas suspects that Israel wants to use Kerem Shalom to replace the Rafah crossing on the Egypt-Gaza border, which has been closed since June 9. The Palestinians had symbolic control at Rafah. At Kerem Shalom, Israel can better supervise who ?? and what ?? is going in and out of the strip.

“Kerem Shalom is a military post, a place from which Israeli tanks begin their incursions into Gaza,” said Fawzi Barhoum, a Hamas spokesman, justifying the mortar attacks. “How can we consider it a safe and legitimate crossing to replace Rafah?”

But when it comes to food, rather than principle, Hamas is proving itself pragmatic as well. On Sunday, Palestinian merchants, trying to press Israel to reopen Karni, told the Israelis that Hamas had barred the import of Israeli fruit. But by Wednesday, the Israeli fruit was ordered again. “Hamas does not want to lose the private sector,” a Gaza businessman explained.

Tellingly, the exposed Sufa crossing, through which most of the food comes, has not been attacked with mortars so far. Without Karni, however, and with the smaller crossings operating on a one-way basis, Gaza can barely subsist. With hardly any raw materials going in, and no products from Gazan farms, greenhouses and factories so far allowed out, Gaza’s tiny industrial base is on the verge of collapse.

Hamas officials say they want to start negotiations with Israel about reopening the formal crossings. Major Lerner said that Hamas had “a few things to do” first, including recognizing Israel’s right to exist and freeing Gilad Shalit, the Israeli soldier captured and taken to Gaza in a raid more than a year ago.

But the ultimate test of pragmatism may come in September when the Hebrew calendar enters what is known in Jewish law as a “shmita” year. Then the fields of Israel are supposed to lie fallow, and observant Jews seek agricultural products grown elsewhere. Before the Hamas takeover, Israel’s rabbis had reached agreements with Palestinians to import vegetables from Gaza, Major Lerner said. Given the needs of both sides, it may still happen.

2007-06-04

[]??Delphihacks??Delphi??Win32API??

Delphi - Wikipedia??Windows開発の決定版 - Delphi(Skype??なでしこ)

タグ「delphi」を含む注目エントリー - はてなブックマーク

Delphiアプリケーションのメモリリーク検出法

Delphiアプリケーションのメモリリーク検出法 (山本隆の開発日誌)

作ろう!コンポーネント Delphi C++Builder

http://www.componentsource.co.jp/features/delphi/

TMS Software | Productivity software building blocks

Components > Effects and Multimedia > Video. Torry's Delphi Pages

Components > Effects and Multimedia > Audio. Torry's Delphi Pages

Components > Effects and Multimedia > Voice. Torry's Delphi Pages

Components > Effects and Multimedia > Direct X. Torry's Delphi Pages

try finally end

CとDelphiの対比表

eXeScope(Windows95/98/Me / ユーティリティ)

Delphi - テクノラティブログ検索

2ch検索: [Delphi]

Delphi-ML〓〓〓〓〓〓〓〓〓〓〓??About Delphi

Delphi Q & A掲示板

Delphi Q & A 〓f〓〓〓〓 〓〓〓〓〓〓O〓〓(HTML〓o〓[〓W〓〓〓〓)

fdelphi.com

Delphi入門

旧 Delphi 入門??Seventh Delphi

Delphiメモ

超ローテクDelphi講座

俺のためのDelphi学習

Delphi はじめの一歩

VB〓〓VC〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓H

Delphi の格言

キーボードからの入力取得

マウスボタンのクリック、マウスの位置情報の取得

ジョイスティックからの入力取得

バッカーへの階段: 入門:キーロガー

テキストファイルを読み書きする

テキストファイルのロードとセーブ

DelphiによるWin32API

Delphi WAVEサウンド音を鳴らす/Tips & Tricks

MIDI、WAVEファイルを再生する

サウンドを読み込んで鳴らす

MIDIを演奏する MCI/midiStream

5分ではじめるDelphi - 第1回 簡単なメディアプレーヤの作成(前編)

MP3プレイヤーを作る>dllによる再生

Controling sound volume from code

Torry's Delphi Pages

lsMicrophone: mxl.dwComponentType :=MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;

MIXERLINE_COMPONENTTYPE_DST_SPEAKERS

MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT

SwissDelphiCenter.ch : ...set the volume for the microphone/ mute it (enhanced)?

Components > Sound Effects > Mixer. Torry's Delphi Pages

uses MMSystems;

//

PlaySound('C:\WINNT\Media\start.wav', 0, SND_FILENAME or SND_ASYNC);


ビットマップを表示しよう

画像ファイルを指定した位置へ表示

俺Delゲーム応用

画面をキャプチャして表示する

めもニャンだむ

Delphi6でプログラミング ビットマップの半透明コピー AlphaDraw

画像処理プログラミング講座

Graphic Effect

カラー画像をモノクロ画像に変換

procedure TForm1.Button1Click(Sender: TObject);

var

bmp1,bmp2 :TBitmap;

begin

bmp1 :=Tbitmap.Create;

bmp2 :=Tbitmap.Create;

try

bmp1.LoadFromFile('C:\Program Files\Common Files\Borland Shared\Images\Splash\256Color\FINANCE.BMP');

bmp2.LoadFromFile('C:\Program Files\Common Files\Borland Shared\Images\Splash\256Color\FACTORY.BMP');

Form1.Canvas.Draw(10,10,bmp1);

Form1.Image1.Canvas.Draw(10,10,bmp2);

finally

bmp1.Free;

bmp2.Free;

end;

end;


無料版Delphi6でSTGをつくるためのプログラミング講座 Ver.2005 Jan.

Delphiでわずか59KBのオセロを作る方法

めもニャンだむ:BIOS 情報

コンストラクタとデストラクタ

SwissDelphiCenter.ch : ...get the MAC Address?

乱数

DelphiでMD5

もっと楽にGUIとの連携がしたい:Python + Delphi = P4D(Python for Delphi) - ふにゃるん

Delphi WindowsのOSのバージョンを取得する/Tips & Tricks

SourceForge.net: Gecko SDK for Delphi

DelphiでWinSock

SQLite-もげもげ〜

BDS(Delphi/BCB)用SQLiteライブラリ (山本隆の開発日誌)

Application.ProcessMessages

FrontPage - DelphiVIP

SwissDelphiCenter.ch : programming tips

Torry's Delphi Pages

Delphi Tips

Delphi Code Tips

Magic of Delphi4〓z〓[〓〓 〓y〓[〓W

Delphi Win32API/API関数一覧

Delphi〓〓〓Z

クジラ式 Delphi 資料

Delphi〓〓y〓[〓W

サイト移転のお知らせ(Mr.XRAY)

openDelphi.org

KOL and MCKPage

Gen's Delphi Labo.

サイト移転のお知らせ(Mr.XRAY)

ナッキーの「Turbo Delphiはじめて奮戦記」- 第1回 Turbo Delphi のインストール

フリーのTurbo Delphiで始めるWindowsプログラミング:ITpro

フリーのTurbo Delphiで始めるWindowsプログラミング:ITpro

http://torrent.borland.com/turbo_hotfix_rollup.zip

http://torrent.borland.com/prereqs_jp.zip

http://torrent.borland.com/turbodelphi_jp.exe

(1) \dotNETRedist\dotnetfx.exe

(2) \dotNETRedist\langpack.exe

(3) \dotNETRedist\NDP1.1sp1-KB867460-X86.exe

\dotNETSDK\setup.exe

\IE60SP1\ie6setup.exe

\dotNETJSharp\vjredist.exe

\dotNETJSharp\vjredist-Permalink | 記事への反応(1) | 15:15

2007-05-09

http://anond.hatelabo.jp/20070508170219

FizzBuzz・・・。


DROP TABLE IF EXISTS `tmp_fizzbuzz`;
CREATE TABLE `tmp_fizzbuzz` (
`num` int( 4 ) NOT NULL default 0,
`fizz` VARCHAR( 4 ) NOT NULL default '',
`buzz` VARCHAR( 4 ) NOT NULL default '',
PRIMARY KEY  (`num`)
)
;

delimiter //
DROP PROCEDURE IF EXISTS fizzbuzz//
CREATE PROCEDURE  fizzbuzz()
BEGIN

	DECLARE bufnum INT DEFAULT 1;
	delete from `tmp_fizzbuzz`;
	WHILE bufnum <= 15 DO
	    insert into tmp_fizzbuzz (num) value (bufnum);
	    set bufnum = bufnum + 1;
	END WHILE;

END
//
delimiter ;
call fizzbuzz();

update tmp_fizzbuzz set fizz = 'Fizz' where mod(num,3) = 0;
update tmp_fizzbuzz set buzz = 'Buzz' where mod(num,5) = 0;

select 
if (concat( fizz ,buzz) = '' ,
	num,
	concat( fizz ,buzz)
) FizzBuzz
from tmp_fizzbuzz;


mySQLでつくってみた。

文字列の連結ができないで死にそうになった。。+とか&でやっても0で帰ってきやがるのさ。

そしてそもそもストアドを使わない仮想レコードの作り方ができないで死にそうになった。

なんか、こんなのに時間かけるつもりなかったんだけどなー・・・。

だめっぽ。

modとか使っちゃだめなんだっけ? 知るかヽ(`д´* )ノプンピー

2007-04-30

今日トリビア

ビギン・ザ・ビギン」の、後ろのほうの「ビギン」は「beguine」。

30+ん年間、beginと思ってたよ。

ログイン ユーザー登録
ようこそ ゲスト さん