2011-04-01から1ヶ月間の記事一覧

PHP4ではメンバ変数の参照時にドルがついてても動く

php

pub = "php5"; $this->$pub = "php4"; var_dump($this->pub); var_dump($this->$pub);//dollar is here } } $base = new Test(); $base->callpro(); php4 displays php4 but php5 is not it,cause runtime error is called. php4 ignores dollar and ex…

perlでツタヤの店舗を取得

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; package Tshop; sub new{ my $class = shift; my $self = {}; bless $self,$class; } sub shopname{ my $self = shift; my $cont = shift; my @list = $cont =~ /<h2><a\s.*>.*<\/a><\/h2>/g; my $data </a\s.*></h2>…

なんでこれでリストが返るのか

js

たまに見る↓の書き方。 function get_list(){ console.log(Array.prototype.slice.call(arguments)); } get_list(1,2,3,4);//[1,2,3,4] これが何を意味してるのかわからない。。。 なんでprototypeプロパティを使ってsliceメソッドをわざと追加してるんだろ…

csvを読み込んで処理して書き出す

php

何かのときに書いたやつ。 何だったかは思い出せない。。。 csvname, "r"); while(!feof($handel)){ $this->csv = fgets($handel); $this->all .= $this->csv."!!!!!"; $str = explode(',',$…

カスタムフィールドでの改行方法

カスタムフィールドで、 テキスト(複数行)というフィールドを使う場合。 テキストエリアで改行しても、 出力時には改行が反映されない。

Movable Typeでの公開パス設定

MTでブログを作成するときの注意点。 公開設定でのパスとURLは、 htmlなどの拡張子を指定できない。

yield statement

# -*- coding:utf-8 -*- import urllib2 import re url = 'http://www.yahoo.co.jp' word = '社会的責任' def gene(n): s = 100 f = urllib2.urlopen(n) while 1: yield f.read(s) s+=100 def s(): v = gene(url) p = re.compile(word) print "if it dose no…

Mod_rewrite is able to rewrite url easily

I am examining now about to change dynamic url to static url.example,http://www.example.php?lunch=chinese&area=riverside ↓ http://www.example.php/chinese/riversideIt is called URL Regularization.If you wanna change url that and then you ha…

.forwardファイルを設置してパイプ処理をする

受信メールを別のメルアドに転送する目的で作成する.forwardファイル。 使い道は他にもあって、 何かの出力結果を何かに渡す、ということができる。 これを応用して、 メール受信後に指定したプログラムを実行できる。

awk script language for text operation

I was looking for fileAPI today. then found blog post that it is write about text operation using javascript and fileAPI. This page introduces how to rewrite contents(csv.data) in file. after complete to read contents, it would rewrote by …

perlからunixコマンドを実行する

こんな感じ。 use warnings; use strict; open(FI,"ls|")||die; my @s = <FI>; close(FI); my $arg = $ARGV[0]; foreach my $i(@s){ chop($i); if($i =~ /$arg/){ print "$i.\n"; } } ユーザーとかプロセス見たりとか、 システム管理に使えるかも。 でもrmとかし</fi>…

perlで配列の要素を取り出す方法

my $num = [1,2,3]; print($num->[0]); my @num2 = (1,2,3); print($num2[0]); 上が配列のリファレンス、下が配列。 これって何が違うんだ。 アドレスを取得してるかどうかしかわかんないけど、 ほかに違いがあるのかな。 どっちがいいんだろうねー。