Friday, December 26, 2008

Describing data

Bar charts and pie charts

Bar charts are popular for showing the relative occurrence of an atrribute. The lengths of the bars represent the frequencies with which the various categories were found in the sample.

Sometimes the frequency for a category of an attribute can be subdivided within that category.
  • Stacked bar chart: each subcategory is stacked over
  • Multiple bar chart: subcategories are displayed as a bar adjacent to each other
When the data can be thought of as being a breakdown of some whole entity into component parts then a pie chart cna be drawn.

Numerical measures for raw data

mean or average

Extraordinarily large or small x values, called outliers, will have a disproportionate effect on the average of a sample.
.
The median is defined to be the middle value when all the data is arranged in numerical order.

The mode reprensents the most popular value which occurs more frequently than any other.

To measure the spread of the data:
  • The range equals to the largest data value minus the smallest one.
  • The variance is related to the deviations of the data values from their mean.
  • The standard deviation is the square root of the variance.
There are usually two standard deviation options, one marked \sigma_{n-1}, which is the sample standard deviation, and another marked \sigma_{n}, the population standard deviation. The latter applies only when the data relates to the entire population. We shall have no use for it as all our work is with samples which are not complete polulations.

Similar to the median (greater than 50% of the data), we can define lower quartile (greater than 25% of the data) and upper quatile (greater than 75% of the data). The distance between the lower and upper quartiles is the interquartile range which contains half the values.

Sometimes the size of the numbers in a sample may be too large and lead to numerical errors. It is helpful to subtract a suitable number, an assumed mean, from every data value. After getting the mean of the new sample, it can be adjusted by adding back the assumed mean afterwards. The range, variance and standard deviation all remain the same for the adjusted sample as its spread is precisely the same as that of the original data.

Grouped data, histograms and ogives

When the sample contains many different values, data can be classified. For example, The lengths of the stalks of hundreds of dandelions were measured and classified to form a grouped frequency table:

Stalk length (mm) 1.0-4.0 4.0-6.0 6.0-8.0 ........
Number of dandelions 9 25 34 ........

The diagram must illustrate not only the frequencies with which the data values occur within the different classes, but also the sizes of the class widths. A histogram is a kind of bar chart where the widths of the bars represent the widths of the classes. As areas have more visual impact than lengths, we draw bars whose areas are proportional to the frequencies for each class.

The scall of the vertical axis and its label, 'Frequency/class width' are ofter omitted, leaving the areas to indicate the relative sizes of the frequencies without conveying their exact values.

In order to estimate the mean, variance, etc., we assume that the value of each class equals to the mid-point of the class to which it belongs.

The cumulative frequency of x is the number of data values which are less than or equal to x. A graph of cumulative frequency against x should be a smoothly varying curve. It is called a cumulative frequency curve or ogive. The ogive can be constructed from the grouped frequency table.

Time series, frequency polygons and indices

A sequence of measurements corresponding to different instants or periods of time is called a time series. It should be noted that a time series is a single sample with two variables being measured, the quantitiy of interest and time.

Time series can be illustrated by a frequency polygon. It consists of straight lines joining the values of each measurement. It is often felt necessary to focus attention on the movement of the figures in a time series rather than on their absolute size. An index is established for the series by expressing each data value as a percentage of the figure for a base year. For example, CPI. A frequency polygon with indices would look exactly the same as the actual scale on the vertical axis.

Scatter diagrams

A scatter diagram is a plot of one variable against another showing how, if at all, they are related.

Thursday, December 25, 2008

The General Two-Person, Zero-Sum Game

The games in this chapter have no equilibrium points; if you are to win anything like the amount that you should, you must start second-guessing your opponent in earnest.

A strategy that prescribes the selection of a pure strategy by means of random device is called a mixed strategy.

Once a player resorts to randomizing, not only can he/she not lose (on average), no matter how well an opponent plays; he/she will not gain, however badly an opponent plays. The more capable your opponent, then, the more attractive the randomizing procedure.

von Meumann's Minimax Theorem

One can assign to every finite, two-person, zero-sum game a value V: the average amount that player I can expect to win from player II if both players act sensibly. This predicted outcome is plausible, for three reasons:
  1. Player I will not settle for anything less than V.
  2. Player I can prevented from getting more than V.
  3. Since the game is zero-sum, player II is motivated to limit I's average return to V.
We can treat all two-person, zero-sum games as though they had equilibrium points. The only difference between games with actual equilibrium points and those without them is that in one case you can use a pure strategy and obtain the value of the game with certainty, while in the other case you must use a mixed strategy and you obtain the value of the game on average.

Calculating Mixed Strategies

A strategy may be dominated by either a pure strategy or a mixed one.

  1. Calculate the maximin and minimax - if they are equal, this is a game with exact equilibrium point(s). Otherwise, go on to step 2.
  2. Eliminate all strategies that are dominated.
  3. Assign probabilities to each of your strategies so that the outcome of the game will be the same on average whatever your opponent does. Assume your opponent does the same; if the outcome when you use this mixed strategy is the same as the outcome when your opponent uses his/her mixed strategy and if all probabilities are nonnegative, you have solved the game.
