Surendran 的个人资料..::SUreN::..照片日志列表更多 工具 帮助

日志


2008/9/4

Session Variables

<sessionState

mode

="InProc"

stateConnectionString

="tcpip=127.0.0.1:42424"

sqlConnectionString

="data source=127.0.0.1;Trusted_Connection=yes"

cookieless

="false"

timeout

="20"

/>

2008/4/22

Two Background Images In Single Cell

html:


<div class="outer">
<div class="inner">
<h1>Hello World</h1>
<p>
blah blah blah blah..
</p>
</div>
</div>

CSS:


.outer {
background: #666 url(graphic.gif) repeat-y top left;
padding-left: 50px;
}
.inner {
background: #666 url(graphic.gif) repeat-y top right;
padding-right: 50px;
}

More than 100 Keyboard Shortcuts

Keyboard Shorcuts (Microsoft Windows)
  1. CTRL+C (Copy)
  2. CTRL+X (Cut)
  3. CTRL+V (Paste)
  4. CTRL+Z (Undo)
  5. DELETE (Delete)
  6. SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)
  7. CTRL while dragging an item (Copy the selected item)
  8. CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)
  9. F2 key (Rename the selected item)
  10. CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)
  11. CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)
  12. CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)
  13. CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)
  14. CTRL+SHIFT with any of the arrow keys (Highlight a block of text)
    SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)
  15. CTRL+A (Select all)
  16. F3 key (Search for a file or a folder)
  17. ALT+ENTER (View the properties for the selected item)
  18. ALT+F4 (Close the active item, or quit the active program)
  19. ALT+ENTER (Display the properties of the selected object)
  20. ALT+SPACEBAR (Open the shortcut menu for the active window)
  21. CTRL+F4 (Close the active document in programs that enable you to have multiple documents open simultaneously)
  22. ALT+TAB (Switch between the open items)
  23. ALT+ESC (Cycle through items in the order that they had been opened)
  24. F6 key (Cycle through the screen elements in a window or on the desktop)
  25. F4 key (Display the Address bar list in My Computer or Windows Explorer)
  26. SHIFT+F10 (Display the shortcut menu for the selected item)
  27. ALT+SPACEBAR (Display the System menu for the active window)
  28. CTRL+ESC (Display the Start menu)
  29. ALT+Underlined letter in a menu name (Display the corresponding menu) Underlined letter in a command name on an open menu (Perform the corresponding command)
  30. F10 key (Activate the menu bar in the active program)
  31. RIGHT ARROW (Open the next menu to the right, or open a submenu)
  32. LEFT ARROW (Open the next menu to the left, or close a submenu)
  33. F5 key (Update the active window)
  34. BACKSPACE (View the folder one level up in My Computer or Windows Explorer)
  35. ESC (Cancel the current task)
  36. SHIFT when you insert a CD-ROM into the CD-ROM drive (Prevent the CD-ROM from automatically playing)
Dialog Box Keyboard Shortcuts
  1. CTRL+TAB (Move forward through the tabs)
  2. CTRL+SHIFT+TAB (Move backward through the tabs)
  3. TAB (Move forward through the options)
  4. SHIFT+TAB (Move backward through the options)
  5. ALT+Underlined letter (Perform the corresponding command or select the corresponding option)
  6. ENTER (Perform the command for the active option or button)
  7. SPACEBAR (Select or clear the check box if the active option is a check box)
  8. Arrow keys (Select a button if the active option is a group of option buttons)
  9. F1 key (Display Help)
  10. F4 key (Display the items in the active list)
  11. BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)

Microsoft Natural Keyboard Shortcuts

  1. Windows Logo (Display or hide the Start menu)
  2. Windows Logo+BREAK (Display the System Properties dialog box)
  3. Windows Logo+D (Display the desktop)
  4. Windows Logo+M (Minimize all of the windows)
  5. Windows Logo+SHIFT+M (Restore the minimized windows)
  6. Windows Logo+E (Open My Computer)
  7. Windows Logo+F (Search for a file or a folder)
  8. CTRL+Windows Logo+F (Search for computers)
  9. Windows Logo+F1 (Display Windows Help)
  10. Windows Logo+ L (Lock the keyboard)
  11. Windows Logo+R (Open the Run dialog box)
  12. Windows Logo+U (Open Utility Manager)
  13. Accessibility Keyboard Shortcuts
  14. Right SHIFT for eight seconds (Switch FilterKeys either on or off)
  15. Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)
  16. Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)
  17. SHIFT five times (Switch the StickyKeys either on or off)
  18. NUM LOCK for five seconds (Switch the ToggleKeys either on or off)
  19. Windows Logo +U (Open Utility Manager)
  20. Windows Explorer Keyboard Shortcuts
  21. END (Display the bottom of the active window)
  22. HOME (Display the top of the active window)
  23. NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)
  24. NUM LOCK+Plus sign (+) (Display the contents of the selected folder)
  25. NUM LOCK+Minus sign (-) (Collapse the selected folder)
  26. LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)
  27. RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)

