七行プログラミング (452レス)
七行プログラミング http://medaka.5ch.net/test/read.cgi/php/1036141603/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
359: nobodyさん [sage] 2005/04/27(水) 02:12:54 ID:??? >>358 ライブラリ使い過ぎると面白さ半減ってことだろ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/359
360: nobodyさん [] 2005/04/27(水) 03:24:58 ID:0BxullHs モジュール/ライブラリに関して >>46, >>135 >>136, >>174 >>175 http://cm.xrea.cc/techinfo.cgi の 0.1. ライブラリ及びモジュールの利用 >>355 requireって () 省略できるはず。 http://medaka.5ch.net/test/read.cgi/php/1036141603/360
361: nobodyさん [sage] 2005/04/27(水) 07:43:42 ID:??? >>355 まぁでも、7行で基本機能を備えたwikiが使えるなら実世界でも結構有用じゃないか。 Text_Wikiの機能のデモにはなるでしょ。 むしろwiki技術関連スレ向きとは思うが。 向こうにも一応アンカー張ってあるね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/361
362: nobodyさん [sage] 2005/04/28(木) 12:12:12 ID:??? 流れを無視して、7vote が 7 行に収まったのでパッケージング。 #!perl use CGI":all";charset$c='UTF-8';${$_}=param$_ for f,n,v;$f=~s/\W//g;open F,"+<$ f"if chdir V;eval{flock F,2};$t=<F>;/\t/and$D{$`}+=$' for<F>;seek F,0,0;$n?$D{$ n}||=1:$v&&$D{$v}++,print F$t,map"$_\t$D{$_}\n",keys%D if$n||$v;$L{$K[$i++]}=$_ for radio_group(v,[@K=sort{$D{$b}<=>$D{$a}}keys%D]);put header,start_html(-lang ,ja,encoding,$c,-Title,$t),h1($t),startform,tabl
e({},Tr[map{td["$L{$_}($D{$_})" ,hr{width,$D{$_}}]}@K]),hr,p(textfield(n),hidden(f,$F),submit),endform,end_html UTF-8 になったのがちょっと悔しい。 ファイル名は \w+ にしました。 http://medaka.5ch.net/test/read.cgi/php/1036141603/362
363: nobodyさん [hg] 2005/11/07(月) 20:21:27 ID:??? 半年ぶりフォーーーーーーーーーーーーーーーーーーーーーー http://medaka.5ch.net/test/read.cgi/php/1036141603/363
364: nobodyさん [] 2005/11/23(水) 11:59:34 ID:8dGTpf7c 良スレあげ http://medaka.5ch.net/test/read.cgi/php/1036141603/364
365: nobodyさん [sage] 2006/01/21(土) 13:50:12 ID:??? #!/usr/bin/perl my@d=([qw/? ? ? ? ? ? ? ? ? ? ? ? ? ?/],[qw/☆ △ ■/]); my$c='Shift_JIS';my$l='ja';use CGI':standard';my@r=(0)x@d; print header(-charset=>$c),start_html(-encoding=>$c,-lang=>$l),start_form, (map{my$i=$_;ul li[(map{$r[$i]+=param($_);$_.textfield -name=>$_}@{$d[$i]}), "計 $r[$i]"]}0..$#d),ul(li"$r[1]÷$r[0]=".eval{$r[1]/$r[0]}),submit,end_form, end_html; http://medaka.5ch.net/test/read.cgi/php/1036141603/365
366: nobodyさん [] 2006/01/21(土) 23:54:14 ID:e+ke+qvM なぜ丸付き数字と図形なのかわからんけど面白いですね。 どういうときに使えるだろう・・・。と考えてしまう http://medaka.5ch.net/test/read.cgi/php/1036141603/366
367: クロエ [sage] 2006/01/22(日) 02:56:50 ID:??? http://tool-6.net/?0001 イメージ的には、こんな感じなんですが…。【1】,「?〜?まで入力した数値を総計。」 【2】,「A+B+Cに入力した数値を総計。」 【3】,「【2】÷【1】×100」っていう演算プログラムなんですが…。 http://medaka.5ch.net/test/read.cgi/php/1036141603/367
368: 365 [sage] 2006/01/22(日) 10:02:46 ID:??? >>367 仕様変更は34,000円からになっておりますw 話の流れがわからない人はhttp://pc8.2ch.net/test/read.cgi/tech/1134327348/756- >>365はかなりゆとりがあったので7Excelにしてみた。 スタイルシートを別ファイルにしてもいいならまだまだいけそうだ。 #!/usr/bin/perl @x='A'..'G';@y=1..10;$c='Shift_JIS';use CGI':all';@r=(0)x(@x+1);print header( -charset=>$c),start_html(-encoding=>$c,-lang=>'ja',-head=>style({-type=> 'text/css'},'table{border-colla
pse:collapse}input,th{width:50px}td{text-align: right}td,th{border:1px solid gray}')),start_form,table(Tr(map th($_),'',@x,''), (map{$i=$_;$s=0;Tr td[$_,(map{$p=param"$i$x[$_]";$s+=$p;$r[$_]+=$p;textfield "$i$x[$_]"}0..$#x),($r[-1]+=$s,$s)[1]]}@y),Tr td['',@r]),submit,end_form,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/368
369: 365 [sage] 2006/01/22(日) 16:39:32 ID:??? use Storable;$f='file';$s=8;$c='Shift_JIS';%p=qw/-1 〇 0 _ 1 ●/;@m=map([map 0 ,0..$s+2],0..$s+2);($x,$y)=map param($_)%($s+1),qw/x y/;$r=1;use CGI':all';sub f2{my($w,$y,$x,$c)=@_;$u=1;if(0>$r*$m[$y][$x]){$c++;$m[$y][$x]*=$u=f2($w,$y+$w ->[0],$x+$w->[1],$c)}elsif(0<$c&&0<$r*$m[$y][$x]){$u*=-1}$u}sub r{if($y&&$x&&! $m[$y][$x]){for(0..7){$i=$_*atan2 1,1;$l=[map int(sprintf'%f',$_*sqrt 2),sin$i, cos$i];$z++if 0>f2$l,$y+$l->[0],$x+$l->[1]}
if($z){$m[$y][$x]=$r;$r*=-1}}}$m[$s/ 2+(0<($_&2))][$s/2+(0<($_&1))]=$_%3?1:-1 for 0..3;($r,@m)=@{retrieve$f}if-s$f;r ;store[$r,@m],$f;print header(-charset=>$c),start_html(-encoding=>$c,-lang=> 'ja'),table(Tr[map{$i=$_;td[map a({-href=>"o.cgi?y=$i&x=$_"},$p{$m[$i][$_]}),1 ..$s]}1..$s]),$p{$r},end_html; 7オセロ? o.cgiで保存。 同じディレクトリに記録用ファイルの "file" を作成。 要 Storable.pm (Active Perl なら最初から入っているはず) リセットは手動で "file" を空にするw 7行に収まると思ったけ
ど見込みが甘かった。 http://medaka.5ch.net/test/read.cgi/php/1036141603/369
370: クロエ [sage] 2006/01/23(月) 02:25:04 ID:??? >>365 本当にありがとうございます。設置の仕方が分かりませんorz orz orz 今日6時間くらい、CGIについて解説してあるサイトを隅から隅まで見ましたが、収穫なしですwww ばかん ばかん 俺のばかん テキストエディタ?を使うんですか? http://medaka.5ch.net/test/read.cgi/php/1036141603/370
371: nobodyさん [sage] 2006/01/23(月) 03:02:02 ID:??? >>370 CGI設置について質問 【Part2】 http://pc8.2ch.net/test/read.cgi/php/1104624784/ だがどのみち使いこなせないと見た http://medaka.5ch.net/test/read.cgi/php/1036141603/371
372: クロエ [sage] 2006/01/23(月) 16:06:04 ID:??? >>365氏 本当にありがとうございます。 2chでこんな優しい人初めてだ。 勉強してきますた。 鯖にアップロードして、パーミッションを755にするだけでおKですか? http://medaka.5ch.net/test/read.cgi/php/1036141603/372
373: nobodyさん [sage] 2006/01/23(月) 16:30:08 ID:??? >>372 やってから聞いてる? http://medaka.5ch.net/test/read.cgi/php/1036141603/373
374: クロエ [sage] 2006/01/23(月) 18:13:14 ID:??? 372であってますか? http://medaka.5ch.net/test/read.cgi/php/1036141603/374
375: nobodyさん [sage] 2006/01/23(月) 18:19:38 ID:??? >>374 鯖によるから合ってるとか間違ってるとか言えん。 とにかくやって、エラーが出たらまた聞いてくれよ。 何かやるたびに聞かれたんじゃ迷惑だし、そもそもスレ違い。 http://medaka.5ch.net/test/read.cgi/php/1036141603/375
376: nobodyさん [sage] 2006/01/23(月) 19:29:44 ID:??? ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x$s+1],0..$s+1;map$m[$s /2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x]; if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i; f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset
'';print header,$p[$r], table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 昨日の続きで7オセロ! モジュール詳しくないからやらないけどモジュール*だけ*で構成なんてのも面白そうだ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/376
377: nobodyさん [sage] 2006/01/23(月) 19:31:49 ID:??? >>374 質問するならまず68,000円のサポートチケットを購入してからにしてくださいw http://medaka.5ch.net/test/read.cgi/php/1036141603/377
378: 376 [sage] 2006/01/23(月) 21:15:02 ID:??? ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x($s+1)],0..$s+1;map$m[ $s/2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x] ;if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i ;f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset '';pr
int header,$p[$r] ,table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 括弧はずしすぎでバグっていたので修正 ファイル名省略すると Lynx じゃ動かないね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/378
379: nobodyさん [sage] 2006/01/23(月) 21:31:39 ID:??? >>378 パスできない仕様はどうかと。 ファイルに記録するより Cookie にでも持たせた方がいいんじゃない? 参考に C の6行オセロを Perl に移植してみた。 オリジナルより数 byte 大きい。 ;-) #!/usr/local/bin/perl sub K{$m[$p]||do{for(@m[0..7]){$v=$p+$_;$v+=$_ while$m[$v]==9-$t;if($v-$p-$_&&$ m[$v]==$t&&($a=$s=$v=$p,$d)){{$m[$v]=$t;$m[$v+=$_]-$t&&redo}}}}}@m[40,41,49,50, 0..7]=(3,6,6,3,-10..-8,-1,1,8..10);$s=$t=3;@c=(qw(・ ○ ●),$/);while($s-1){$_% 9?K$p=$_
:($m[$_]=9),print$c[$m[$_]/3]for 9..81;$a?($a=$d=$p=9):$s?($s=0,print "pass\n"):++$s;K$p+=$t-6?(($p,$_)=<>=~/\d/g,$_*9):1until$a-9;$t=9-$t;$a=$d=0} http://medaka.5ch.net/test/read.cgi/php/1036141603/379
380: nobodyさん [sage] 2006/01/23(月) 22:25:29 ID:??? >>379 できませんよ>< http://medaka.5ch.net/test/read.cgi/php/1036141603/380
381: nobodyさん [sage] 2006/01/24(火) 00:41:03 ID:??? @x='A'..'G';@y=1..10;@s=qw/合計 平均/;use CGI':all';charset '';print header, style({type,'text/css'},'table{border-collapse:collapse}td,input{text-align: right;width:70px}td,th{border:1px solid gray}'),start_form,table(Tr[th(['',@x, @s]),(map{$i=$_;$s=0;$n=0;td[$_,(map{$p=param"$x[$_]$i";($t=$s)==($s+=$p)||$n++ ;($t=$r[$_])==($r[$_]+=$p)||$v[$_]++;textfield"$x[$_]$i"}0..$#x),($r[@x]+=$s,$s ,eval{$s/$n})[1,2]]}@y),td([$s[0],@r,'']),td[$s[1],map($v[$_]?sp
rintf('%.3f',( $c++,($t=$r[$_]/$v[$_]),$v+=$t)[1]):'',0..@x),eval{$v/$c}]]),submit,end_form; >>368 がいまいち糞コードになりきれていなかったので平均の計算も追加。おやすみ〜 ノシ http://medaka.5ch.net/test/read.cgi/php/1036141603/381
382: 378 [sage] 2006/01/24(火) 00:44:20 ID:??? >>379 >パスできない仕様はどうかと。 あまり細かいこと考えていないのでw 今日はもう寝ますがなんかすごそうなので明日動かしてみます。 http://medaka.5ch.net/test/read.cgi/php/1036141603/382
383: nobodyさん [sage] 2006/01/25(水) 22:05:38 ID:??? >>379 昨日見てみましたがこれをCGI化するのは行数的にちょっと無理じゃないですかねぇ。 でも面白かったです。 http://medaka.5ch.net/test/read.cgi/php/1036141603/383
384: nobodyさん [sage] 2006/01/25(水) 22:06:31 ID:??? 初回起動時からの累計と過去1週間の日別カウンタ。 設定を変えれば一日の時間別みたいな使い方もできる。 ($f,$l,$z)=qw{./counter.dat 7 5};use CGI':all';sub d{sprintf '%d年%02d月%02d日(%s)',1900+$_[5],1+$_[4],$_[3],(qw/日 月 火 水 木 金 土/)[$_[6 ]]}sub n{sprintf"%0${z}d回",shift}$n=time;$d=24*60*60;$p=$n-$n%$d;if(open F, "+<$f"){eval{flock F,2};($s,@d)=map[split/\s+/],<F>;$s->[0]||=$n;$s->[1]++;$p== $d[0][0]?$d[0][1]++:unshift@d,[$p,1];$n-=$d*
$l;seek F,0,0;printf F"%d\t%010d\n" ,@$_ for@d=($s,grep$n<$_->[0],splice@d,0,$l);truncate F,tell F;close F}charset '';print header,ul map{li b(n$_->[1]),d localtime$_->[0]}@d http://medaka.5ch.net/test/read.cgi/php/1036141603/384
385: nobodyさん [sage] 2006/01/25(水) 22:08:08 ID:??? 7CMS このスレで作った >>365 >>378 >>381 >>384 をモジュール化して一元管理する。 サードパーティー製品でもCGI.pmを使ったものなら大丈夫かも。 >>137 >>274 は一応動いた。 使い方は全部同じディレクトリに入れればいいだけだから。 use CGI':all';$d=param '*';@r=[$0=~/([^\\\/]+)$/,'START'];$p=$`;for$n(<*>){if($r [0][0]ne$n&&$n=~/\.cgi$/){$r='';chdir$p;open F,$n;read F,$c,-s F;tie*G=*STDOUT, 'main';eval"package C$`;$c";untie
*G;$r=~s/^.+?(\r?\n){2}//s;$r=~s/(<a\s.*?\?)(. *?>)/$1*=$d&$2/gisx;$r=~s!(?=</for)!hidden -name,'*',-value,$d!egi;push@r,[ $n,$r.$@]}}AUTOLOAD{ref(shift)?($r.=join'',@_):bless[]}charset '';put header, table Tr td{style=>'vertical-align:top;text-align:left;border:1px solid gray'}, [ul(li[map a({href,"?*=$_"},$d==$_?b($r[$_][0]):$r[$_][0]),0..$#r]),$r[$d][1]] http://medaka.5ch.net/test/read.cgi/php/1036141603/385
386: nobodyさん [age] 2006/01/26(木) 18:42:38 ID:??? hage http://medaka.5ch.net/test/read.cgi/php/1036141603/386
387: nobodyさん [sage] 2006/01/26(木) 21:31:03 ID:??? 7メル ($p,$t,$s)=('/usr/sbin/sendmail','mail@example.com','メールフォームから');use CGI':all';$$_=param $_ for qw/f m/;($f)=$f=~/^([\w.-]{1,64}\@[\w.-]{1,128})$/i; ($m=substr$m,0,2**16)=~tr/\0/ /;$m=~s/\r\n?/\n/g;$m=~s/^\.$/../gm;charset '';put header,startform,'あなたのメールアドレス',textfield(-name,'f'),br,'メッセージ', br,textarea(-name,'m',-rows,10,-cols,60),br,submit,endform;if($f&&$m&&open M, "| $p -t"){print(M join"\n",'Content-Transfer-Encodin
g: 8bit',"Reply-To: <$f>", "To: <$t>","Subject: $s",'',$m,'')&&put '管理者へ送信しました。';close M} http://medaka.5ch.net/test/read.cgi/php/1036141603/387
388: nobodyさん [sage] 2006/01/26(木) 21:31:54 ID:??? 7カレ @c=([('silver')x 7],[('red',('black')x 5,'blue')],'lavender');use CGI':all';$s= 24*60*60;@t=localtime($t=time);@r=td{align=>'right',bgcolor=>$c[2]},font{color =>$c[1][$t[6]]},b $t[3];@t1=localtime($i=$t-$s);while($t[4]==$t1[4]||$t1[6]<6){ unshift@r,td{align=>'right'},font{color=>$c[$t[4]==$t1[4]][$t1[6]]},$t1[3];@t1= localtime($i-=$s)}@t2=localtime($i=$t+$s);while($t[4]==$t2[4]||0<$t2[6]){push@r ,td{align=>'right'},font{co
lor=>$c[$t[4]==$t2[4]][$t2[6]]},$t2[3];@t2=localtime ($i+=$s)}charset '';put header,table Tr[map join('',@r[7*$_..7*($_+1)-1]),0..$#r] http://medaka.5ch.net/test/read.cgi/php/1036141603/388
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 64 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.010s