Archive

Archive for the ‘English - 英文’ Category

Fedora12 下配置 SVN 服务器

April 9th, 2010 lennydou No comments

assume the following dummy IP addresses and port of the server for the rest of the article: (replace these with your own IP, and port values)

  external IP: 55.444.444.55
  internal lan IP: 192.168.1.200
  svn port: 8080

Most of the operations here will require that you have access to the root account, as always.

I like to use the yum extender and an http gui to manipulate apache’s settings, so those need to be installed:

  > yum -y install yumex

This installs a gui for yum, which can be found, after a successful install on the desktop at:

  Applications > Yum Extender

Using the yum extender, we can see what has already been installed or not, on the linux machine. So, we should make sure that the Apache server is installed, and also install the Apache configuration tool (the http gui):

  httpd
  system-config-httpd

We also need to install the Apache server module for the subversion server:

  mod_dav_svn

Next, to install SVN subversion we can go back to the command line, and install it using yum:

  > yum install subversion

With these installations complete we can begin to create the necessary directories and modifying the various configuration files.

As root, create the following directory:

  > mkdir -p /var/www/svn/repository

change to that directory,

  > cd /var/www/svn/repository

and create a test repository,

  > svnadmin create test_svn

Notice: use svnadmin command maybe get an error: SQLite编译为3.6.20,但是运行于3.6.17。然后会发现repository目录下面并没有生成任何东西。此时需要在Yum Extender里面找到两个sqlite开头的包,然后升级这两个包就可以了。

Actually, these SVN directories can be placed anywhere, as long as you keep track of the correct path for the modifications that will need to be added later to the configuration files.

Next, change directory, and set the ownership so that Apache can access the SVN directories.

  > cd /var/www
  > chown -R apache.apache svn

Next, we modify Apache’s settings.

Before modifying Apache’s settings it would be a good idea to make a backup of the configuration file, in case the Apache server won’t restart, we can always restore the configuration file and try again.

  > cd   /etc/httpd/conf.d
  > cp  system-config-httpd.conf   system-config-httpd.conf.backup

Start the httpd configuration gui:

  > /usr/bin/system-config-httpd &

In this window set the server name to:
  192.168.1.200
Add to Available Addresses :

  listen to all addresses
  port: 8080

Then to save these settings, hit OK. These changes will modify the file:

  /etc/httpd/conf.d/system-config-httpd.conf

Restart the Apache server. There are operating system line commands for restarting the http daemon, but a GUI is just as easy, and we can keep the GUI open since we will need to restart Apache a few more times.

  /usr/bin/system-config-services &

Scroll down, select the daemon labeled httpd, and hit restart. Hopefully Apache restarts successfully, if not, then you may need to reload the original configuration file and try again.

Next, we will need to modify subversion’s configuration files.

To modify subversion’s configuration files we need to edit the following:

  /etc/httpd/conf.d/subversion.conf

This file was created with the installation of subversion.

The first two lines of the file should contain:

  LoadModule dav_svn_module modules/mod_dav_svn.so
  LoadModule authz_svn_module modules/mod_authz_svn.so

… if not, then those modules need to be installed.

First create a backup of the configuration file:

  > cp subversion.conf subversion.conf.backup

Modify the Location section of the file to the following:

  n  

Notice here how the directory for the repository we created earlier using the svnadmin command is not listed above. The above settings only point to the root location of the repository, or rather its parent path.

Save these settings, and restart the Apache server.

At this point we can test the SVN server from another PC on the private LAN. We can use our favorite web browser on a windows, linux, or mac PC, and enter the following URL:

  http://192.168.1.200:8080/svn/test_svn/

We should get a response page that looks like the following:

  Revision 0: /

  ————————————————————–
  Powered by Subversion version 1.4.4 (r25188).

If you can see this, then the SVN server is running.
Next, we need to add some password protection.

Here we add some password protection to the new SVN server.
For this, lets assume a username of trill, and a password of towel42.
Make the password directory:

  > mkdir /etc/httpd/passwd

To create the initial password file, and add a user called “trill”:

  > htpasswd -c /etc/httpd/passwd/svnpasswords trill

When the program asks, enter the password:

  towel42

Other command line options to htpasswd will allow you to add or delete more users.

For example, to add another user, called “asmith”:

  > htpasswd /etc/httpd/passwd/svnpasswords asmith

When the program asks, enter the password:

  neo22

This will append the user “asmith” to the passwords file, with the above password.

