Archives

You are currently viewing archive for May 2007
Category: Web dev
Posted by: hajime osako
//カラム内の文字を置換する
UPDATE tableA SET colA = replace(colA, '_strA', '_strB') WHERE colA LIKE '%_strA'; 

//特定のユーザの権限を確認する
SHOW GRANTS FOR 'user_name'@'address';

//特定のユーザからすべての権限を取り除く
REVOKE ALL PRIVILEGES ON `db_name`.`table_name` FROM 'user_name'@'address'; 

//特定のユーザにすべてまたは一部の権限を与える
GRANT ALL ON db_name.* TO 'user_name'@'address';
GRANT SELECT, INSERT, REFERENCES ON `db_name`.`table_name` TO 'user_name'@'address';

//権限を変えた後は
FLUSH PRIVILEGES;

//カラムを追加する
ALTER TABLE `table_name` ADD COLUMN `column_name` data_type default_value AFTER `after_column_name` ;
Category: Linux tips
Posted by: hajime osako
FreeTDS.org
FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.
Category: Z. etc
Posted by: hajime osako
なぜかリダイレクトするページがキャッシュされて、exit()が使用されていない場合、Internet Explorerのアドレスバーにリダイレクトを実行するURLが表示されたままになる。

直すには、
   header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
   header("Location: http://www.osakos.com/");
   exit();
Category: Web dev
Posted by: hajime osako
プロトタイプ(prototype)によるJavaScriptのオブジェクト指向
すなわち、あるオブジェクトがプロパティを評価された時、自分自身がそのプロパティを持っていなければ、暗黙の参照をたどって、その先のオブジェクトのプロパティを評価します。
参照がJavascriptは変。
最初、インスタンスは暗黙で参照になるのに、できたインスタンスの値を変更すると、参照にならない。

サンプル:
// Constructor (何もできない?)
var Validator = new Function();

// Declare Properties
Validator.prototype.regExpPatterns = new Object(); // *1
Validator.prototype.errMsgs = new Object();

// Declare Methods
Validator.prototype.validate = function(elm, ptn, msg)
{
   var _parent = new Validator(); // *2
   var _str = null;

   if(!ptn && elm.name && _parent.regExpPatterns[elm.name])
   {
      ptn = _parent.regExpPatterns[elm.name];
   }
   
   ...
}

Validator.prototype.setAlertErr = function(bool)
{
   Validator.prototype.alertErr = bool;   //*3
}

Validator.prototype.getAlertErr = function()  // getterは意味がない?
{
   var _parent = new Validator();  //*2
   return _parent.alertErr;
}

