google2001で死んだ
2001年は多分、侍魂の先行者なんかが今で言うホッテントリな頃だったと思います。てことはですね、私がむかーし友人に勧められて、ホームページとか制作し始めた頃でもあったと思います。
で、ワタシの作ったホームページが、ありましてですね。アーカイブされてた訳です。
それは邪鬼眼なみの破壊力を持っておりまして、誰かに観られたら舌かんで死ぬ。ほんっとヤバいものを観てしまいました。google2001こわい。
« 2008年09月 | メイン | 2008年11月 »
やる夫のような天才プログラマは いつもクズSEに足を引っ張られて成功を掴み損ねるお。 ____ /_ノ ヽ_\ /( ●) ( ●)\ / ::::::⌒(__人__)⌒:::::\ |  ̄ | \ / コンポジットだかポンコジットだか知らないけど デザパタの勉強はクズSEに思想教育されてるみたいでヤダお! ノ L____ ⌒ \ / \ / (○) (○)\ / (__人__) \ | |::::::| | \ l;;;;;;l /l!| ! / `ー' \ |i / ヽ !l ヽi ( 丶- 、 しE |そ ドンッ!! `ー、_ノ ∑ l、E ノ < レY^V^ヽl いいかやる夫。これまで俺が教えてきた考え方は 素晴らしいプログラムの組み方というよりは作法だ。 つまり、プログラマ向けの躾みたいなもんだから お前がなっちゃいねーとこっちが恥かくんだボケ。 / ̄ ̄\ / _ノ \ | ( ●)(●) . | (__人__) | ` ⌒´ノ . | } . ヽ } ヽ ノ / く | \ | |ヽ、二⌒) ドシー!悪口でおいらの心が折れる前に とっととポンコジットパターンを教えるお! ____ /_ノ ' ヽ_\ /(≡) (≡)\ / /// (__人__) ///\ | |r┬-| | \ ` ー'´ / いいだろう。 / ̄ ̄\ / \ |:::::: | . |::::::::::: | |:::::::::::::: | ....,:::´, . . |:::::::::::::: } ....:::,, .. . ヽ:::::::::::::: } ,):::::::ノ . ヽ:::::::::: ノ (:::::ソ: . /:::::::::::: く ,ふ´.. -―――――|:::::::::::::::: \ -―,――ノ::ノ―― |:::::::::::::::|ヽ、二⌒)━~~'´
・・・ということだ。
/ ̄ ̄\
/ _ノ \
| ( ●)(●)
. | (__人__)
| ` ⌒´ノ
. | }
. ヽ }
ヽ ノ
/ く
| \
| |ヽ、二⌒)
?
|:;:;:;;:;:;:;:;:i;:;::::;:;|
|;:;:_:_;:;_:;:l:;_:_;:_;|
|___|__|
/ ・ ・ \
/ (●) (●) \
| (__人__) |
\________/
/|├┤├┤|\
(理解してんだかしてねーんだか
わかんねぇリアクションは頼むからやめてくれ)
・・・・・・・。
/ ̄ ̄\
/ _ノ \
| ( ○)(○)
. | u (__人__)
| ` ⌒´ノ
. | }
. ヽ }
ヽ ノ
/ く
| \
| |ヽ、二⌒)
ディレクトリ構造だってことは理解したお
おいらのお宝ディレクトリへのパスは頭に
たたきこんであるお。
どこにいようと相対パスで手繰れるほどだお。
ディレクトリ構造は得意だお。
____
/ \
/ ─ ─\
/ (●) (●) \
| (__人__) | ________
\ ` ⌒´ ,/ .| | |
ノ \ | | |
/´ | | |
| l | | |
ヽ -一ー_~、⌒)^),-、 | |_________|
ヽ ____,ノγ⌒ヽ)ニニ- ̄ | | |
把握したなら
それを踏まえてコードを書いてみろ。
/ ̄ ̄\
/ \
|:::::: |
. |::::::::::: |
|:::::::::::::: | ....,:::´, .
. |:::::::::::::: } ....:::,, ..
. ヽ:::::::::::::: } ,):::::::ノ .
ヽ:::::::::: ノ (:::::ソ: .
/:::::::::::: く ,ふ´..
-―――――|:::::::::::::::: \ -―,――ノ::ノ――
|:::::::::::::::|ヽ、二⌒)━~~'´
// まず抽象コンポーネントを用意するお
public abstract class YaruoComponent {
// 操作の定義 追加・削除・子ノードの取得
public void add( YaruoComponent param ){}
public void remove( YaruoComponent param ){}
public YaruoComponent getChild( int idx ){}
// ビジネスロジック定義
public String getName(){}
public String getDescription(){}
public double getEffectiveValue(){}
public void print(){}
}
// アビリティ1つを表現する
public class AbilityItem extends YaruoComponent {
String name; // アビリティ名
String description; // 説明
double effectiveValue; // アビリティ効果値
public AbilityItem( String name, String description, double effectiveValue ){
this.name = name;
this.description = description;
this.effectiveValue = effectiveValue;
}
// ビジネスロジックのオーバーライド
public String getName(){ return name; }
public String getDescription(){ return description; }
public double getEffectiveValue(){ return effectiveValue; }
public void print(){
System.out.println( getName() );
System.out.println( getDescription() );
System.out.println( getEffectiveValue() );
}
}
// アビリティコレクションを表現する
public class AbilityCollection extends YaruoComponent {
ArrayList abilityComponents = new ArrayList();
String name; // アビリティ名
String description; // 説明
public AbilityCollection( String name, String description ){
this.name = name;
this.description = description;
}
public void add( YaruoComponent param ){
abilityComponents.add( param );
}
public void remove( YaruoComponent param ){
abilityComponents.remove( param );
}
public YaruoComponent getChild( int idx ){
return (YaruoComponent)abilityComponents.get( idx );
}
// ビジネスロジックのオーバーライド
public String getName(){ return name; }
public String getDescription(){ return description; }
public void print(){
System.out.println( getName() );
System.out.println( getDescription() );
}
}
___
/ ⌒ ⌒\ ざっとこんなもんだお
/ (⌒) (⌒) \
/ ///(__人__)/// \
| `Y⌒y'´ | ________
\ ゙ー ′ ,/ | | |
ノ \ | | |
/´ | | |
| l | | |
ヽ -一ー_~、⌒)^),-、 | |________|
ヽ ____,ノγ⌒ヽ)ニニ-  ̄ | | |
これでアビリティ内アビリティを延々と
表現できるでおJAL
|:;:;:;;:;:;:;:;:i;:;::::;:;|
|;:;:_:_;:;_:;:l:;_:_;:_;|
|___|__|
/ ・ ・ \
/ (●) (●) \
| (__人__) |
\________/
/|├┤├┤|\
(なんだこの自由すぎるキャラは)
そのとおりだ。おおむね間違っていないが、
前回学んだイテレータが生かされてないのと
AbilityItemがノードの操作をできてしまうから
抽象クラスでは例外を投げるようにするのが普通だ。
/ ̄ ̄\
/ _ノ \
| ( ●)(●)
. | (__人__)
| ` ⌒´ノ
. | }
. ヽ }
ヽ ノ
/ く
| \
| |ヽ、二⌒)
public abstract class YaruoComponent {
// 操作の定義 追加・削除・子ノードの取得
public void add( YaruoComponent param ){
throw new UnsupportedOperationException();
}
// 以下のメソッドに例外を埋め込んでく
}
// アビリティコレクションを表現する
public class AbilityCollection extends YaruoComponent {
ArrayList abilityComponents = new ArrayList();
// 中略
public void print(){
System.out.println( getName() );
System.out.println( getDescription() );
// イテレータで実装
Iterator itr = abilityComponents.iterator();
while( itr.hasNext() ){
YaruoComponent ability = (YaruoComponent)itr.next();
ability.print();
}
}
}
これでどうかお。完璧すぎてこわいお。
____
/⌒ ⌒\
. /( ―) (―)\ ふん、ふーん。
/ ::::::⌒(__人__)⌒::::: \ ふ、んー。
| |r┬-| |
\ `ー'´ /
ノ \
/´ ヽ カ
| l l||l 从人 l||l l||l 从人 l||l カ タ
ヽ -一''''''"~~``'ー--、 -一'''''''ー-、. タ
ヽ ____(⌒)(⌒)⌒) ) (⌒_(⌒)⌒)⌒))
┌┬┬┐┌┬┬┬┐┌┬┬┬┐┌┬┬┬┐
,. - ''"| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ρ ̄`l
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ノ ̄
そのとおりだ。
これで俺からのデザパタ講義は完了だ。
ほかにも教えなきゃいかんことがたくさんあるが
しばらく一人でやってみろ。
/ ̄ ̄\
/ \
|:::::: |
. |::::::::::: |
|:::::::::::::: | ....,:::´, .
. |:::::::::::::: } ....:::,, ..
. ヽ:::::::::::::: } ,):::::::ノ .
ヽ:::::::::: ノ (:::::ソ: .
/:::::::::::: く ,ふ´..
-―――――|:::::::::::::::: \ -―,――ノ::ノ――
|:::::::::::::::|ヽ、二⌒)━~~'´
やる夫はまだまだ知りたいことがたくさんあるお
次は暗号技術について知りたいから
やる夫で学ぶシリーズかけるくらいになっとけお。
____
/⌒ ⌒\
/( ―) (―)\
/::::::⌒(__人__)⌒::::: \
| |
\ /
っっっっ!!
___
/ \ ___
/ノし u; \ ;/(>)^ ヽ\; あぶぶ
| ⌒ ) ;/ (_ (<) \;
| 、 );/ /rェヾ__)⌒::: ヾ;
| ^ | i `⌒´-'´ u; ノ;;
| | \ヽ 、 , /;
| ;j |/ \-^^n ∠ ヾ、
\ / ! 、 / ̄~ノ __/ i;
/ ⌒ヽ ヽ二) /(⌒ ノ
/ r、 \ / ./  ̄ ̄ ̄/
あるフィールドはユーザからの直接入力をさせたくないけど、用意されたインターフェイスからはアイテムの追加ができて、アイテムを削除する際もアイテム単位で行いたい。ただ、フィールドのスタイルはテキストフィールドっぽい体裁で表示させたい。なんてことを言われたのでやってみました。サンプルはユーザインターフェイスのところのみ記述していて、どこかへデータをポストしたいとかいった場合は、実際のアイテムのデータハンドリングを他で丁寧に行う必要があります。
var elem = range.parentElement();
range.moveToElementText( elem );
range.select();
これだけで良いらしい。createaRangeであれこれ検索してもなかなかやりたい事が出てこなくてすごい参った。のでポスト。
<script>
var inst = {
selectElem : null,
itemFocus : function(){
var range = document.selection.createRange();
var elem = range.parentElement();
inst.selectElem = elem;
range.moveToElementText( elem );
range.select();
}
}
document.attachEvent( "onkeydown", function( event ){
if( event.keyCode == 46 && inst.selectElem != null ){
inst.selectElem.parentNode.removeChild( inst.selectElem );
}
});
document.attachEvent( "onclick", function( event ){
if( event.srcElement.id != null && event.srcElement.id.search( /gen*/g) != 0 ){
inst.selectElem = null;
}
});
window.onload = function(){
var elems = document.getElementsByTagName( "span" );
for( var idx in elems ){
elems[ idx ].onclick = inst.itemFocus;
}
}
</script>
<body>
<div style="border: 1px solid #ddd; padding: 0.5em 1em; background-color: #F6F6F6;">
<div>
<span id="gen1">ほげ;</span><span id="gen2">もげ;</span><span id="gen3" >ぴよ;</span><span id="gen4" >ふが;</span>
</div></div>
package {
import Box2D.Common.Math.b2Vec2;
import Box2D.Dynamics.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.Security;
import flash.geom.Rectangle;
import flash.geom.Point;
import mx.controls.Alert;
public class TwitterBox extends Sprite {
private static const DRAW_SCALE:Number = 100;
private var world:b2World;
private var boxBegin:Point = new Point();
private var mUrlAry:Array = new Array();
private var mIdx:int = 0;
public function TwitterBox() {
var req:URLRequest = new URLRequest();
req.url = "http://mojalog.com/mojascript/proxy.php?u=higemoja";
req.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.addEventListener( Event.COMPLETE, proxyLoaded );
loader.addEventListener( IOErrorEvent.IO_ERROR, errorHandler );
loader.load( req );
////////////////////////////////////////
// 物理エンジンのセットアップ
// 外枠を定義する
var worldAABB:b2AABB = new b2AABB();
worldAABB.lowerBound.Set(-100, -100);
worldAABB.upperBound.Set(100, 100);
// 重力を下方向に10m/s^2とする
var gravity:b2Vec2 = new b2Vec2(0, 10);
// 外枠と重力を指定して、物理エンジン全体をセットアップする
world = new b2World(worldAABB, gravity, true);
////////////////////////////////////////
// 床の設置
// 床は画面の下のほうに設置します
// 床の位置を左から2.5m、上から3mとする
var floorBodyDef:b2BodyDef = new b2BodyDef();
floorBodyDef.position.Set(2.5, 3);
// 床の形を、幅4m、厚さ20cmとする
// 指定するのはその半分の値
var floorShapeDef:b2PolygonDef = new b2PolygonDef();
floorShapeDef.SetAsBox(2, 0.1);
// 床を動かない物体として作る
var floor:b2Body = world.CreateStaticBody(floorBodyDef);
floor.CreateShape(floorShapeDef);
////////////////////////////////////////
// 描画設定
var debugDraw:b2DebugDraw = new b2DebugDraw();
debugDraw.m_sprite = this;
debugDraw.m_drawScale = DRAW_SCALE; // 1mを100ピクセルにする
debugDraw.m_fillAlpha = 0.3; // 不透明度
debugDraw.m_lineThickness = 1; // 線の太さ
debugDraw.m_drawFlags = b2DebugDraw.e_shapeBit;
world.SetDebugDraw(debugDraw);
// イベントハンドラを登録する
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function mouseDownHandler(event:MouseEvent):void {
// マウスが押された場所を記憶しておく
boxBegin.x = event.stageX;
boxBegin.y = event.stageY;
}
private function mouseUpHandler(event:MouseEvent):void {
if( mIdx >= mUrlAry.length ) mIdx = 0;
if( mUrlAry[ mIdx ] == null ) return;
var x:Number = (event.stageX + boxBegin.x) / 2 / DRAW_SCALE;
var y:Number = (event.stageY + boxBegin.y) / 2 / DRAW_SCALE;
var halfWidth:Number = Math.abs( event.stageX - boxBegin.x ) / 2 / DRAW_SCALE;
var halfHeight:Number = Math.abs( event.stageY - boxBegin.y ) / 2 / DRAW_SCALE;
// 箱の場所を設定する
var bodyDef:b2BodyDef = new b2BodyDef();
bodyDef.position.Set( x, -1 );
// 箱の大きさなどを設定する
var shapeDef:b2PolygonDef= new b2PolygonDef();
shapeDef.SetAsBox( 0.95, 0.2 );
shapeDef.density = 1;
shapeDef.restitution = .4;
// 箱を動く物体として作る
var body:b2Body = world.CreateDynamicBody(bodyDef);
body.CreateShape(shapeDef);
body.SetMassFromShapes();
var _loader:Loader = new Loader();
_loader.load( new URLRequest( mUrlAry[ mIdx ] ) );
mIdx++;
_loader.contentLoaderInfo.addEventListener( Event.COMPLETE, function( event:Event ):void {
var bodyImg:Bitmap = Bitmap( event.target.loader.content );
bodyImg.x = -bodyImg.width / 2;
bodyImg.y = -bodyImg.height / 2;
body.m_userData = new Sprite();
body.GetUserData().x = body.GetWorldCenter().x * DRAW_SCALE;
body.GetUserData().y = body.GetWorldCenter().y * DRAW_SCALE;
body.GetUserData().addChild(bodyImg);
addChild(body.GetUserData());
});
}
private function enterFrameHandler(event:Event):void {
// Flashはデフォルトで秒間24フレームなので、
// 物理シミュレーションを1/24秒進める
for (var b:b2Body = world.GetBodyList(); b; b = b.GetNext()) {
if (b.GetUserData() is Sprite) {
// 物理エンジン内での位置と回転角度を反映させる
b.GetUserData().x = b.GetWorldCenter().x * DRAW_SCALE;
b.GetUserData().y = b.GetWorldCenter().y * DRAW_SCALE;
b.GetUserData().rotation = b.GetAngle() * 180 / Math.PI;
}
}
world.Step(1 / 24, 10);
}
private function proxyLoaded( event:Event ): void {
var loader:URLLoader = event.currentTarget as URLLoader;
var xmlData:XML = XML( loader.data );
var urlList:XMLList = xmlData.elem;
for each( var elem:Object in urlList ){
mUrlAry.push( String( elem.@url ) );
}
}
private function errorHandler( event:Event ): void {}
}
}
<?php
putenv( 'GDFONTPATH=' . realpath('./font/') );
$font = 'HONYA-JI';
$fontpath = 'HONYA-JI.ttf';
$height = $_GET["h"];
$width = $_GET["w"];
$fsize = $_GET["s"];
$im = imagecreate( $width, $height );
$white = imagecolorallocate( $im, 255, 255, 255 );
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle( $im, 0, 0, $width -1, $height -1, $white );
imagettftext($im, $fsize, 0, 5, $fsize *1.5, $black, $fontpath, mb_convert_encoding($_GET["t"],"UTF-8","auto"));
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>