Edit the subversion configuration file to turn on the SVN authorization. We found that commenting out the <LimitExcept lines allowed the SVN password authorization to work. So the final subversion configuration file:

 /etc/httpd/conf.d/subversion.conf

… can look like this:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn/repository
</Location>

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn/repository

   # Limit write permission to list of valid users.
   #<LimitExcept GET PROPFIND OPTIONS REPORT>
      # Require SSL connection for password protection.
      # SSLRequireSSL

      AuthType Basic
      AuthName “Authorization Realm”
      AuthUserFile /etc/httpd/passwd/svnpasswords
      Require valid-user
   #</LimitExcept>
</Location>

After having made these changes, restart the Apache server as above. Now, if we go back to the PC with the web browser, we can test the password authentication. Restart the web browser and enter into the URL:

  http://192.168.1.200:8080/svn/test_svn/

We should see a window pop up, prompting for a user’s name and a corresponding password.

Enter trill for the user name, and towel42 for the password. This should let us see the svn server’s response page as before.

Categories: English - 英文 Tags: ,

Install MySQL from source in a Linux box

February 20th, 2010 Bali 1 comment

I had a CentOS Linux box bundled with a MySQL with Latin as default charset. As time goes by, I need

a) utf-8 everywhere(client, server, collation, everywhere) to support Chinese.

b) Innodb as default engine

Here is what I did:

1) Download latest source(mysql-5.1.44) from MySQL site

2) rpm -i xxx.src.rpm to install the source. By default, the source will be installed to /usr/src/redhat/SOURCES/mysql-5.1.44.

3) Go the root dir of source, run:

CFLAGS=”-O3″ CXX=gcc CXXFLAGS=”-O3 -felide-constructors \
-fno-exceptions -fno-rtti” ./configure \
–prefix=/usr/local/mysql –enable-assembler \
–with-mysqld-ldflags=-all-static \
–with-charset=utf8 \
–with-collation=utf8_general_ci \
–with-plugins=all

Explain: use gcc as compiler; install mysql to /usr/local/mysql; utf8 as default char set; install all plugins including innodb.

During this process, you may see errors saying “I need this, I need that”, use ‘yum‘ to install them.

And ./configure –help will show all possible options.

4) make

5) make install

And /usr/local/mysql will be the rool dir of new mysql installation.

6) Modify /etc/my.cnf. /usr/src/redhat/SOURCES/mysql-5.1.44/support-files/ contains sample configuration files. Note to set below:

[mysqld]

default-storage-engine = INNODB

7) Modify /etc/init.d/mysqld. You may need sym-link to new mysql installation.

Done. Below message should prove the installation is fine:

mysql> show engines;
+————+———+—————————————————————-+————–+——+————+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+————+———+—————————————————————-+————–+——+————+
| ndbcluster | NO      | Clustered, fault-tolerant tables                               | NULL         | NULL | NULL       |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB     | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MyISAM     | YES     | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
+————+———+—————————————————————-+————–+——+————+
9 rows in set (0.00 sec)

mysql> show variables like ‘%char%’;
+————————–+—————————————-+
| Variable_name            | Value                                  |
+————————–+—————————————-+
| character_set_client     | utf8                                   |
| character_set_connection | utf8                                   |
| character_set_database   | utf8                                   |
| character_set_filesystem | binary                                 |
| character_set_results    | utf8                                   |
| character_set_server     | utf8                                   |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
+————————–+—————————————-+
8 rows in set (0.00 sec)

mysql> show variables like ‘%colla%’;
+———————-+—————–+
| Variable_name        | Value           |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+———————-+—————–+
3 rows in set (0.00 sec)

Categories: English - 英文 Tags: ,

Graduate from Microsoft

January 8th, 2010 Bali 4 comments

(Keep in touch. My msn: baocun_hld AT hotmail DOT com, email: bill.z.li AT gmail DOT com)

My dear friends,

Today is my last working day in Microsoft, and it is time for me to start a long-awaited adventure. During past 3 years, many folks impressed me deeply and I hope have a slice of knowledge/skills you have.  After working in such a wonderful place, I possessed enough confidence to face any subtle difficulties ahead. What I got are much more than what I contributed to this company.