Shortcut Keys for Character MapAfter you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:

  1. RIGHT ARROW (Move to the right or to the beginning of the next line)
  2. LEFT ARROW (Move to the left or to the end of the previous line)
  3. UP ARROW (Move up one row)
  4. DOWN ARROW (Move down one row)
  5. PAGE UP (Move up one screen at a time)
  6. PAGE DOWN (Move down one screen at a time)
  7. HOME (Move to the beginning of the line)
  8. END (Move to the end of the line)
  9. CTRL+HOME (Move to the first character)
  10. CTRL+END (Move to the last character)
  11. SPACEBAR (Switch between Enlarged and Normal mode when a character is selected)

Microsoft Management Console (MMC)

Main Window Keyboard Shortcuts

  1. CTRL+O (Open a saved console)
  2. CTRL+N (Open a new console)
  3. CTRL+S (Save the open console)
  4. CTRL+M (Add or remove a console item)
  5. CTRL+W (Open a new window)
  6. F5 key (Update the content of all console windows)
  7. ALT+SPACEBAR (Display the MMC window menu)
  8. ALT+F4 (Close the console)
  9. ALT+A (Display the Action menu)
  10. ALT+V (Display the View menu)
  11. ALT+F (Display the File menu)
  12. ALT+O (Display the Favorites menu)

MMC Console Window Keyboard Shortcuts

  1. CTRL+P (Print the current page or active pane)
  2. ALT+Minus sign (-) (Display the window menu for the active console window)
  3. SHIFT+F10 (Display the Action shortcut menu for the selected item)
  4. F1 key (Open the Help topic, if any, for the selected item)
  5. F5 key (Update the content of all console windows)
  6. CTRL+F10 (Maximize the active console window)
  7. CTRL+F5 (Restore the active console window)
  8. ALT+ENTER (Display the Properties dialog box, if any, for the selected item)
  9. F2 key (Rename the selected item)
  10. CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)

Remote Desktop Connection Navigation

  1. CTRL+ALT+END (Open the Microsoft Windows NT Security dialog box)
  2. ALT+PAGE UP (Switch between programs from left to right)
  3. ALT+PAGE DOWN (Switch between programs from right to left)
  4. ALT+INSERT (Cycle through the programs in most recently used order)
  5. ALT+HOME (Display the Start menu)
  6. CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
  7. ALT+DELETE (Display the Windows menu)
  8. CTRL+ALT+Minus sign (-) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)
  9. CTRL+ALT+Plus sign (+) (Place a snapshot of the entire client window area on the Terminal server clipboard and provide the same functionality as pressing ALT+PRINT SCREEN on a local computer.)

Microsoft Internet Explorer Navigation

  1. CTRL+B (Open the Organize Favorites dialog box)
  2. CTRL+E (Open the Search bar)
  3. CTRL+F (Start the Find utility)
  4. CTRL+H (Open the History bar)
  5. CTRL+I (Open the Favorites bar)
  6. CTRL+L (Open the Open dialog box)
  7. CTRL+N (Start another instance of the browser with the same Web address)
  8. CTRL+O (Open the Open dialog box, the same as CTRL+L)
  9. CTRL+P (Open the Print dialog box)
  10. CTRL+R (Update the current Web page)
  11. CTRL+W (Close the current window)
2008/4/9

5 cool things you can do with windows and php

Many PHP examples out there are designed for a linux/unix operating system. I am going to give some examples of some interesting functionality that only works with php running in a windows environment (IIS or apache).

1) Eject the CD-ROM

//create an instance of Windows Media Player
$mp = new COM("WMPlayer.OCX");
//ejects the first cd-rom on the drive list
$mp->cdromcollection->item(0)->eject();

2) Read and write from/to the registry

function registry_read($folder, $key)
{
$WshShell = new COM("WScript.Shell");

$registry = “HKEY_LOCAL_MACHINE\SOFTWARE\\” . $folder . “\\” . $key;
$result = $WshShell->RegRead($registry);

return($result);
}