//*** How to use ***
var myValidator = new Validator(); // インスタンスを作成
myValidator.regExpPatterns["account_id"] = "[0-9]";   //プロパティを変更
myValidator.setAlertErr(false);   //セッターを使用
*1: プロパティやメソッドを追加するのに、prototypeを直接使うのはECMAScriptに準拠しない、がIEやFirefoxでは動く。ネームスペースを考えると、このやり方のほうがベターに思う。
*2: メソッド内で、親クラスなどのメソッドを使いたいときはインスタンスを作成しないとうまく動かない。
*3: しかし、メソッドからプロパティを変更するときはprototype。
Category: Web dev
Posted by: hajime osako
Selenium IDE: Selenium IDE
Firefoxのプラグイン(extension)として動きます。
Category: Web dev
Posted by: hajime osako
phpDocumentor Manual
class myclass {
    /**
     * variable description
     * @access private
     * @var integer|string
     * @link http://www.example.com Example link
     * @see myclass()
     * @uses testing, anotherconstant
     */
    var $firstvar = 6;
Category: Web dev
Posted by: hajime osako
Category: Web dev
Posted by: hajime osako
EPFプラグインでらくらく開発プロセス管理!(入門編) (1/2) - @IT

正規表現のテストが簡単にできるツール
名前: QuickREx
URL: http://www.bastian-bergerhoff.com/eclipse/features/

Spell checker
GNU Aspell dictionaries
Category: Web dev
Posted by: hajime osako
Category: Web dev
Posted by: hajime osako
function autoLink($str){
   $prefix = "([[:space:]]|\(|^)";
   $suffix = "([[:space:]]|\))";

   $linkPtns = array();
   $linkPtns[] = array("([-a-z0-9_.]+@[-a-z0-9_.]+)",
                     "\\1\\2\\3");
   $linkPtns[] = array("(http://|https://|ftp://)([[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)",
                     "\\1\\2\\3\\4");
   $linkPtns[] = array("(www\.[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)",
                     "\\1\\2\\3");
   $linkPtns[] = array("([[:alnum:]/_-]+)(\.jpg|\.gif|\.png)",
                     "\\1\\4");

   foreach($linkPtns as $patterns)
   {
       $str = eregi_replace($prefix.$patterns[0].$suffix, $patterns[1], $str);
   }

   return $str;
}

//不正な記号をHTML特殊文字(html entity)に変換する
function allHtmlentities($str)
{
   // somehow can't convert em dash and en dash...
   $new_string = preg_replace(
      '/([^\x09\x0A\x0D\x20-\x7F]|[\x3A-\x40])/e',
      '"&#".ord("$0").";"',
      $str);
	return $new_string;
}
Category: Z. links
Posted by: hajime osako
UNLOCKER 1.8.5 BY CEDRICK
消せないファイルを強制的に消せるようにする。
Category: Web dev
Posted by: hajime osako
Category: Web dev
Posted by: hajime osako
C:\Program Files\Microsoft SQL Server\MSSQL\Upgrade\scptxfr /s [Server address] /d [Database name] /P [sa password] /F "[Output file path]" /q /H /Y /H
Category: Z. links
Posted by: hajime osako

05/10: HTMLAssistant

Category: Web dev
Posted by: hajime osako
フリーソフト置き場

HTMLAssistantは、常駐して入力時にHTMLの保管をするツールです。英語環境だと文字化けします。
Category: Web dev
Posted by: hajime osako
Greasespot

Greasemonkey is a Firefox extension that allows you to customize the way webpages look and function.

Hundreds of scripts are already available for free. And if you're the tinkerer sort, you can also write your own.
Category: Web dev
Posted by: hajime osako
IEでgetElementsByNameはA, APPLET, BUTTON, FORM, FRAME, IFRAME, IMG, INPUT, OBJECT, MAP, META, PARAM, TEXTAREA, SELECTでしか動作しない。
そこで下記のスクリプトを代用する。
また、onChangeはradioボタンではうまく動かない。

getElementsBy*()
getElementsByClassName Deluxe Edition | Muffin Research Labs by Stuart Colville
function getElementsByClassName(strClass, strTag, objContElm)
{
   strTag = strTag || "*";
   objContElm = objContElm || document;
   var objColl = objContElm.getElementsByTagName(strTag);
   if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
   var arr = new Array();
   var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
   var arrClass = strClass.split(delim);
   for (var i = 0, j = objColl.length; i < j; i++)
   {
      var arrObjClass = objColl[i].className.split(' ');
      if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
      var c = 0;
      comparisonLoop:
      for (var k = 0, l = arrObjClass.length; k < l; k++)
      {
         for (var m = 0, n = arrClass.length; m < n; m++)
         {
            if (arrClass[m] == arrObjClass[k]) c++;
            if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length))
            {
               arr.push(objColl[i]);
               break comparisonLoop;
            }
         }
      }
   }
   return arr;
}
追記:classが指定してあるエレメントのスタイル(背景など)を、Javascriptで変更しようとしてもうまくいかないときがある。その場合は別のクラスで書き換えるとうまくいく。
<input type="text" class="bgRed" id="test" />
×   $("test").style.backgroundColor="red";
○   $("test").className = "newClassName";
* $ = document.getElementById
Category: Web dev
Posted by: hajime osako
pdt / Zend.com

http://downloads.zend.com/pdt <--- for Remote Site

Eclipse EMF

Eclipse GEF
Eclipse VE
Eclipse WTP (WST)
Callisto経由でインストールしたほうが楽。
Category: Z. etc
Posted by: hajime osako
Crispy JavaScript Cookies: JavaScript Cookie Functions - Doc JavaScript
function setCookie(name, value, expires, path, domain, secure) {
   if(!expires)
   {
      expires = new Date();
      var yy = expires.getYear();
      if (yy < 2000) yy += 1900;
      expires.setYear(yy+1);
   }

   if(value.length <= 4000)
   {
      var curCookie = name + "=" + escape(value) +
         ((expires) ? "; expires=" + expires.toGMTString() : "") +
         ((path) ? "; path=" + path : "") +
         ((domain) ? "; domain=" + domain : "") +
         ((secure) ? "; secure" : "");

      document.cookie = curCookie;
   }
}
Category: Web dev
Posted by: hajime osako
【PHPウォッチ】第11回 PHP4/PHP5にバグ修正版,高機能デバッグ・ツールXdebug登場:ITpro

zend_extension_ts=C:\php5\ext\php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000