What I learned

  • How to tackle the most complex problems in the world as a team.
  • How to attract most smart people
  • How to inspire people
  • How to make a great place to work
  • How to build the right software right as a team
  • How to deliver good news
  • How to deliver bad news(This one is harder)
  • How to deliver good/bad reviews(One of hardest part of people management)
  • How to deliver a speech
  • How to handle *angry* customers
  • How to educate customers
  • How to learn what customers want
  • How to sit down with customers and close a deal
  • How to run a team of different size in different stage with different goals
  • How to make friends(Pop quiz: Do ICs need friends? Are they all about diagram and code?)
  • How to approach people and win their support
  • How to win an email argument
  • How to response to the competition news
  • How to beat competitors
  • How to build ecosystem
  • How to build up a giant company from scratch (If I can say)
  • The way how MSFT encourages knowledge sharing – Discussion loop, brown bag, online learning center, in-person training, marc polo, silk road, mentorship, mentor ring, code review, spec review …
  • Share ideas – think week paper, idea exchange, …
  • The most easy one – How to reply to all with a “good job” message after a product ship :-)
  • And many more…

I won’t claim I am a guru in any of areas above because I see what the highest standards are in this company. And I just reach the good(to me) level of combination of these ingredients.

People

  • So many great folks including leadership, developer, tester, PM, marketing, sales, support… I can’t say your names since this is public post, but I will memorize how you changed my mind.

and also something unique about me…

In addition to taking part in shipping 3 products…

  • Win FOOL(group alias ‘FOOL’) award. I am probably the only person who has this award in greater Asia.(If not, let me know. Maybe we can talk about that.)
  • Win Best Business Value award in a startup team
  • Win largest number of valid bugs in first team wide bug bash
  • Deliver a presentation to the whole STBC in all hands meeting. (Enwei is even listening to me:-)
  • Enter final list with a mobile phone innovation idea(Finally it is so smart that one team in US is on the way of building it quietly.)
  • Board number of of STBC citizenship committee
  • Organizer of Junior Achievement program in STBC
  • Posted a question which a technical fellow answered(MSFT have less than 20 technical fellows which are highest technical title one can achieve.)
  • Regular guest speaker of SJTU software institution
  • Probably the best Java learner in a .NET world
  • Probably the developer with most deep business minds, or business man with strong technical background(I call it “Think globally, act locally” as my blog slogan.)

Almost everyone asked about where I am going. This world is undertaking dramatic changes, especially this country. I can’t stay in this huge market to build software for anywhere else except here forever. Life is short, and I won’t forgive myself if time just passes by as “yet another year” way. Pursuing a fair ROI is another factor which won’t be achieved by working for any company. I am happy to complete engagement with Microsoft roughly on schedule.

2010 will be a new exciting start. I will enjoy in any event.

Good luck to us all! (And luck is actually where preparations meet opportunities.)

Bill

Categories: English - 英文 Tags:

Win7那些事儿(3) – Hesitate to reinstall?

November 7th, 2009 Bali No comments

I am lazy, as many folks are. One of compelling reasons for personal user not installing Win7 is as following,

“Win7 requires a clean install, which mean I will lost 2 days to back to full productivity. I have to reinstall my applications one by one, and set setting, and restore my data.”

If you agree with above claim. This post is for you. Read along.

1 Introduction

MyApps is a suite of technologies which allow users easily manage and distribute all their Windows applications in most convenient way than before. MyAapps is the name.

2 Problem

Have you ever hesitated rebuilding your dev machine to clean up an instability issue after looking at installed about 200 programs?

Have you ever help new members in your team setup and configure his development environment per strict team-acorss guidelines?

Have you ever had to exit setup dialog to install bunch of prerequisites?

Do you have to remember a long list of license key or file?

You may notice that existing processes that maintain applications and their settings in users’ computer are painful and time-consuming. The explosive growth of applications makes users be tired of finding software, waiting for download, playing with options, accepting defaults, inputting license key or file, clicking through and waiting reboot, especially when they are forced to repeat similar steps again and again. MyApps are technologies which change the way people distribute, access and manage various applications in their computer.

3 Solution

3.1 Unique Values

The unique values MyApps offer can be expressed as followings.

  • Easy installation – Users can install any application with one click.
  • App bag support – App list is a list of applications with customized options. Rebuild becomes never easier. You can kick off the installation of hundreds of applications within minutes, and go away to have a cup of coffee.
  • App bag sharing – You can share your application list to your team member or friends, and they can easily repro your environment.
  • Automatic dependency management – MyApps is aware of app dependency and will install all dependent apps for users automatically.
  • License management – do not need save license key/file locally any more. MyApps does that for users.

3.2 Core Scenarios

