Friday, November 02, 2012

funny

MYSQL REG EX

hello world
Regular Expression //it's fail because security reason. DELETE FROM xxxt_dxxxx.dxxxx WHERE nameid REGEXP '[a-Z]'; //it's passed SELECT * FROM xxxt_dxxxx.dxxxx WHERE nameid REGEXP '[a-Z]';

Thursday, November 01, 2012

MYSQL trigger


CREATE
    [DEFINER = { user | CURRENT_USER }]
    TRIGGER trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW trigger_body

trigger_name = customize name
trigger_time = after || before
trigger_event = insert || delete || update || loaddata || replace
trigger_body = BEGIN ..... END

[BEGIN ..... END] 
procedural SQL

Exaple:
--------------------------------------------------------------------------------
-- Trigger DDL Statements
DELIMITER $$

USE `development_deploy`$$
CREATE
DEFINER=`et`@`%`
TRIGGER `xxxment_deploy`.`item_delete2_deploy`
AFTER DELETE ON `xxxment_deploy`.`ixxx`
FOR EACH ROW
begin
 replace into deploy
 values('Wxx','Sxx',OLD.sxx,NOW(),'','','','','','') ;
end$$
-------------------------------------------------------------------------------

Tuesday, October 30, 2012

regexp regular expression
php 5:
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )

JS:

/\d{4}-\d{2}-\d{2}/.test('2007-01-25');     // true
'2007-01-25'.match(/\d{4}-\d{2}-\d{2}/);    // true

DHTMLX 在使用treegrid的方式宣告出grid表格會造成一些原有的onclick事件失效,例如checkbox在裡面他是用自己的方式寫,事用onclick事件去驅動BOX改變,在onclick事件失效後,checkbox變成只能固定不能更改。
CSS special use

shadow

      -webkit-box-shadow: 2px 2px 3px #222222;
      -moz-box-shadow: 2px 2px 3px #222222;
      box-shadow: 2px 2px 3px #222222;

radius
/* support Safari, Chrome */
-webkit-border-radius: 5px;
/* support firefox */
-moz-border-radius: 5px;
border-radius: 5px;

http://www.cbflabs.com/book/cce/cce.htm

Monday, October 22, 2012


Q1.
1.1me = $('#win_content_copy').find('#categoryname');
alert(me.value).text();

[ans:]its worng. text() alert-method response undefined.

1.2alert(me.text());
[ans:]its working

1.3alert(me.val());
[ans:]when we use input marksigned ,have to

Q2.time control

//sleep(4000);
//setInterval("categoryname_keydown();", 3000);
//event.timeStamp;
//setTimeout("alert ('called from setTimeout()');",4000);
Q3.when you clone a DOM element

window_content_copy = $('#window_content').clone();
window_content_copy.attr('id','win_content_copy');
window_content_copy.appendTo('#body');

is html inside script syntax
onclick='function(this)'  (<---wrong)
onclick='function($(this))'   (<---right)



Thursday, October 18, 2012


PDO使用時要注意
使用prepare
在execute若有LIKE條件時
%必須放到excute參數內
放在原始$sql會出錯

 $sql = "SELECT id,full_xxxx_name
                       FROM xxxx
                       WHERE full_xxxx_name LIKE :xxxx_name;";

        $statement = $connection->prepare($sql);

        $statement->execute(array(':xxxx_name' => $inputname."%"));

取消表單輸入時的自動完成


<form>
    <input type="password" name="Password" autocomplete="off">
</form>


or

<form autocomplete="off">
    <input type="password" name="Password" >
</form>


//JavaScript
//HTML
//function onchange() test

<input type="text" onkeydown="myFunction()">


Tuesday, October 16, 2012


black ground:

  <div id="mask" style="filter: Alpha(opacity=30); -moz-opacity: 0.3; -khtml-opacity: 0.3;
  opacity: 0.3; background-color: #000; width: 100%; height: 100%; z-index: 5px;
  position: absolute; left: 0; top: 0; display: none; overflow: hidden;">
  </div>

jqurey
 $('#blackmask').show("slow") ;


Wednesday, July 18, 2012

GRAFIC libraries

2012/07/19
做一個匯入3D模型之簡易動畫。

GRAFIC is a set of libraries of C and C++ callable routines for programming interactive
graphics applications on workstations and personal computers. Versions of the GRAFIC library are
available for workstations running X Windows™, Apple Macintosh™ PowerPC personal
computers, and Intel compatible personal computers running Microsoft Windows 95, 98 and NT.
Except for minor differences, the same source code will function as expected for these platforms
simply by re-compiling and linking with the appropriate GRAFIC library. The GRAFIC package
was developed to provide basic, cross-platform, multi-language support for programming windowbased
raster graphics applications without the complexities and language dependencies typical of
window graphics systems. The libraries can be accessed at URL www.cadlab.ecn.purdue.edu.
The next sections introduce the basic concepts for GRAFIC programming, followed by
descriptions of the routines. Information specific to programming using the Windows and
Macintosh versions of GRAFIC is provided in the closing sections.

