サブディレクトリを含めて一気にファイル数を調べたいとき
シェルで直接以下をたたく
1 |
for x in * ; do echo $x ; ls -1UR $x | wc -l ; done |
フォルダ名とファイル数を教えてくれます。
在宅プログラマーの備忘録として2005年に始めたブログです。
サブディレクトリを含めて一気にファイル数を調べたいとき
シェルで直接以下をたたく
1 |
for x in * ; do echo $x ; ls -1UR $x | wc -l ; done |
フォルダ名とファイル数を教えてくれます。
数字を入力されたら即計算するようなフォームで使用
1 2 3 4 5 6 7 8 9 10 11 |
// トリム & 全角を半角に $('input:text').each(function(key, val) { var str = $(this).val(); str = str.trim(); var str2 = str.replace(/[A-Za-z0-9]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) - 65248); }); $(this).val(str2); }); |
XMLの需要は、まだある。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// 連想配列をXMLに変換する function array_to_xml($array, &$xml) { foreach($array as $key => $value) { if(is_array($value)) { if(!is_numeric($key)){ $subnode = $xml->addChild("$key"); $this->array_to_xml($value, $subnode); } else { $this->array_to_xml($value, $xml); } } else { $xml->addAttribute("$key","$value"); } } } |
クリックジャッキング対策
1 2 3 |
// クリックジャッキング対策 header("X-Frame-Options: SAMEORIGIN"); header("Content-Security-Policy: frame-ancestors 'self'"); |
httpsのみCookieを許可する
1 2 |
// httpsのみ許可する ini_set('session.cookie_secure', 1); |