Key scenarios that MyApps addresses include:

  • One-stop installFrank needs building his dev machine containing about 120 various apps as the first dev of team COOL5. He logs onto MyApps site and set his preferences (e.g., install all apps onto D:\frankapps\) as the first time visitor. He browses/search the software and put them into MyCart of MyApps site. Finally, he accepts all EULAs and clicks Install, and then goes away for half-day training. When he returns, he finds that his computer is installed with latest software and ready to go.
  • Dependency awareness and license handling – .NET 3.5 is required by one of Frank’s selected app – SpeedLaunch, and is installed automatically along with SpeedLaunch. MyApps is also smart enough to handle license at the background for Frank.
  • Share app bagFrank starts customizing his apps. Frank points a debugging tool to an internal team testing DB. The setting is uploaded to public section in CuteInstall site. Frank sets font size to 12 in his VS2008 and uploads this to the private section. Finally Frank published his current app bag as “COOL5_dev_bag” in the MyApps site.
  • No need re-invent the wheelJoanne, the second dev of COOl5 team, install all apps same with Frank by clicking the link in his onboard email:

http://MyApps/install.aspx?bid=COOL5_dev_bag

Joanne also finds out that the debugging tool points to the team testing DB.

  • Easy repro – Months later, Frank has to rebuild his computer to clean out certain instability issues although he is facing tight schedule. Frank logs onto CuteInstall site and with his account and clicks “Restore to latest” button before he leaves office. The second day, Frank gets a fresh working machine with all his favorite private settings (e.g., font is 12 in VS2008) and continue working for his deadline without any delay.
  • Software shopping Sara, a regular computer user, logs onto a MyApps technology enabled online software shop with her Live ID. She decides to buy Office2007 and pays the bill using PayPal. After clicking “Install”, Office2007 is delivered/installed/Configured to her computer through a CDN network within 1/2 hour. She is very happy because she no long needs wait for DVD delivered by UPS again.

3.3 Value Proposition

For customers, the value propostion is pretty obvious if you look at the above scenarios carefully. It save man hours in every application installation and migration, increase productivity and improve across-team capabilities to meet business goals.

For Microsoft, it is also a “must have”. MyApps makes Windows platform more accessible and easy to manage. MyApps technologies bright customers’ unique values by leveraging our Windows platform leadership and global presence of Live platform. It also provides special value to our S+S strategy. More and more people turn to web app mostly because web app is:

  1. Easy available
  2. No download(s) and installation(s) required
  3. Your settings always go with you

MyApps technologies solve above 3 problems altogether. Software installation and maintenance are no longer headache for users. As a result, this ensures the success of Microsoft S+S strategy and strengthens our long term value. It is beneficial to the whole industry and any and every software users.

4 Logical Architecture

The diagram below shows the logical architecture of MyApps platform.

Arch of MyApps

Arch of MyApps

Two innovative concepts MyApps introduces are as follows:

  • Split of static and dynamic bits of apps which will be stored in App bits DB and App settings/bags DB respectively
  • App release description script

To achieve these goals, MyApps technology contains a suite of software component and standard.

  • MRT (MyApps Releasing Toolkit) – software vendors use this tool to write installer code. MRT is based on WSI.
  • MP (MyApps Portal) – it is centralized place which stores all configurable settings of all apps. And it is also responsible for managing software installation, licensing and user configurations.
  • MC (MyApps Client) – MC will be running on software users side to manage installation and settings.

Next we will discuss components one by one.

4.1 MyApps Releasing Toolkit

Every software release should provide a XML file like below.

<?xml version=1.0 encoding=utf-8?>

<App>

<Name>Microsoft.OfficeLabs.PeerMail</Name>

<Version>1.1.0.0</Version>

<DependencyManagement>

<Dependency>

<App>

<Name>Microsoft.DotNet</Name>

<Version>2.0</Version>

</App>

<App>

<Name>Microsoft.Office.Outlook</Name>

<Version>12.0.6213.1000</Version>

</App>

</Dependency>

</DependencyManagement>

<InstallSteps>

<step_by_step_install_guide_by_XML></step_by_step_install_guide_by_XML>

</InstallSteps>

</App>

This file makes sure that (1) the app gets globally unique name with Name and Version, (2) Dependency is clearly defined, (3) InstallSteps will reuse certain tasks pre-defined by MRT. The tasks sample provided by MRT will be to create folder, register COM component, start certain services, copy files, etc. MRT will read this file and generate releasing package.

4.2 MyApps Portal

MyApps Portal is the only place where users browse, search, install, configure, manage and share their apps across all their computers.

4.3 MyApps Client

MyApps will be running in software users as ActiveX IE plugin. Every app defines its config DB as following:

<?xml version=1.0 encoding=utf-8?>

<Configs>

<Section1>

<Property Key=key1 Value=value1 />