1.
http://hungming.ct.ntust.edu.tw/
GRAFIC 是用來控制視窗,
利用GLUT需要設定步驟,
GLUT現在已經改為freeglut因此以前教學中glut32.lib全部要改為freeglut.lib,一些相關的連結檔案也要注意。

2.
已經可以跑出畫面,現在開始找功能強大以及可以匯入3DS模組的函式庫,
http://code.google.com/p/lib3ds/
可惜lib3DS說明文件太少,本身也未附帶函式之說明文件。

3.
嘗試使用開放源碼之3D引擎ORGE作為匯入3DS及建置場景之工具。
參考此篇網路文章所得ORGE之訊息
http://www.programmer-club.com/showSameTitleN/game/3494.html
以下ORGE首頁
http://www.ogre3d.org/
一篇中文教學網誌
http://chia0418.wordpress.com/2009/03/11/%E8%88%87ogre%E5%85%B1%E8%88%9E%EF%BC%9A%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%8C%E5%AE%89%E8%A3%9D-ogre-161-%E4%BD%BF%E7%94%A8-vc-20052008/

4.
授權分為BSD、MIT、GNU、GPL等等,ORGE是較為寬鬆的MIT license可以用

5.
匯入3DS失敗了,改成匯入OBJ檔案,先將3DS轉檔成OBJ
WINGS3D
匯入方法有以下教學
http://www.programmer-club.com/showsametitlen/opengl/1144.html
http://www.gamelife.idv.tw/viewtopic.php?t=211
http://lawlietmoon.pixnet.net/blog/post/27177462-%E8%AE%80obj%E6%AA%94(opengl,visual-c%2B%2B6.0)
貼出匯入範例程式檔如下

/////////////////////////
// glutTest08.cpp
//
// Created by Gary Ho, ma_hty@hotmail.com, 2005
//


#include <stdio.h>
#include <math.h>

#include "glut.h"

#include "glm.h"

#define G_PI 3.14159265358979323846f

void prepare_lighting();
void display();
void keyboard(unsigned char key, int x, int y);

float theta, phi;

GLuint list_id;

void main()
{
  theta = G_PI/2;
  phi = -G_PI/2;

  glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
  glutInitWindowSize( 640, 640 );
  glutCreateWindow( "glutTest08" );

  glutDisplayFunc(display);
  glutKeyboardFunc( keyboard );

  {
    GLMmodel *glm_model;
     glm_model= glmReadOBJ( "castle.obj" );
     glmUnitize( glm_model );
     glmScale( glm_model, .1 );
     glmFacetNormals( glm_model );
     glmVertexNormals( glm_model, 90 );

     list_id = glmList( glm_model, GLM_MATERIAL | GLM_SMOOTH );

     glmDelete( glm_model );
  }

  prepare_lighting();

  glutMainLoop();
}

void keyboard(unsigned char key, int x, int y)
{
  switch( key )
  {
    case 'w':
     theta -= .05;
     prepare_lighting();
     glutPostRedisplay();
    break;

    case 's':
     theta += .05;
     prepare_lighting();
     glutPostRedisplay();
    break;

    case 'a':
     phi -= .05;
     prepare_lighting();
     glutPostRedisplay();
    break;

    case 'd':
     phi += .05;
     prepare_lighting();
     glutPostRedisplay();
    break;
  };
}


void display()
{
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluPerspective( 20, 1, 0.1, 10 );

    glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     gluLookAt(
     0,0,1,
     0,0,0,
     0,1,0 );

    glEnable( GL_LIGHTING );
    glEnable( GL_DEPTH_TEST );
 
    glCallList( list_id );

  glutSwapBuffers();
}

void prepare_lighting()
{
  theta = fmodf( theta, 2*G_PI );
  phi = fmodf( phi, 2*G_PI );

  float light_diffuse[4] = {1.0, 1.0, 1.0, 1.0};
  float mat_diffuse[4] = {1.0, 1.0, 1.0, 1.0};
  float light_position[4] = { sinf(theta) * cosf(phi), cosf(theta), -sinf(theta) * sinf(phi), 0 };

  //glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  glEnable( GL_LIGHT0 );
}

6.弳度或弧度




單位弧度定義為圓弧長度等於半徑時的圓心角

7.發現一個很容易查GLUT函式的網站
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318369(v=vs.85).aspx

8.