Saturday, September 05, 2009

Friday, August 21, 2009

Install PHP under Apache and Vista

http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/


I initially tried the msi installer for PHP 5. Unfortunately, it installs only PHP under CGI, which although it has some performance and security issues, might be ok for a quick and dirty development environment.

But the installer is badly broken. You’ll get an error something like

PHP Fatal error:  require_once()[function.require]: Failed opening required 'SAM/php_sam.php' (include_path='.;C:php5pear') in sam_factory on line 1

After fighting this for a couple of hours, I ended up installing manually anyway. I used this procedure to get PHP 5 running under Vista:

  1. Install the Apache webserver.
  2. Get the current version of PHP 5 fromhttp://www.php.net/downloads.php#v5. (It’s 5.2.3 at this time). Get both the zip file and the PECL zip file (which includes extensions).
  3. Uninstall any previous installations of PHP 5 (Start > Control Panel > Programs and Features). You may have to reboot your machine.
  4. Disconnect from the Internet. Turn off your firewall. Turn off your virus checker.
  5. Turn off User Account Control (UAC).
  6. Get an administrator prompt by going to All Programs > Accessories. Right-Click “Command Prompt” and choose “Run as Administrator”
  7. Use the command prompt to manually remove directories containing previous PHP installations (like C:\Program Files\PHP…)
  8. Go to the directory where you’ve downloaded the PHP5 and PECL zipfiles. Extract the PHP zipfile. Rename the extracted php directory (which has a name something like php-5.2.3-Win32) to c:\php. Extract the PECL zipfile into c:\php\ext.
  9. In the command prompt, type:
    cd c:\php mkdir upload mkdir session copy php.ini-recommended php.ini
  10. Open php.ini in Notepad:
    1. There are many variables… the following are important. Notice that starting a line with a semicolon in the ini file comments it out.
      upload_tmp_dir="C:\php\upload" session.save_path="C:\php\session" cgi.force_redirect=0 extension_dir ="C:\php\ext" display_errors = Off log_errors = On error_log = "C:\php\error_log"
    2. You might want to look at upload_max_filesize. I’ve set mine to 16M. I also set post_max_size = 16M.
    3. Enable the extensions you need by deleting the semicolon at the beginning of the line. These will depend on your application… I’m going to be using MySQL (which I’ve already installed) and Moodle (which I’ll install later). My list looks like the following:
      extension=php_bz2.dll extension=php_curl.dll extension=php_dba.dll extension=php_dbase.dll ;extension=php_exif.dll extension=php_fdf.dll extension=php_gd2.dll extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_ifx.dll ;extension=php_imap.dll ;extension=php_interbase.dll extension=php_ldap.dll extension=php_mbstring.dll extension=php_mcrypt.dll extension=php_mhash.dll extension=php_mime_magic.dll ;extension=php_ming.dll ;extension=php_msql.dll ;extension=php_mssql.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll extension=php_openssl.dll ;extension=php_pdo.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll ;extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_oci8.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll ;extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_pspell.dll extension=php_shmop.dll ;extension=php_snmp.dll extension=php_soap.dll extension=php_sockets.dll ;extension=php_sqlite.dll ;extension=php_sybase_ct.dll extension=php_tidy.dll extension=php_xmlrpc.dll extension=php_xsl.dll extension=php_zip.dll
  11. Right-Click on Start > Computer. Choose “Properties”, then “Advanced”. Click on “Environment Variables”. Click on PATH, then Edit… and add “;C:\php;c:\php\ext” (without quotes) to the end of the variable.
  12. Open your Apache configuration file (All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Edit the Apache httpd.conf Configuration File). Add the following lines:
    LoadModule php5_module "C:\php\php5apache2_2.dll" AddType application/x-httpd-php .php AcceptPathInfo on PHPIniDir "C:\php"

    Look for the DirectoryIndex line. Add ” index.php” (no quotes) to the end of that line.

    Save the file.

  13. Create a file named test.php in your Apache htdocs directory, containing this text:
  14. Reboot your machine.
  15. Browse to http://localhost/test.php. You should see tabulated information about your working PHP installation.

