Archive for the ‘Computer’ Category

Recover Recycle Bin icon in Windows Vista

星期日, 九月 11th, 2011

We can recover Recycle Bin icon by the following steps:

1. Right-click on Desktop
2. Select "Personalize"
3. Click "Change desktop icons"
4. Check "Recycle Bin" in "Desktop icons"
5. Click "Apply"
5. Click "OK"

Store and Retrieve data in Struts 2

星期日, 二月 27th, 2011

In Struts 2, ActionContext, which is the global storage area, contains application, session, parameters, attr, request, ValueStack (root), and other objects, while Action resides on the ValueStack.

To retrive a first-level Action’s property or data from the ValueStack:

<s:property value="name"/>

To retrive a second-level Action’s  property or data from the ValueStack:

<s:property value="student.name"/>

To store a property to the ActionContext:

<s:set name="studentName" value="student.name" />

To retrive a property from the ActionContext:

<s:property value="#studentName" />
 

To store a property to application, session, parameters, attr, or request:

<!-- Replace session for others -->
<s:set name="studentName" value="student.name" scope="session" />

To retrive a property from application, session, parameters, attr, or request:

<!-- Replace session for others -->
<s:property value="#session['studentName']" />

Restrict input data of cells in MS Excel 2003

星期日, 二月 27th, 2011

We can restrict input data of cells by the following steps:

1. Highligh cells to be restricted to input data
2. Click "Data"
3. Click "Validation"
4. Select "List" in "Allow"
5. Enter "chioce1,choice2,choice3″ in "Source"
6. Click "OK"

Remove all options of a Select object in JavaScript‏

星期三, 十一月 10th, 2010

The simplest way is:

selectObject.length = 0;

TinyMCE Advanced

星期日, 九月 12th, 2010

This WordPress’s plugin extends TinyMCE, WordPress’s WYSIWYG editor, with 16 new buttons including Advanced hr, Advanced Image, Advanced Link, Context Menu, Emotions (Smilies), Full Screen, IESpell, Layer, Media, Nonbreaking, Print, Search and Replace, Style, Table, Visual Characters and XHTML Extras.

All buttons can be added to and removed from the editor’s toolbar in the following administrator page of WordPress:

Settings > TinyMCE Advanced > TinyMCE Buttons Arrangement

SyntaxHighlighter Evolved

星期日, 九月 12th, 2010

This WordPress’s plugin makes use of Alex Gorbatchev’s Syntax Highlighter to highlight code snippets in WordPress

Simple Usage
Just wrap the code snippets by the language’s alias:

[lang]code[/lang]

e.g.

[php]code[/php]
Language Supported Aliases
ActionScript3 as3, actionscript3
Bash/shell bash, shell
ColdFusion cf, coldfusion
C# c-sharp, csharp
C++ cpp, c
CSS css
Delphi delphi, pas, pascal
Diff diff, patch
Erlang erl, erlang
Groovy groovy
JavaScript js, jscript, javascript
Java java
JavaFX jfx, javafx
Perl perl, pl
PHP php
Plain Text plain, text
PowerShell ps, powershell
Python py, python
Ruby rails, ror, ruby
Scala scala
SQL sql
Visual Basic vb, vbnet
XML xml, xhtml, xslt, html, xhtml

Advanced Usage
Use attributes in addtion:

[lang attrib1="val1" attrib2="val2"]code[/lang]

e.g.

[php firstline="2" highlight="2,4,6" wraplines="true"]code[/php]
Attribute Usage Values
auto-links Toggle URL linking true or false
class-name Add additional CSS classes A list of class names
collapse Toggle collapsing the code box true or false
first-line Change the starting line number A number
gutter Toggle the line numbering true or false
highlight Highlight specific lines An array of numbers
html-script Toggle highlighting HTML/XML code also true or false
light Toggle the line numbering and toolbar true or false
padlinenumbers Change padding the leading zeros of the line numbers true (automatic padding) or false (no padding) or an integer
toolbar Toggle the toolbar true or false
wraplines Toggle the scrollbar ture (disable the scrollbar) or false (show the scrollbar)

Extend the content width of the default theme in WordPress 2.9

星期日, 九月 5th, 2010

We can extend the content width by, for example, 224 pixels by the following steps:

1. Increase the widths of the following pictures by 224 pixels
/wp-content/themes/default/images/kubrickheader.jpg
/wp-content/themes/default/images/kubrickfooter.jpg
/wp-content/themes/default/images/kubrickbg-ltr.jpg
/wp-content/themes/default/images/kubrickbg-rtl.jpg
/wp-content/themes/default/images/kubrickbgwide.jpg

2. Make some changes in the following files
/wp-content/themes/default/images/header-img.php segment:

// Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )
$corners = array(
	0 => array ( 25, 734 ), // Change to 0 => array ( 25, 734 + 224 ),
	1 => array ( 23, 736 ), // Change to 1 => array ( 23, 736 + 224 ),
	2 => array ( 22, 737 ), // Change to 2 => array ( 22, 737 + 224 ),
	3 => array ( 21, 738 ), // Change to 3 => array ( 21, 738 + 224 ),
	4 => array ( 21, 738 ), // Change to 4 => array ( 21, 738 + 224 ),
	177 => array ( 21, 738 ), // Change to 177 => array ( 21, 738 + 224 ),
	178 => array ( 21, 738 ), // Change to 178 => array ( 21, 738 + 224 ),
	179 => array ( 22, 737 ), // Change to 179 => array ( 22, 737 + 224 ),
	180 => array ( 23, 736 ), // Change to 180 => array ( 23, 736 + 224 ),
	181 => array ( 25, 734 ), // Change to 181 => array ( 25, 734 + 224 ),
	);

// Blank out the blue thing
for ( $i = 0; $i < $h; $i++ ) {
	$x1 = 19;
	$x2 = 740; // Change to $x2 = 740 + 224;
	imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
}

// Draw a new color thing
for ( $i = 0; $i < $h; $i++ ) {
	$x1 = 20;
	$x2 = 739; // Change to $x2 = 739 + 224;
	$r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;
	$g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;
	$b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;
	$color = imagecolorallocate( $im, $r, $g, $b );
	if ( array_key_exists($i, $corners) ) {
		imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
		list ( $x1, $x2 ) = $corners[$i];
	}
	imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );
}

/wp-content/themes/default/style.css segment:

/* Begin Typography & Colors */
#headerimg 	{
	margin: 7px 9px 0;
	height: 192px;
	width: 740px; /* Change to width: 964px; */
	}
/* End Typography & Colors */

/* Begin Structure */
#page {
	background-color: white;
	margin: 20px auto;
	padding: 0;
	width: 760px; /* Change to width: 984px; */
	border: 1px solid #959596;
	}

#header {
	background-color: #73a0c5;
	margin: 0 0 0 1px;
	padding: 0;
	height: 200px;
	width: 758px; /* Change width: 982px; */
	}

.narrowcolumn {
	float: left;
	padding: 0 0 20px 45px;
	margin: 0px 0 0;
	width: 450px; /* Change to width: 674px; */
	}

.widecolumn {
	padding: 10px 0 20px 0;
	margin: 5px 0 0 150px;
	width: 450px; /* Change to width: 674px; */
	}

#footer {
	padding: 0;
	margin: 0 auto;
	width: 760px; /* Change to width: 984px; */
	clear: both;
	}
/* End Structure */

/* Begin Sidebar */
#sidebar
{
	padding: 20px 0 10px 0;
	margin-left: 545px; /* Change to margin-left: 769px; */
	width: 190px;
	}
/* End Sidebar */

Obtain checked values of HTML checkboxes in Java Servlet

星期六, 三月 13th, 2010

HTML Segment:

<form method="post" action="<%=request.getContextPath()%>/servlet/ObtainCheckedValueServlet">
What are your favorite colors?<br />
<input type="checkbox" name="color" value="COLOR01" /> Red<br />
<input type="checkbox" name="color" value="COLOR02" /> Blue<br />
<input type="checkbox" name="color" value="COLOR03" /> Green<br />
<input type="submit" value="submit" />
</form>

Java Servlet Segment:

// Obtain checked values (available values here are COLOR01,
// COLOR02, and COLOR03) of HTML checkboxes by the method
// String[] request.getParameterValues(String), which obtains all
// values of request parameters with the same specified name.
// Note that this method will return null if no parameter with the
// specified name exists. No parameter with the specified name
// exists if no checkbox is checked. Thus, the method will return
// null if no checkbox is checked.
String[] checked_values = request.getParameterValues("color");
if (checked_values != null)
{
   // Display all obtained checked values
   for (int i = 0; i < checked_values.length ; i++)
   {
      System.out.println("checked_values[" + i + "]: " + checked_values[i]);
   }
}

Create an Object in JavaScript

星期六, 三月 13th, 2010

The simplest way is using new Object():

<script type="text/javascript">
<!--
// Declare an object
var car = new Object();

// Initialize the object's properties
car.name = "Car A";
car.price = "$100k";

document.write("Original Car Info<br />");
document.write("car.name: " + car.name + "<br />");
document.write("car.price: " + car.price + "<br /><br />");

// Declare a function of the object
car.update = function(name, price)
{
   this.name = name;
   this.price = price;
}

// Update the object's properties
car.update("Car B", "$130k");

document.write("Updated Car Info<br />");
document.write("car.name: " + car.name + "<br />");
document.write("car.price: " + car.price + "<br />");
//-->
</script>

Apply JavaScript

星期六, 三月 13th, 2010

Method 1
By importing external JavaScript files:

<script type="text/javascript" src="<%=request.getContextPath()%>/js/common1.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/common2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/common3.js"></script>

Method 2
By embedding scripts:

<script type="text/javascript">
<!--
document.write("Hello World!");
//-->
</script>

Note that a HTML comment is added to prevent scripts from being displayed as plain text in browsers that do not support JavaScript, as such browsers will treat the scripts as a HTML comment. A JavaScript comment // is added in front of the end of the HTML comment –> to prevent it from being read as a part of the scripts. JavaScript interpreters will treat both lines as one-line JavaScript comments.