If there is a gap between the outcomes or if some of the probabilities are negative, reexamine the games for dominated strategies; if there are none, then this method failed.

For example,




Your Opponent


D
E

A
15
10

B
6
15
You
C
5
20

1/5 A and 4/5 C7
18

p A and (1-p)C
15*p + 5*(1-p)10*p + 20*(1-p)
Your strategy B is dominated by the mixed strategy of A and C, such as play A 1/5 of the time and C 4/5 of the time. Then B is eliminated.

Then let's assume that you play A with probability p and C with (1-p), and your opponent plays D with probability r and E with (1-r). We need 15*p + 5*(1-p) = 10*p + 20*(1-p). Therefore, p = 3/4 and the corresponding payoff is 12.5 on average.

By a similar calculation, you find that your opponent should play each of his/her strategies half the time and the payoff is the same 12.5.

Notes

Player I can be stopped from getting any more; moreover, player II is motivated to stop I from getting more. If I chooses another strategy, he/she is gambling. If II also gambles, there is no telling what will happen. The minimax strategies are attractive in that they offer security. The appeal of security is a matter of personal taste.

If should be emphasized that the minimax strategy is essentially defensive, and when you use it, you often eliminate any chance of doing better.

Experimental studies show that people approach minimax strategies by "learning" during the game. They "learned" how to react effectively to the specific behavior of the experimenter, and adopt defensive strategies when meeting clever opponent or aggressive ones to exploit the others.

The weakest part of the theory is undoubtedly the assumption that a player should always act so as to maximize the average payoff. The justification for the assumption is that, in the long run, not only the average return but the actual return will be maximized. This is because any tricks or pure strategy will be recognized and exploited by the opponent. But if a game is played only once, ofter a strategy that maximizes the average return is not desirable, much less compelling.

In summary,
  1. Minimax strategy is secure but defensive, thus not always be the choice of people (depends on the level of the opponent).
  2. It relies on the concept of average payoff, which implicitly assumes repeated games. For game just goes once, it may not be suitable.
  3. The pre-requirement of zero-sum is strict and not always be the truth in real life. For this issue, refer to the next chapter of utility theory.

Some Thoughts

  1. Do we really need to eliminate dominated strategies? Maybe after solving the maxtrix, their corresponding probability equals to 0.
  2. The method may fail. Then what to do next?
  3. The definition of payoff matrix may be a sujective process.

The Two-Person, Zero-Sum Game with Equilibrium Points

Zero-sum means the players have diametrically opposed interests.

Two strategies are said to be in equilibrium (they come in pairs, one for each player) if neither player gains by changing strategy unilaterally. The outcome corresponding to this pair of strategies is defined as the equilibrium point, which is considered stable because a player unilaterally picking a new strategy is hurt by the change.

For two-person, zero-sum games, there may be more than one equilibrium point, but it there is, they will all have the same payoff.

How to find the equilibrium point

Theoretic method

If equilibrium points exist, they are easy to find. For a given payoff matrix (A's choice is represented as rows, while B's as columns):
  1. Since B would choose a strategy that yields the minimum value of any row A chooses, A should choose a strategy that yields the maximum of these minimum values; this value is called the maximin.
  2. Since A would choose a strategy that yields the maximum value of any column B chooses, B should choose the column that minimizes these maximum values; this value is called the minimax.
  3. If the minimax equals the maximin, the payoff is an equilibrium point and the corresponding strategies are an equilibrium strategy pair.
When an equilibrium point exists in a two-person, zero-sum game, it is called the solution. The reasons why equilibrium points are considered solutions are:
  1. By playing his/her equilibrium strategy, a player will get at least the value of the game.
  2. By playing his/her equilibrium strategy, an opponent can stop a player from getting any more than the value of the game.
  3. Since the game is zero-sum, a player's opponent is motivated to minimize the player's payoff.
In games with equilibrium points, payoffs that are not associated with either equilibrium strategy have no bearing on the outcome. That is, the change to these values will not change player's strategies.

Simplification with domination

It is often possible to simply a game by eliminating dominated strategies.

Strategy A dominates strategy B if a player's payoff with A is
  • always at lease as much as that of B (whatever other players do)
  • at lease some of the time actually better than strategy B.
If all strategies but one are dominated for each player, the equilibrium point(s) can be calculated.

If there is no equilibrium point, a mixed strategy is required. Refer to the next chapter.

Saturday, December 20, 2008

An Overview

The theory of games is a theory of decision making. While decision makers are trying to manipulate their environment, their environment is trying to manipulate them.

Statistical methodology

The first phase of a statistical investigation is the identification of the population together with the variables which will be measured.

A population is a totality of entities about which we hope to draw conclusions.

A property of a member of a population which varies from one individual to another is called a random variable.

Data can be classified by its level of measurement:
  • Nominal: items will be classified into categories.
  • Ordinal: categories which are ranked in some sort of logical order.
  • Metric: the quantity has a physical significance.
Data can also be classified by the continuity of the scale:
  • Continuous: can take any value within a certain range.
  • Discrete: there are gaps in the scale between allowable values.
A factor is an effect we can control by setting its level before any variables are measured. Notice that a factor is not a random variable as its value is completely within our control as part of the experiment design.