Tuesday, August 04, 2009

from chrome to os

It's like a long time ago, I feel like the browser is another os, espeically when you use it in full screen mode. It's a network os but without dedicated compiling language. Ok, I admit that javascript is not standarded in fact and it's not like elegant as my favorate Python; due to the security problem, it has no access to the local files; it's in single process. But it do lead to some wonder land.

People always have dreams when they are young while they don't know how to achieve the goal, achieve it in a proper way or do it in fashion. From ages ago, people either want to post something and don't care what others say or communicate through dedicated channel that all people have one but have their own. Slim client, net computer, grid, you figure the name that people build to express the enthusiastic on distributed work place and one data and processing center. Nowadays, one data and processing center has became the one central access point and clould is behind the point. Millions transactions are running on data center. But people still have to use simple network application around text.

There are something missing and some people will patch the problem, while some problem is hard to solve as far as I can see. To have fully functional web application, a platform, something like an OS is necessary. The browser is better than a OS in the sense that it has the function over user interface while OS (actually, I mean old-fashioned batch system) don't; browser has instancely useable standarded language, Javascript, while OS don't.

But the horn is still sounding on the battle field between the browser and OS. Browser don't have control over resource, it runs on OS; An extension to this problem is that browser cannot get more resource if it's single processed. Another externsion to the problem is that browser will do the same task with less speed than OS, so to win, browser must be fast. In the sense of human interface, browser is fine at 2D interaction, especially around forms and text, which have rich structure; OS can do great job in 3D animation however.

So, peopel in action. Google Chrome has take its lead. The browser has a Javascript interpretor that only store difference between objects, which makes it fast. A window is a process, which can eat up more resource. And it will step over OS by the Chrome OS, which is chrome + Linux. Ha, another slim client in this decade. Will we see 3D in browser as well? Not recently, I believe. There is some 3D extension for browser out there. But 3D function is a plus for the network gigant. I believe 99% business over the network is in 2D form. And that's their target.

Finally, there is one large problem about the browser is that all the Javascript code can be seen by the final user. The saving is to put all business logic behind on the servers. But it opposes the purpose to use as much as resource on the client side. To find aid from copy right law is out of options. Maybe one day browser will cover the source code but always gives the user the right to choose to run the application or not. At that time, everything will come back to as it today.

Friday, July 24, 2009

dom event

in dom level2 event:
mouse event is defined.

mouse event:
click
mousedown
mouseup
mouseover
mousemove
mouseout

context info:
altKey
button
clientX
clientY
ctrlKey
metaKey
relatedTarget
screenX
screenY
shiftKey

keyboard event is in dom level3 events

make div like a input text field.


Wednesday, July 22, 2009

javascript term

http://www.webessence.nl/projects/terminal/#help
http://www.masswerk.at/jsuix/
http://cb.vu/

Tuesday, July 21, 2009

huge treasure

http://www.51cnnet.com

Korean is great.

人老了

http://www.youtube.com/watch?v=sE-r_uLmp_c&feature=player_embedded

CSS Properties To JavaScript Reference Conversion

document.getElementById(div_id).style.JS_property_reference = "new_CSS_property_value";

Friday, July 17, 2009

Screen Capture and Save as an Image

Suddenly came out this problem. The following is a search result.

The code is from

http://www.c-sharpcorner.com/UploadFile/perrylee/ScreenCapture11142005234547PM/ScreenCapture.aspx