<Property Key=key2 Value=value2 />

</Section1>

<Section2>

<Property Key=key3 Value=value3 />

<Property Key=key4 Value=value4 />

</Section2>

</Configs>

We can use lightweight DB component(e.g., SQLite, or SQL Express) to achieve that.

5 Go TO Market Strategy

Business model would be software licensing.

MyApps is not just for resintalling the whole software stack. It actually allows users to maintain streamlined application and settings across the computer overtime. I will probably to start a project in CodePlex for this.

Acknowledgment: MyApps is inspired by Maven for Java, RubyGems for Ruby, CAPN for Perl, YUM for Linux, etc. I am actually surprised that Windows don’t have this till today. Ninite is likely, but far from solving the problem entirely.

Calling SQL Server Stored Procedures with ADO.NET in 5 minutes

August 2nd, 2009 Bali No comments

A stored procedure is an already written SQL statement that is saved in the database. It can take parameters; return objects you specified, just like what happens in any other programming languages you are familiar with.

Why stored procedures instead of random SQL? For me:

1. Modular Programming- Stored procedures allow developers to encapsulate business functionality and provide callers with a simple interface. Once interfaces are settled down, caller and callee coding work can be assigned to different team/persons.

2. Security Enhancement- Users can be granted permission to execute a stored procedure. Use parameterized queries—not string concatenation—to build queries.

3. Reduce network traffic – Benefits can be easily noticed if you have frequently called T-SQL code of hundreds of lines.

4. Performance – Stored procedures are registered at servers, and as a result DBAs/servers get more change to optimize them.

Coding time now. Firstly, you need run below SQL script in SQL2005.

SQL Script

– Create a test DB

USE [master]

GO

CREATE DATABASE SpTestDB

GO

USE SpTestDB

GO

– Create a test Table

CREATE TABLE dbo.TestTable (

id [nvarchar](50) NULL,

SomeValue [int] NULL

)

GO

– Create read SP

CREATE PROCEDURE dbo.ReadData

@id nvarchar (50)

AS

BEGIN

SELECT * FROM dbo.TestTable

WHERE id = @id;

END

GO

– Create write SP

CREATE PROCEDURE dbo.WriteData

@id nvarchar (50),

@SomeValue int

AS

BEGIN

INSERT INTO dbo.TestTable (id, SomeValue)

VALUES (@id, @SomeValue);

END

GO

Next, you can call in ADO.NET.

ADO.NET C# code

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.SqlClient;

namespace ConsoleApplication4

{

class Program

{

// NOTICE: You MUST replace ‘localhost\baligoal’ with your own DB instance name

const string ConnString = @”Data Source=localhost\baligoal;Initial Catalog=SpTestDB;Integrated Security=True”;

/// <summary>

/// Write a record to DB with stored procedure “WriteData”,

/// and then read it out with stored procedure “ReadData”

/// </summary>

/// <param name=”args”></param>

static void Main(string[] args)

{

const string TestID = “firstid”;

const int TestValue = 500;

// Firstly, write a record with store procedure

using (SqlConnection conn = new SqlConnection(ConnString))

{

// Specify ‘WriteData’ procedure in the params

using (SqlCommand cmd = new SqlCommand(“WriteData”, conn))

{

cmd.CommandType = System.Data.CommandType.StoredProcedure;

// The param names are exactly the same with SP WriteData’s

cmd.Parameters.AddWithValue(“@id”, TestID);

cmd.Parameters.AddWithValue(“@SomeValue”, TestValue);

cmd.Connection.Open();

cmd.ExecuteNonQuery();

}

}

// If you set BP here, and check you DB table, you should find ‘firstid, 500′ there

Console.WriteLine(“Write: done.”);

// Next, read it out with store procedure

using (SqlConnection conn = new SqlConnection(ConnString)) {

// Specify ‘ReadData’ procedure in the params

using (SqlCommand cmd = new SqlCommand(“ReadData”, conn)) {

cmd.CommandType = System.Data.CommandType.StoredProcedure;

// The param names is exactly the same with SP ReadData’s

cmd.Parameters.AddWithValue(“@id”, TestID);

cmd.Connection.Open();

using (SqlDataReader reader = cmd.ExecuteReader())

{

if (reader.Read()) {

Console.WriteLine(“read: id – “ + Convert.ToString(reader[0]));

Console.WriteLine(“read: SomeValue – “ + Convert.ToInt32(reader[1]));

}

}

}

}

// End for bp

Console.WriteLine(“exit”);

}

}

}

That is it.

Categories: English - 英文 Tags: ,