2010年5月4日 星期二

JSP: attributes of page directive

The following are legal attributes of page directive -

  1. import

  2. isThreadSafe

  3. session

  4. contentType

  5. autoFlush

  6. extends

  7. info

  8. errorPage

  9. isErrorPage

  10. language

2010年4月28日 星期三

Category 5 cable

Wiring

See modular connector for numbering of the pins


PinT568A PairT568B PairWireT568A Color (CROSS) A-BT568B Color (STRAIGHT) A-APins on plug face (socket is reversed)
132tipPair 3 Tip
white/green stripe
Pair 2 Tip
white/orange stripe
Rj45plug-8p8c.png
232ringPair 3 Ring
green solid
Pair 2 Ring
orange solid
323tipPair 2 Tip
white/orange stripe
Pair 3 Tip
white/green stripe
411ringPair 1 Ring
blue solid
Pair 1 Ring
blue solid
511tipPair 1 Tip
white/blue stripe
Pair 1 Tip
white/blue stripe
623ringPair 2 Ring
orange solid
Pair 3 Ring
green solid
744tipPair 4 Tip
white/brown stripe
Pair 4 Tip
white/brown stripe
844ringPair 4 Ring
brown solid
Pair 4 Ring
brown solid

2010年4月15日 星期四

Linux - startx

Install X:

sudo apt-get install xinit


xrdb command not found, X session not merged:
Install GUI:

Gnome: sudo aptitude install ubuntu-desktop
KDE: sudo aptitude install kubuntu-desktop


X: user not authorized to run the X server, aborting:
startx -- :1





2009年5月2日 星期六

The published solution uses the Session object as storage for the currently selected culture. This will be initialized during Session_Start method that is part of the global.asax file.

If a culture change is requested by the user (through a dropdownlist for example), the MasterPage changes the stored culture in the Session object.

In a BasePage that inherits from Page, the method InitializeCulture is overriden and sets the appropriate culture information stored in the session object to the current thread. Therefore, every Web Form needs to derive from this BasePage.

Step 1. Creating a base page

Under the App_code folder create a new codefile and name it BasePage. This is my code:

Imports Microsoft.VisualBasic
Imports System.Threading
Imports System.Globalization

”’


”’ Custom base page used for all web forms.
”’

Public Class BasePage
Inherits System.Web.UI.Page
Protected Overrides Sub InitializeCulture()

‘Set the UICulture and the Culture with a value stored in a Session-object. I called mine “MyCulture”
Thread.CurrentThread.CurrentUICulture = New CultureInfo(Session(”MyCulture”).ToString)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Session(”MyCulture”).ToString)
End Sub
End Class

Step 2: Let all pages derive from the BasePage

For every page where you want the localization to work, change Inherits System.Web.UI.Page to Inherits BasePage in the codefile (ex. YourPage.aspx.vb).

For example:

Partial Class Your_Class
Inherits BasePage

End Class

Instead of:

Partial Class Your_Class
Inherits System.Web.UI.Page

End Class

Step 3: Create a Global.asax file

Create a file under the root-folder and name it: Global.asax
Remove all the code and type: <%@ Application CodeBehind=”Global.asax.vb” Inherits=”Global2″ Language=”VB” %>

Under the App_Code folder create a file and name it Global.asax.vb.
Some remarks about the code:
- Use Global2 as classname because Global is a reserved word.
- Only the Session_Start method is necessary.
- I use a cookie (otmData) to store the users’ preference which is put in a Sessionvariable called MyCulture

‘Global.asax.vb codebehind file

Imports System.Web
Imports System.Web.SessionState
Imports System.Threading
Imports System.Globalization

Public Class Global2
Inherits System.Web.HttpApplication

Sub Session_Start(ByVal Sender As Object, ByVal E As EventArgs)

If Not Request.Cookies(”otmData”) Is Nothing Then
‘If a cookie exists, set the session-object with the data from the cookie.
Session(”MyCulture”) = Server.HtmlEncode(Request.Cookies(”otmData”)(”languagePref”))
Else
‘If the cookie doen’t exist (user visits the website for the first time) set the session-object to the default value, in this case English. And ‘create the cookie.
Session(”MyCulture”) = “en”
Dim aCookie As New HttpCookie(”otmData”)
aCookie.Values(”languagePref”) = Session(”MyCulture”)
aCookie.Expires = System.DateTime.Now.AddDays(21)
Response.Cookies.Add(aCookie)
End If
End Sub
End Class

Step 4: Dropdownlist on the masterpage

In my masterpage I created a dropdownlist which is populated with data from a sql-database. You can of course add items to the ddl manualy.
Make sure that the AutoPostBack-value is set to True.

The needed code for the selectedIndexChanged method:

Protected Sub ddlLanguage_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlLanguage.SelectedIndexChanged
‘if the session differs from the value in the ddl, the session-object is changed and the cookie is created
If Not Session(”MyCulture”) = ddlLanguage.SelectedValue Then
Session(”MyCulture”) = ddlLanguage.SelectedValue
Dim aCookie As New HttpCookie(”otmData”)
aCookie.Values(”languagePref”) = Session(”MyCulture”)
aCookie.Expires = System.DateTime.Now.AddDays(21)
Response.Cookies.Add(aCookie)
End If

‘Reload the page
Response.Redirect(Request.Url.ToString)
End Sub

2009年4月1日 星期三

Smart Applicants Matching System

Tools to automate resumes handling process

A single multilingual user interface for the user to analyze resumes received and exchange of data for wide range of common data sources. The process includes determination of job that the applicants looking for and their­­ qualifications. 

Download@:

2009年2月18日 星期三

c# : dataset

            // Navigate Dataset
            foreach (DataTable table in dataset.Tables)
            {
                temp += "TableName = " + table.TableName;
                temp += "---------";
                temp += "Columns ...\r\n";

                foreach (DataColumn column in table.Columns)
                {
                    //Console.Write("{0,-22}", column.ColumnName);
                    temp += column.ColumnName + "\t";
                }
                temp += "\n";
                temp += "\r\nNumber of rows = " + table.Rows.Count.ToString();
                temp += "Rows ...\r\n";

                foreach (DataRow row in table.Rows)
                {
                    foreach (Object value in row.ItemArray)
                    {
                        temp += value.ToString() + "\t";
                    }
                    temp += "\n";
                }
                temp += "\n";
            }

2009年2月3日 星期二

c# window application-- Change locale dynamically

CultureInfo objCI = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = objCI;
Thread.CurrentThread.CurrentUICulture = objCI;                

//localization code
this.Controls.Clear();
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
InitializeComponent();

this.lbTime.Text = DateTime.Now.ToLongDateString().ToString();