$key = registry_read(”RegisteredApplications”,”Firefox”);
parameters:

    * Folder name - (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
    * key - the key name to read from

function registry_write($folder, $key, $value,$type="REG_SZ")
{
$WshShell = new COM("WScript.Shell");

$registry = “HKEY_LOCAL_MACHINE\SOFTWARE\\” . $folder . “\\” . $key;
$result = $WshShell->RegRead($registry);
$result = $WshShell->RegWrite($registry,$value, $type);

return($result);
}

parameters:

    * Folder name - (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
    * key - the key name to write to
    * value - value that will be written to the key
    * type - key type (default: REG_SZ)

3) register and un-register phpscripts as a windows service

# registering a service

win32_create_service(array(
’service’ => ‘myservice’, # the name of your service
‘display’ => ’sample dummy PHP service’, # description
‘params’ => ‘c:\path\to\script.php run’, # path to the script and parameters
));

# un-registering a service

win32_delete_service(’myservice’);

# code run as a service

if ($argv[1] == 'run') {
win32_start_service_ctrl_dispatcher('myservice');

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
# write script here
# as a general rule, keep it below 30 seconds through each loop iteration
}
}

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

    * Download the main library (it’s included in the main PECL extension download from php.net) here
    * extract php_win32service.dll to your ext directory (where your php extension .dlls are located)
    * add the following line to your php.ini: extension=php_win32service.dll

4) print pages/data

#this is an example function that will format a host/printer name, for printing to shared printers over the network

function getPrinter($host,$SharedPrinterName) {
return “\\\\”.$host.”\\”.$SharedPrinterName;
}

#this opens the printer
$handle = printer_open(getPrinter(”my computer 2″,”my printer”));

An extensive list of functions for printing can be found here

#this is possible in *nix as well. Here is some example code

function lpr($string,$printer) {
$prn=(isset($printer) && strlen($printer))?”$printer”:C_DEFAULTPRN ;
$CMDLINE=”lpr -P $printer “;
$pipe=popen(”$CMDLINE” , ‘w’ );
if (!$pipe) {print “pipe failed.”; return “”; }
fputs($pipe,$string);
pclose($pipe);
}

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

    * Download the main library (it’s included in the main PECL extension download from php.net) here
    * extract php_printer.dll to your ext directory (where your php extension .dlls are located)
    * add the following line to your php.ini: extension=php_printer.dll

5) List the current system processes

# list all the current processes running on the system

print_r(win32_ps_list_procs());

other related commands:

# Retrieves statistics about the global memory utilization
print_r(win32_ps_stat_mem());

# Retrieves statistics about the process with the process id pid (if no process id is given, the current process will be used)
print_r(win32_ps_stat_proc(int processid));

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

    * Download the main library (it’s included in the main PECL extension download from php.net) here
    * extract php_win32ps.dll to your ext directory (where your php extension .dlls are located)
    * add the following line to your php.ini: extension=php_win32ps.dll

2008/2/25

String to time

echo strftime('%d-%m-%Y %H:%M:%S', strtotime('2007-10-25 10:10:10'));
2007/5/23

convert field values to upper (or lower) case

To demonstrate this, let's assume you have a Contacts table containing addresses in North America. For some reason, your State and Province abbreviations have been entered in mixed case. For example, some of your California contacts have been entered as "ca", "Ca, and "CA." The following SQL query would change these to "CA" and all other abbreviations to upper case:
 
UPDATE
   "CONTACTS.DB"
SET
   StateProv = upper( StateProv )
2007/5/8

Optimize All Tables In A MySQL Database

Description

If you have a database driven site and you want to optimize MySQL tables then this is perfect. It goes through all the tables in a MySQL database and does table optimization on each one using the MySQL Optimize Table syntax.

The code


<?php

dbConnect
()

$alltables = mysql_query("SHOW TABLES");

while (
$table = mysql_fetch_assoc($alltables))
{

   foreach (
$table as $db => $tablename)
   {
       
mysql_query("OPTIMIZE TABLE '".$tablename."'")
           or die(
mysql_error());
   }
   
}

?>

Directory lister

Description

Displays a hyperlinked list of all the files contained in a specified folder. A really simple way to have your own directory browser, just drop the file in the folder and it will show an index of all files in the directory on your webspace.

The code


<?

/**
* Change the path to your folder.
*
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory.
*/

    // Define the full path to your folder from root
    
$path = "/home/user/public/foldername/";

    
// Open the folder
    
