Saturday, September 05, 2009
Sunday, August 30, 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:
- Install the Apache webserver.
- 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).
- Uninstall any previous installations of PHP 5 (Start > Control Panel > Programs and Features). You may have to reboot your machine.
- Disconnect from the Internet. Turn off your firewall. Turn off your virus checker.
- Turn off User Account Control (UAC).
- Get an administrator prompt by going to All Programs > Accessories. Right-Click “Command Prompt” and choose “Run as Administrator”
- Use the command prompt to manually remove directories containing previous PHP installations (like C:\Program Files\PHP…)
- 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.
- In the command prompt, type:
cd c:\php mkdir upload mkdir session copy php.ini-recommended php.ini
- Open php.ini in Notepad:
- 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"
- You might want to look at upload_max_filesize. I’ve set mine to 16M. I also set post_max_size = 16M.
- 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
- There are many variables… the following are important. Notice that starting a line with a semicolon in the ini file comments it out.
- 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.
- 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.
- Create a file named test.php in your Apache htdocs directory, containing this text:
- Reboot your machine.
- Browse to http://localhost/test.php. You should see tabulated information about your working PHP installation.
Tuesday, August 04, 2009
from chrome to os
Friday, July 24, 2009
dom 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
Wednesday, July 22, 2009
javascript term
http://www.masswerk.at/jsuix/
http://cb.vu/
Tuesday, July 21, 2009
CSS Properties To JavaScript Reference Conversion
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
Saturday, June 27, 2009
ri air show
Monday, June 15, 2009
Sunday, June 14, 2009
vim tricks
- :set filetype=python, for python file and we can figure out the general form.
- 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
- move complementary position by pressing Ctrl+5
- Type fraction by Ctrl+/
- Type superscript by Ctrl+6
- Type subscript by Ctrl+-
- Type overscript by Ctrl+7
- Type underscript by Ctrl+=
- Type square root by Ctrl+2
- Type radicals by square root and moving complementary position.