/* Author: Perry Lee
* Submission: Capture Screen (Add Screenshot Capability to Programs)
* Date of Submission: 12/29/03
*/

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
// If you have any questions regarding functions (methods) imported from
// GDI32.dll and User32.dll refer to 'msdn.microsoft.com'
class GDI32
{
[DllImport("GDI32.dll")]
public static extern bool BitBlt(int hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,int hdcSrc,intnXSrc,int nYSrc,int dwRop);
[DllImport("GDI32.dll")]
public static extern int CreateCompatibleBitmap(int hdc,int nWidth, int nHeight);[DllImport("GDI32.dll")]
public static extern int CreateCompatibleDC(int hdc);
[DllImport("GDI32.dll")]
public static extern bool DeleteDC(int hdc);
[DllImport("GDI32.dll")]
public static extern bool DeleteObject(int hObject);
[DllImport("GDI32.dll")]
public static extern int GetDeviceCaps(int hdc,int nIndex);
[DllImport("GDI32.dll")]
public static extern int SelectObject(int hdc,int hgdiobj);
class User32
{
[DllImport("User32.dll")]
public static extern int GetDesktopWindow();
[DllImport("User32.dll")]
public static extern int GetWindowDC(int hWnd);
[DllImport("User32.dll")]
public static extern int ReleaseDC(int hWnd,int hDC);
}
class Example
{
public void CaptureScreen(string fileName,ImageFormat imageFormat)
{
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),
hdcDest = GDI32.CreateCompatibleDC(hdcSrc),
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,
GDI32.GetDeviceCaps(hdcSrc,8),GDI32.GetDeviceCaps(hdcSrc,10)); GDI32.SelectObject(hdcDest,hBitmap);
GDI32.BitBlt(hdcDest,0,0,GDI32.GetDeviceCaps(hdcSrc,8),
GDI32.GetDeviceCaps(hdcSrc,10),hdcSrc,0,0,0x00CC0020);
SaveImageAs(hBitmap,fileName,imageFormat);
Cleanup(hBitmap,hdcSrc,hdcDest);
}
private void Cleanup(int hBitmap,int hdcSrc,int hdcDest)
{
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);
GDI32.DeleteDC(hdcDest);
GDI32.DeleteObject(hBitmap);
}
private void SaveImageAs(int hBitmap,string fileName,ImageFormat imageFormat)
{
Bitmap image =
new Bitmap(Image.FromHbitmap(new IntPtr(hBitmap)),
Image.FromHbitmap(new IntPtr(hBitmap)).Width,
Image.FromHbitmap(new IntPtr(hBitmap)).Height);
image.Save(fileName,imageFormat);
}
}

Explanation of methods:

public void CaptureScreen(string fileName,ImageFormat imageFormat)
{
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()), // Get a handle to the desktop window
hdcDest = GDI32.CreateCompatibleDC(hdcSrc), // Create a memory device context
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, // Create a bitmap and place it in the memory DC
GDI32.GetDeviceCaps(hdcSrc,8),GDI32.GetDeviceCaps(hdcSrc,10));
// GDI32.GetDeviceCaps(hdcSrc,8) returns the width of the desktop window
// GDI32.GetDeviceCaps(hdcSrc,10) returns the height of the desktop window
GDI32.SelectObject(hdcDest,hBitmap); // Required to create a color bitmap
GDI32.BitBlt(hdcDest,0,0,GDI32.GetDeviceCaps(hdcSrc,8), // Copy the on-screen image into the memory DC
GDI32.GetDeviceCaps(hdcSrc,10),hdcSrc,0,0,0x00CC0020);
SaveImageAs(hBitmap,fileName,imageFormat); // Save the screen-capture to the specified file using the designated image format
Cleanup(hBitmap,hdcSrc,hdcDest); // Free system resources
}
private void Cleanup(int hBitmap,int hdcSrc,int hdcDest)
{
// Release the device context resources back to the system
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);
GDI32.DeleteDC(hdcDest);
GDI32.DeleteObject(hBitmap);
}
private void SaveImageAs(int hBitmap,string fileName,ImageFormat imageFormat)
{
// Create a bitmap from the Windows handle
Bitmap image = new Bitmap(Image.FromHbitmap(new IntPtr(hBitmap)),
Image.FromHbitmap(new IntPtr(hBitmap)).Width,
Image.FromHbitmap(new IntPtr(hBitmap)).Height);
image.Save(fileName,imageFormat);
}

Sunday, July 12, 2009

Meschach: Matrix computations in C

Since the I always suspect the speed of matlab. Today I start to look for the c/c++ liberary for matrix manipulation. And I find Meschach.

Saturday, June 27, 2009

ri air show