$dir_handle = @opendir($path) or die("Unable to open $path");

    
// Loop through the files
    
while ($file = readdir($dir_handle)) {

    if(
$file == "." || $file == ".." || $file == "index.php" )

        continue;
        echo
"<a href=\"$file\">$file</a><br />";

    }

    
// Close
    
closedir($dir_handle);

?>

Display a different image for each day of the week

Description

This PHP script will get the day of the week from the server date and then display an image (jpg or gif) to match.

The code


<?php

/**
* Change the name of the image folder
*
* Images must be named Monday.gif, Tuesday.gif etc
*/

// Change to the location of the folder containing the images
$image_folder = "images/days";

// You do not need to edit below this line

$today = date('l');

if (
file_exists($image_folder."/".$today.".gif")) {
  echo
"<img src=\"$image_folder/".$today.".gif\">";
}
else {
  echo
"No image was found for $today";
}

?>

Random image

Displays a random image on a web page. Images are selected from a folder of your choice.

<?php

/*
 * Name your images 1.jpg, 2.jpg etc.
 *
 * Add this line to your page where you want the images to
 * appear: <?php include "randomimage.php"; ?>
 */

// Change this to the total number of images in the folder
$total = "11";

// Change to the type of files to use eg. .jpg or .gif
$file_type = ".jpg";

// Change to the location of the folder containing the images
$image_folder = "images/random";

// You do not need to edit below this line

$start = "1";

$random = mt_rand($start, $total);

$image_name = $random . $file_type;

echo "<img src=\"$image_folder/$image_name\" alt=\"$image_name\" />";

?>
2007/4/20

PHP: Random Quote

Make a file called quotes.txt

Put each quote on it's on line.

Here's a script:

<?
$r_array=file('quotes.txt');
shuffle($r_array);
echo $mQuotePath[0];
echo $r_array[0];
?>
2007/3/29

Flash Fullscreen, Without changing image size

stop();
getURL(FSCommand:allowscale, false);
getURL(FSCommand:fullscreen, true);
2007/1/24

php.ini to run <? without <?php 5

short_open_tag = on
2007/1/5

File Browse without button

<html>
<head>
    <title>File Upload Example</title>
    <script language="JavaScript" type="text/javascript">
    function HandleFileButtonClick()
    {
        document.frmUpload.myFile.click();
        document.frmUpload.txtFakeText.value = document.frmUpload.myFile.value;
    }
    </script>
</head>
<body>
  <form name="frmUpload">
    <input type="file" name="myFile" style="display: none">
    <input type="text" name="txtFakeText" readonly="true">
    <a href="javascript:HandleFileButtonClick();">Attach</a>
  </form>
</body>
</html>
2006/12/19

SQL - net send

xp_cmdshell "net send localhost hi'

Move Window

<meta http-equiv="refresh" content="5;URL=windowmove.html">
<script>
<!--//
  var mx=10
  var my=10

function movewindow(n)
{
if (window.top.moveBy)
    {
for (i = 10; i > 0; i--)
 {
for (j = n; j > 0; j--)
  {
   window.top.moveBy(0,i);
   window.top.moveBy(i,0);
   window.top.moveBy(0,-i);
   window.top.moveBy(-i,0);
  }
 }
    }
}

-->
</script>
</HEAD>
<BODY onload="movewindow(10);">

2006/11/2

AJAX : Connections

AJAX = Asynchronous JavaScript And XML
HTML
<html>
<head>
<script src="selectcustomer.js"></script>
</head>
<body>
<form> 
Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<option value="ALFKI">Alfreds Futterkiste
<option value="NORTS ">North/South
<option value="WOLZA">Wolski Zajazd 
</select>
</form>
<p>
<div id="txtHint"><b>Customer info will be listed here.</b></div>
</p>
</body>
</html>
 
JavaScript
var xmlHttp

function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="getcustomer.asp"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
 
Server side
sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
sql=sql & request.querystring("q")

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open sql, conn

response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")
next
rs.MoveNext
loop

response.write("</table>")

SQL - All Field Search

SELECT * FROM employee WHERE MATCH (name,age,salary,address,telephone) AGAINST ('suren')
2006/10/31

Flash : Font Problem

var textFileData = new LoadVars();
textFileData.onLoad = function ()
{
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "my font";
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 120);
my_txt.wordWrap = true;
my_txt.embedFonts = true;
my_txt.htmlText = textFileData.name;
my_txt.setTextFormat(my_fmt);
};
textFileData.load("text.txt");