Each factor can be operative at two or more levels and we define a treatment to be a combination of specific levels of each factor present.

Each treatment defines a separate sample, a set of entities from a population. It is emphasized that the items in a sample must be homogeneous with respect to the characteristics we are studying. The fundamental assumption in a statistical analysis is that members of a sample are identical with each other except for that variability we are prepared to write off as being due to random unexplained variation.

The Law of Large Numbers states that the larger the size of sample, the better its average estimates the corresponding average of the population.

Most statistical techniques assume that the sample is randomly selected, and every single member of the population has an equal chance of being included in the sample. Individual data measurements must be statistically independent of each other and ideally should not interact at all.

Methods of analysis range from the calculation of summary statistics like averages and the drawing of diagrams like bar charts to more sophisticated techniques like analysis of variance and regression. Because the information content of the whole operation is being compressed into a diagram or a simple statement, the result can be like a woman's bikini - what it reveals is interesting but what it covers up is vital.

Thursday, February 22, 2007

Resize Images while Mouse Rollover

Gradual Image Resizing on Mouse Rollover

or, How To Do Google X Type Image Rollover Effects

or, have the same effect as dock in Mac for webpage.
(Refer to http://www.nsftools.com/tips/ImageResize.htm)

I also make a mirror for Google X at my department home page.

The source code is:


<script language=JavaScript>
/**
The JavaScript functions below will gradually enlarge or shrink an image
on the current page. I use this for mouseover effects, but there might be
some other interesting applications of it as well.

You can use these scripts in any way you'd like, just don't pretend like
you wrote them yourself.

version 1.0
March 17, 2005
Julian Robichaux, http://www.nsftools.com
*/

/**** adjust these two parameters to control how fast or slow
**** the images grow/shrink ****/
// how many milliseconds we should wait between resizing events
var resizeDelay = 10;
// how many pixels we should grow or shrink by each time we resize
var resizeIncrement = 5;

// this will hold information about the images we're dealing with
var imgCache = new Object();


/**
The getCacheTag function just creates a (hopefully) unique identifier for
each that we resize.
*/
function getCacheTag (imgElement) {
return imgElement.src + "~" + imgElement.offsetLeft + "~" + imgElement.offsetTop;
}


/**
We're using this as a class to hold information about the elements
that we're manipulating.
*/
function cachedImg (imgElement, increment) {
this.img = imgElement;
this.cacheTag = getCacheTag(imgElement);
this.originalSrc = imgElement.src;

var h = imgElement.height;
var w = imgElement.width;
this.originalHeight = h;
this.originalWidth = w;

increment = (!increment) ? resizeIncrement : increment;
this.heightIncrement = Math.ceil(Math.min(1, (h / w)) * increment);
this.widthIncrement = Math.ceil(Math.min(1, (w / h)) * increment);
}


/**
This is the function that should be called in the onMouseOver and onMouseOut
events of an element. For example:



The only required parameter is the first one (imgElement), which is a
reference to the element itself. If you're calling from onMousexxx,
you can just use "this" as the value.

The second parameter specifies how much larger or smaller we should resize
the image to, as a percentage of the original size. In the example above,
we want to resize it to be 150% larger. If this parameter is omitted, we'll
assume you want to resize the image to its original size (100%).

The third parameter can specify another image that should be used as the
image is being resized (it's common for "rollover images" to be similar but
slightly different or more colorful than the base images). If this parameter
is omitted, we'll just resize the existing image.
*/
function resizeImg (imgElement, percentChange, newImageURL) {
// convert the percentage (like 150) to an percentage value we can use
// for calculations (like 1.5)
var pct = (percentChange) ? percentChange / 100 : 1;

// if we've already resized this image, it will have a "cacheTag" attribute
// that should uniquely identify it. If the attribute is missing, create a
// cacheTag and add the attribute
var cacheTag = imgElement.getAttribute("cacheTag");
if (!cacheTag) {
cacheTag = getCacheTag(imgElement);
imgElement.setAttribute("cacheTag", cacheTag);
}

// look for this image in our image cache. If it's not there, create it.
// If it is there, update the percentage value.
var cacheVal = imgCache[cacheTag];
if (!cacheVal) {
imgCache[cacheTag] = new Array(new cachedImg(imgElement), pct);
} else {
cacheVal[1] = pct;
}

// if we're supposed to be using a rollover image, use it
if (newImageURL)
imgElement.src = newImageURL;

// start the resizing loop. It will continue to call itself over and over
// until the image has been resized to the proper value.
resizeImgLoop(cacheTag);
return true;
}


/**
This is the function that actually does all the resizing. It calls itself
repeatedly with setTimeout until the image is the right size.
*/
function resizeImgLoop (cacheTag) {
// get information about the image element from the image cache
var cacheVal = imgCache[cacheTag];
if (!cacheVal)
return false;

var cachedImageObj = cacheVal[0];
var imgElement = cachedImageObj.img;
var pct = cacheVal[1];
var plusMinus = (pct > 1) ? 1 : -1;
var hinc = plusMinus * cachedImageObj.heightIncrement;
var vinc = plusMinus * cachedImageObj.widthIncrement;
var startHeight = cachedImageObj.originalHeight;
var startWidth = cachedImageObj.originalWidth;

var currentHeight = imgElement.height;
var currentWidth = imgElement.width;
var endHeight = Math.round(startHeight * pct);
var endWidth = Math.round(startWidth * pct);

// if the image is already the right size, we can exit
if ( (currentHeight == endHeight) || (currentWidth == endWidth) )
return true;

// increase or decrease the height and width, making sure we don't get
// larger or smaller than the final size we're supposed to be
var newHeight = currentHeight + hinc;
var newWidth = currentWidth + vinc;
if (pct > 1) {
if ((newHeight >= endHeight) || (newWidth >= endWidth)) {
newHeight = endHeight;
newWidth = endWidth;
}
} else {
if ((newHeight <= endHeight) || (newWidth <= endWidth)) { newHeight = endHeight; newWidth = endWidth; } } // set the image element to the new height and width imgElement.height = newHeight; imgElement.width = newWidth; // if we've returned to the original image size, we can restore the // original image as well (because we may have been using a rollover // image in the original call to resizeImg) if ((newHeight == cachedImageObj.originalHeight) || (newWidth == cachedImageObj.originalwidth)) { imgElement.src = cachedImageObj.originalSrc; } // shrink or grow again in a few milliseconds setTimeout("resizeImgLoop('" + cacheTag + "')", resizeDelay); } System Tools on Ubuntu and Main Menu --> System.

Now just choose the software you want (maybe non-free) to install and make your life easier. See, it contains almost all common tools in Windows.

Capabilities

  1. Acrobat Reader (Adobe Acrobat Reader and plugin for Firefox 1.5)
  2. AMSN 0.95 (MSN client with webcam support)
  3. Amule (Latest version of a P2P file sharing client)
  4. Archiving Tools (Additional archiving tools (rar, unrar, ace, and 7zip))
  5. AUD-DVD codecs (NON-FREE Audio and DVD codecs) (Installation of this option is illegal in the United States of America)
  6. Avidemux (Video Editing Tool)
  7. Azureus (Installs Azureus bittorrent client)
  8. Backup and Restore (A graphical backup and restore solution for Ubuntu (GNOME))
  9. Beagle (A Mono-based search program)
  10. Bittornado (Bittorent Client)
  11. Boot-up Manager (Easy configuration of startup and shutdown scripts and services)
  12. Checkgmail (A nifty gmail checker)
  13. Ctrl-Alt-Del (This configures Ctrl-Alt-Del to Open Gnome System Monitor (GNOME ONLY))
  14. DCPP (Linux DC++ client)
  15. Debian Menu (Shows all installed applications on your system)
  16. Democracy Player (Internet TV platform)
  17. DVD Ripper (DVD ripper)
  18. Extra Fonts (Additional fonts and msttcorefonts)
  19. Flashplayer (Adobe Flash Player for FF)
  20. Frostwire (P2P file sharing client (GPL clone of Limewire))
  21. Gdesklets (eyecandy for Gnome)
  22. Gaim 2.0 beta3 (The latest version of a popular IM client compatible with YIM/MSN/AIM/Jabber etc)
  23. GFTP (FTP client for GNOME with ssh capability)
  24. Gizmo Project (VoIP phone)
  25. Gnomebaker (The best GTK2 CD/DVD burning software)
  26. GnomePPP (Graphical dialup connection tool (GNOME ONLY))
  27. GnuCash (Money management software for GNOME)
  28. Google Earth (Satellite Earth imagery application from Google)
  29. Google Picasa (Photo editing application from Google)
  30. iLinux (iLife Alternative (Banshee, F-Spot, Kino))
  31. Liferea (A RSS reader for GNOME)
  32. Listen Media Manager (Latest version of a new media manager and player for GNOME)
  33. Media Players (Totem-xine, VLC and Beep Media Player (with docklet))
  34. MPlayer & FF plugin (MPlayer and Firefox 1.5 plugin)
  35. Multimedia Codecs (Commonly needed audio and video codecs)
  36. Multimedia Editing (Audio (Audacity) Video (Kino) and ID3 Tag (Easytag) editors)
  37. Nautilus Scripts (Open Nautilus, and any file with gedit with a right click, as root (GNOME ONLY))
  38. NDISWrapper (A driver wrapper that allows you to use Windows driver for network cards)
  39. Network Manager (A program and menu applet that allows you to easily change networks)
  40. NVIDIA Driver (Installs NVIDIA drivers on select NVIDIA cards)
  41. Opera Browser (Opera Web Browser)
  42. OpenOffice Clipart (clipart in OpenOffice)
  43. Programming Tools (Anjuta (C/C++ IDE), Bluefish (HTML editor), Screem (web development), NVU (HTML editor)
  44. RealPlayer (RealPlayer)
  45. Rhythmbox (Latest version of Rhythmbox)
  46. Ripper and Tuner (Streamripper (rips Internet radio streams) and Streamtuner (Internet radio client))
  47. Security Suite (ClamAV AntiVirus and Firestarter Firewall)
  48. Skype (A free (as in free beer) Voice Over IP software)
  49. Slab (Novell's "Slab" menu used in SLED 10)
  50. SUN JAVA 1.5 JRE (Sun's version 1.5 JRE & The Firefox plugin)
  51. SUN JAVA 1.5 JDK (Sun's version 1.5 JDK (Most users DONT need this))
  52. Swiftfox Browser (optimized Firefox browser for your specific CPU)
  53. Swiftfox Plugins (Java, Flash, Acrobat, Mplayer, MS fonts)
  54. Thunderbird 1.5 (Email client)
  55. Wine (Installs Wine)
  56. XChat (a popular IRC client)


Friday, November 10, 2006

Make an MAC Outlook

Source: http://www.taimila.com/

Let's start with some basic concepts. Gnome desktop has three different themes, which you can change (System -> Preferences -> Theme -> Details). These are Controls, Window Border and Icons. Even only by changing them, you can get a very nice desktop. There are many themes available and you can find most of them at Gnome-look. You can of course use any theme you like, but in this guide we are making OSX look-a-like and we must select the best ones for our purpose.

Download the following themes from Gnome-look. The first one includes the theme for window decorator and for controls. And the second one has a lot of OSX style icons.

After you have downloaded these packages go to "System -> Preferences -> Theme". System menu can be found at the left upper corner of your screen. Select "Install Theme..." and browse to the folder where you just downloaded packages above. After the installation of both of them, select T-ish from theme list and OSX icons from icon list (details of theme). It's a good start, but why stop here!

I have only few icons on my desktop and they are pretty big as you can see from the screenshots. I use Innex icons theme on desktop icons. I also recommend you to download OS-L iconset even though it's for KDE. It still contains many nice icons which you can use in menus or in your application launchers. (This part is optional, because we already have a set of icons)

Gnome panel customizing

Let's begin with the bottom panel. Our aim is to have a panel which contains only application launchers.

The first step is to remove all the other elements from the panel. In default ubuntu installation there are Recycle bin, Taskbar, desktop switcher and show desktop -button. These are added later to the top panel so don't worry. You can remove these elements by clicking right mouse-button on them and selecting "Remove from panel" from pop-up menu. Now you have empty gray panel. Next click right mouse-button on the empty panel and select "Properties". Change the Size of the panel to 50 and remove all the ticks form the selectionboxes (See screenshot). Then change to Background tab and select "Solid color". Change the Color to white, if it's not already, and move "Style" slider like in this screenshot. Now the panel is ready. Next we just add icons (application launchers) to it. You can simply drag and drop the icons from the desktop. Another way is to click right mouse-button on the panel and select "Add to panel...". Select "Custom application launcher" from the window and fill Name, Command and select some beatiful icon. You can also write a short comment about the program, if you will. (See screenshot)

The Top panel is little more trickier than bottom panel. But I choose not to change it except adding some panels back.

One stop solution

Of course, we can download complete themes directly and install them. Then we can modify in "Theme Details" as we like. Now I'm using MacOS-X Aqua Theme from http://www.gnome-look.org/content/show.php?content=13548

Later on, we can change the thems or icons manuall at
~/.themes
~/.icons

PS: the following site aims to provide a more mac-like dock which is still in progress but promising: http://www.gnome-dock.org/trac

How to change icons manually

We should first look at the theme definition files in the folder ~/.themes/. To change the icons, we then goto the corresponding folder (name is specified in theme definition) in ~/.icons.

Now replace the unwanted icons in it can achieve the aim. However, we can get substituting sources from the following locatiosn:
  1. /usr/share/icons/
  2. /usr/share/pixmaps
  3. Internet of course


Thursday, November 09, 2006

Adding More Chinese Fonts

  • Get the following fonts from somewhere (c:\windows\fonts)
simsun.ttc --- 宋体和新宋体
tahoma.ttf --- tahoma字体
tahomabd.ttf --- tahoma字体的粗体形式
verdana.ttf --- verdana字体
verdanab.ttf --- verdana字体的粗体形式
verdanai.ttf --- verdana字体的斜体形式
verdanaz.ttf --- verdana字体的粗体+斜体形式
simfang.ttf --- 仿宋体
simhei.ttf --- 黑体
simkai.ttf --- 楷体

and
sudo cp * /usr/share/fonts/zh_CN/
  • Update font cache
cd zh_CN
sudo mkfontscale
sudo mkfontdir
sudo fc-cache

  • Modify the config file, replace the content of it:
gedit /etc/fonts/language-selector.conf





serif



Bitstream Vera Serif
SimSun
DejaVu Serif
AR PL ShanHeiSun Uni
AR PL ZenKai Uni







sans-serif



Bitstream Vera Sans
Simsun
DejaVu Sans
AR PL ShanHeiSun Uni
AR PL ZenKai Uni








monospace



Bitstream Vera Sans Mono
Simsun
DejaVu Sans Mono
AR PL ShanHeiSun Uni
AR PL ZenKai Uni









SimSun
Song
Sun
Kai
Ming


100




180





true







SimSun
宋体
宋体-18030
Song
Sun
Kai
Ming
黑体
新宋体
新宋体-18030
楷体_GB2312
仿宋_GB2312
隶体
SimSun-18030
SimHei
NSimSun
NSimSun-18030
KaiTi_GB2312
FangSong_GB2312
LiSu




false





0





true





false





true





12




24




false





  • Restart X Windows
PS: can run "fontconfig" command to check and set fonts.

Upgrading to Higher Version of Ubuntu

Source: https://help.ubuntu.com/community/EdgyUpgrades

Upgrading using Update Manager

If you want to upgrade from 6.06 LTS to 6.10, run the following command (either via ALT-F2 or a terminal):

gksu "update-manager -c" 

The -c switch instructs Update Manager to look for upgrades. By default, the Ubuntu 6.06 LTS release will not offer that automatically because of its long support cycle and high stability.

If you have a working network connection, it should then inform you about a new release and offer to upgrade your system.

If you have the Edgy Alternate Install CD (not the Desktop CD), you can save bandwidth by using:

gksu "sh /cdrom/cdromupgrade"


Wednesday, November 08, 2006

File Sharing in LAN

How to change computer Domain/Workgroup

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf
  • Find this line
             ...
workgroup = MSHOME
...
  • Replace with the following line
             workgroup = new_domain_or_workgroup
  • Save the edited file
             sudo testparm
sudo /etc/init.d/samba restart

How to share folders the easy way

  • Right click on folder -> Share folder
  • Shared folder -> Share with: Select "SMB"
  • Share properties -> Name: Specify the share name

How to browse network computers

  • Places -> Network Servers

How to access network folders without mounting

Assumed that network connections have been configured properly
Network computer's IP: 192.168.0.1
Shared folder's name: linux
  • Press 'Alt+F2' (Run Application...) and enter:
smb://192.168.0.1/linux

How to mount/unmount network folders manually, and allow all users to read/write

Assumed that network connections have been configured properly
Network computer's IP: 192.168.0.1
Network computer's Username: myusername
Network computer's Password: mypassword
Shared folder's name: linux
Local mount folder: /media/sharename
  • To mount network folder
      sudo mkdir /media/sharename
sudo mount //192.168.0.1/linux /media/sharename/ -o username=myusername,password=mypassword,dmask=777,fmask=777
  • To unmount network folder
      sudo umount /media/sharename/

How to mount network folders on boot-up, and allow all users to read/write

sudo mkdir /media/sharename
gksudo gedit /root/.smbcredentials
  • Insert the following lines into the new file
      username=myusername
password=mypassword
  • Save the edited file
     sudo chmod 700 /root/.smbcredentials
sudo cp /etc/fstab /etc/fstab_backup
gksudo gedit /etc/fstab
  • Append the following line at the end of file
     //192.168.0.1/linux    /media/sharename smbfs  credentials=/root/.smbcredentials,dmask=777,fmask=777  0    0
  • Save the edited file

Install Sun JDK

1. Search for Sun JDK in package manager, and then install it.

2. Try running the command

sudo update-alternatives --config java

and choose a default java of your liking.

3. Set Sun's JVM as default Java version:

sudo update-java-alternatives -s java-1.5.0-sun

4. Edit /etc/jvm and move /usr/lib/jvm/java-1.5.0-sun to the top of JVMs offered:

sudo gedit /etc/jvm

5. Configure the Eclipse.
There is a bug right now were Eclipse ignores Ubuntu's java-common settings and uses its own (bug 45347). To work around the bug, you need to edit Eclipse's java_home file:

sudo -b gedit /etc/eclipse/java_home

and add

/usr/lib/jvm/java-1.5.0-sun

to the top of the file.

If this still not work, just add the new JRE at Eclipse Global Settings.

HowTo: Speed up ubuntu boot process

Source: http://doc.gwos.org/index.php/Speed_up_boot

The following tool gives you a way to easily configure the boot process and runlevel configuration, but it's not necessary if you want to do it manually by linking/unlinking the files... Its up to you.

sudo apt-get update
sudo apt-get install sysv-rc-conf


Now let's fire it up by

sudo sysv-rc-conf

and analyze each service one by one.

Throw a little bit of runlevel knowledge here before we start messing them up.... All the boot processes are executed in sequence as following:

  • runlevel S: the first runlevel in boot process. /etc/init.d/rcS script will be invoked to start and all the processes underneath /etc/rcS.d will be executed.
  • runlevel 1: The single user mode. All processes underneath /etc/rc1.d will be executed.
  • runlevels 2, 3, 4 and 5: In Debian systems the multi-user environment may or may not include GUI. The same processes under each of the corresponding directories will be run. **Note** This is different than RedHat, SuSE, and other RPM-based systems.
  • runlevel 0: computer shutdown.
  • runlevel 6: computer reboot.

Okay, back to sysv-rc-conf:

1. acpi-support - You'd better leave it on "X" at S runlevel.

2. acpid - The acpi daemon. These two are for power management, quite important for laptop and desktop computers, so leave them on.

3. alsa - If you use alsa sound subsystem, yes leave it on.

4. alsa-utils - On my system, this service supercedes the alsa, so I turn off the alsa and turn this on at S level. **Note**, I mean "turn off" is to remove all "X" at all runlevels. If you don't have it on your system, no problem. Just keep going.

5. anacron - A cron subsystem that executes any cron jobs not being executed when the time is on. Most likely you've probably turned your computer off when a certain cron job time is ready. For example, if updatedb is scheduled at 2am everyday, but at that moment your computer is off, then if the anacron service is on, it will try to catch up that updatedb cron... I turn it off cause it didn't turn my laptop off very often, but its totally up to you for this one.

6. apmd - This is the one that confused me a quite bit. I have acpid on already and what's the benefits of having apmd on too? If you computer is not that old which can't even support acpi, then you may try to turn this off. I did anyway.

7. atd - like cron, a job scheduler. I turned it off.

8. binfmt-support - Kernel supports other format of binary files. I left it on.

9. bluez-utiles - I turned it off. I don't have any bluetooth devices.

10. bootlogd - Leave it on.

11. cron - Leave it on.

12. cupsys - subsystem to manager your printer. I don't have so I turned it off, but if you do, just leave it on.

13. dbus - Message bus system. Very important, leave it on.

14. dns-clean - Mainly for cleaning up the dns info when using dial-up connection. I don't use dial up, so I turn it off.

15. evms - Enterprise Volumn Management system. I turned it off.

16. fetchmail - A mail receving daemon. I turned it off.

17. gdm - The gnome desktop manager. I turned it off anyway since I get use to boot to console first. This is up to you if you want to boot directly to GUI.

18. gdomap - Actually I have no idea why this one should on. I didn't see any other systems have this daemon, so I turned it off and I don't feel I lose anything. Any benefits to have it on a loptop or desktop?

19. gpm - Mouse support for console. If you feel you'd better have a mouse on console, go turn it on at runlevel 1 and 2. That's all you need.

20. halt - Don't change it.

21. hdparm - tuning harddisk script. I removed the 2, 3, 4, 5 runlevel but add it to S runlevel. I feel that opening DMA, 32bit I/O, etc eariler will benefit the rest of the processes. Also I changed the original script to a very simple one that I made myself. I feel useless to put all those redundant checks if I know what I am doing. The configuration file is /etc/hdparm.conf.

22. hibernate - If your system support hibernate, leave it on. Otherwise, its useless for you.

23. hotkey-setup - This daemon setup some hotkey mappings for Laptop. Manufacturers supported are: HP, Acer, ASUS, Sony, Dell, and IBM. If you have a laptop in those brands, you can leave it on, otherwise, this might not have any benefits for you.

24. hotplug and hotplug-net #activating hotplug subsystems takes time. I'd consider to turn them off. I did some changes in my /etc/network/interfaces file. Instead of mapping my wireless card during hotplug process, I set it up to auto. So I can turn them off. I've tested even I turned them off, ubuntu can still detect my usb driver, my digital camera, etc. So I think its pretty safe to turn them off. **Note** If you find your sound card doesn't work after turning hotplug service off, you can turn it back. Or edit /etc/modules file to add your sound card's driver module. Tested out the later one is faster.

25. hplip - HP printing and Image subsystem. I turned it off.

26. ifrename - network interface rename script. Sounds pretty neat but I turned it off. Mainly for managing multiple network interfaces names. Since I have a wireless card and an ethernet card, they all assigned eth0 and ath0 from kernel, so its not really useful for me.

27. ifupdown and ifupdown-clean - Leave it on. They are network interfaces activation scripts for the boot time.

28. inetd or inetd.real - take a look your /etc/inetd.conf file and comment out any services that you don't need. If there aren't any services there, then it's very safe to turn them off.

29. klogd - Leave it on.

30. linux-restricted-modules-common - You need to see if you really have any restricted modules loaded on your system. Since I need madwifi ath_pci module, so I left it on. The restricted modules can be found from /lib/linux-restricted-modules. If you find that you are not using any of the restricted modules, then its ok to turn it off.

31. lvm - I don't use it so I turned it off. Leave it on if you *DO* have lvm.

32. makedev - Leave it on.

33. mdadm - Raid management tool. I don't use it so I turned it off.

34. module-init-tools - Load extra modules from /etc/modules file. You can investigate your /etc/modules file and see if there is any modules that you don't need. Normally, this is turned on.

35. networking - bring up network interfaces and config dns info during boot time by scaning /etc/network/interfaces file. Leave it on.

36. ntpdate - Sync time with the ubuntu time server. I don't need it on boot time so I turned it off.

37. nvidia-kernel - I compiled the nvidia driver by myself, so its useless for me now. If you use the ubuntu nvidia driver from the restrict modules, just leave it on.

38. pcmcia - Active pcmcia device. I changed it to start on S runlevel instead of on each 2,3,4,5 cause I feel it's better to have hardware device ready at first. Also, useless if you are using desktop which doesn't have pcmcia card. So in that case, turn it off please.

39. portmap - daemon for managing services like nis, nfs, etc. If your laptop or desktop is a pure client, then turn it off.

40. powernowd - client to manage cpufreq. Mainly for laptops that support CPU speed stepping technology. Normally, you should leave it on if you are configuring a laptop, but for desktop, it might be useless.

41. ppp and ppp-dns - Useless to me. I don't have dial-up.

42. readahead - **Thanks mr_pouit!** It seems readahead is a kind of "preloader". It loads at startup some libs on memory, so that some programs will start faster. But it increases startup time for about 3-4 seconds. So, you can keep it... or not . **update** I tested and I just didn't feel difference loading programs. So I decided to turn it off. If you have a reason to keep it on, please do so.

43. reboot - Don't change it.

44. resolvconfresolvconf - Automatically configuring DNS info according to your network status. I left it on.

45. rmnologin - Remove nologin if it finds it. It wouldn't happen on my laptop, so I got rid of it.

46. rsync - rsync daemon. I don't use it on my laptop, so turned it off.

47. sendsigs - send signals during reboot or shutdown. Leave it as it is.

48. single - Active single user mode. Leave it as it is.

49. ssh - ssh daemon. I need this so I turned it on.

50. stop-bootlogd - stop bootlogd from 2,3,4,5 runlevel. Leave it as it is.

51. sudo - check sudo status. I don't see any good to run it every time on a laptop or desktop client, so I turned it off.

52. sysklogd - Leave it as it is.

53. udev and udev-mab - Userspace dev filesystem. Good stuff, I left them on.

54. umountfs - Leave it as it is.

55. urandom - Random number generator. Might not useful but I left it on.

56. usplash - Well, if you really want to see the nice boot up screen, leave it as it is. I just turned it off anyway. If you want to turn it off, you also need to edit /boot/grub/menu. lst file to comment out the splashimage line and get rid of the splash kernel boot option.

57. vbesave - video card BIOS configuration tool. It's able to save your video card status. I left it on.

58. xorg-common - setup X server ICE socket. I moved it from starting at runlevel S to runlevel 2,3,4,5. Since I don't need this if I boot to single user mode. This way it wouldn't occupy time during the initial booting.

III. Alter the /etc/inittab file

file.pngCode:

vi /etc/inittab


then comment out tty4,tty5, and tty6. Just leave tty1, tty2, and tty3. Three vts should be enough for a laptop or desktop user. Save the file.

IV. Ok, now, we can reboot our box and see how it goes. From what I've tested, before I got tons of services stopped, the whole process is about 85 secs to 90 secs to boot to console. (At that time, I also has samba and nfs services turned on which I shouldn't. Apparently, I turned them off too). After this change, the whole boot up process took about 50 secs. I have a P4M 1.8G CPU laptop. Some of the high-end desktops or laptops should take even less time.

    • UPDATE**: speed up/clean system reboot or shutdown process.

1. start sysv-rc-conf by issuing:

file.pngCode:

sudo sysv-rc-conf


2. ok, open your eyes and look very carefully for those SERVICES DO NOT HAVE "X" ON ALL RUNLEVELS (All runlevel means 1,2,3,4,5,6, and S), write them down one by one. Don't make mistakes here. Double check after you've done.

3. quit sysv-rc-conf.

4.

file.pngCode:

cd /etc/rc0.d


- This is for the system shutdown process.

5. ok, now,

file.pngCode:

ls K*


will list all links starting from UPPERCASE letter "K". Compare with your list, change each of the filename containing the service name in your list to start from a lowercase "k". For example, in your list, you have ppp service (which means ppp is turned off at all runlevels), then you can do like:

file.pngCode:

sudo mv K00ppp k00ppp


You just change the UPPERCASE K to lowercase k, keep the rest the same. Do this on all of the services in your list.

6.

file.pngCode:

cd ../rc6.d


- This is for the system reboot process.

7. ok, you should see similar things here too. So do the same thing here as you did on rc0.d.

8. Now, you reboot and shutdown process should be cleaned up and faster.

The explanation for what you did is pretty simple. The /etc/rc and /etc/rcS scripts run start on each link on each runlevel by scanning if it is starting with a UPPERCASE "S" and run stop on each by scanning if it is starting with a UPPERCASE "K". So for reboot and shutdown runlevels, the most thing we care is the "K" links cause for those services not running on all runlevels, it's just not needed to stop them. They are not running at all. If some day you want to turn some of the services back on, just change the lowercase "k" to UPPERCASE "K". That's all.

Anyway, it is not intended to work on servers, but I did try on one of my servers has 2.7G P4 and 1.5G mem. It brought the boot process down to 31 secs. I calc'ed it with my watch. Besides, this is with my ftp server and nfs server started on boot time.




Cleaning up all those unnecessary junk files

1) Tip #1 - Getting rid of Residual Config packages
Residual Config packages are usually dependency packages that are
left behind after you uninstall a package from your machine. To use this
feature, go to System > Administration > Synaptic Package Manager.
On the bottom left hand corner of the window, click the Status button.
In the list above the Sections, Status, Search, and Custom buttons, Click
on the "Residual config" text. To get rid of these pests, click on the
box to the left of the package name and select "Mark for Complete Removal".
After you have done that for all of the Residual Config packages, click
"Apply".
2) Tip #2 - Getting rid of partial packages
in the Terminal, key in the following command:
sudo apt-get autoclean
3) Tip #3 - Getting rid of "orphaned" packages
Download the "deborphan" package found in Synaptic Package Manager. Then:
sudo deborphan | xargs sudo apt-get -y remove --purge