Today, I drived 1 and half hour to north kingstown, RI to get to the air show. Not mention, on the ground are all the main aircraft used in US military. 3 Carrier, 2 fighters. There are several aircraft in air. chopper, c130, f18(blue bird), f22, f15, f16, A10. At the beginning it's boring. Then a operation simulation is performed and things get interesting. Finally the routine air show, the NAVY F18 Blue Bird is out of their van and that's the ultimate cool.

Monday, June 15, 2009

福建最游处

玉华洞:一是藏禾洞,二是雷公洞,三是果子洞,四是黄泥,五是溪源,六是白云。走2小时。

Sunday, June 14, 2009

vim tricks


  1. :set filetype=python, for python file and we can figure out the general form.
  2. How to insert tab for Makefile when you have expandtab on, use ctrl-V tab in insert mode.

Sunday, June 07, 2009

two dimensional input in mathematica

  1. move complementary position by pressing Ctrl+5
  2. Type fraction by Ctrl+/
  3. Type superscript by Ctrl+6
  4. Type subscript by Ctrl+-
  5. Type overscript by Ctrl+7
  6. Type underscript by Ctrl+=
  7. Type square root by Ctrl+2
  8. Type radicals by square root and moving complementary position.

Friday, May 08, 2009

old basketball

During the supper time, I eat while watch a online video which is 1998 NBA all star. There a M. Jordan, Kobe Bryant and more. The game is hosted by Han who gives a lot of nickname to player. And it gives a lot of fun to the game.

When I watch this game I realize I was born in a great time. Kobe may have the strong body and great skill as Jordan. Jordan's move is more attractive and curve is higher, air time is longer and audient as me more like it. And when shooting, Jordan is more relax, he doesn't use his leg much in the air. 

Anyway, Jordan is the king and 90' NBA is great.

northeastern really need a great dinner place

again it's the summer time. Food court all close early these time. When I came back from au bon pain with steak rice bowl, a man stopped me and asked me the question which I asked myself several times, "Is there a place to eat on campus?". And the word "is" starts from ten steps away. No doubt that both men were hungry. I came up close and said "along that direction, you will get to Huntington Ave, where serveral place you can eat". 

Notheastern University has great built view, especially thinking the campus is in the city and the thinker from the over crowded eastern. But food do rely on the avenue. Wish one day I can see there is a whole flour restaurant here.

Thursday, May 07, 2009

关于F股票

今天总结一下这段时间关注的F股票。自从在新闻中间看见了美国汽车行业的问题就觉得这是股价发生巨大变化的时候。如果勉强的从实际的观察看,三大车厂中ford is like honda, gm is like toyota and chrysler is like nissan. gm has many brand and long product line. ford has less brand and shorter product line while chrylser has small amount of brands with long product line from compact car to super sport car. And from my rental experince with these car, the defect from chrylser can be felt anyway. And shorter product line helps surviving since longer product line appears with the growing economy. Once crysis touchs bottom, price will again go up. So I check ford regularly and find the following number:
March 06, 2009, $1.70, cap: 35.14m
and today
May 04, 2009, $5.87, cap: 58.16m
That's a fast grow for me. But I think the growing will slow down. Since the future for Chrysler and GM is settle down and I don't see any uncertainty in auto industry.

As I see from this case, I should remember some tips. 
In America, news do lead clue to the uncertainty in the market where chance hides. 
In oligarch industry, if this is the correct word, one fails mean other one rises.
One on the edge, meaning either with low price or on the news or dominate power should be on the check list.

Wednesday, May 06, 2009

突然想到中国的房地产

看这新闻突然想到了中国的房地产的事情。土地归属权的改变是市场化和私有化的必然过程。但如果仍然以社会主义中的国有土地为出发点,发现政府果然不再是以前共产党领导的政府。以前土地是国有或是集体所有的,人们在其上生活,工作。有一天政府说要盘活土地,于是土地被政府拍卖了,当然政府留了一手,说你只有使用权。于是在土地上生活工作的人们不再拥有这片土地,同时也没有得到失去这片土地的补偿。也许从第一天开始土地就不属于生活和工作在其上的人们。