Thursday, September 11, 2008
Ubuntu: adding more space to root partition
I had given a mare 2.5 gigs of space to my gusty when I installed it and over the time it proved to be pretty miser :) So, I decided to add more space to it. I went to windows vista right click on my computer->properties->manage->disk to get disk management snapshot. From there I shrank my D: drive 4 gigs. Then comes the question of how to add this 4 gigs to my ubuntu root drive. If we boot to ubuntu then we cannot do any partition task as the root drive is mounted. So, we need a live CD. Every ubuntu CD is live, so if u got one then just boot from it and it will start a live session. From there, start gParted (the partitioning tool of ubuntu system->administration->gparted) and if the unallocated space is beside the ubuntu root partition you can just resize the root partition and grow it to include the unallocated storage. But here I faced another problem. My D: drive was a primary partition and so the unallocated space resulted from the shrinking of D: drive was just after that. But my linux installation is insize an extended partition. And, sorrowfully, I can see from gparted that the extended partition is locked and I cannot resize it due to the fact that the swap partition which is in extended partition is in use and locked. To recover, I right click on swap partition and unmount (unswap) it, so my extended partition is no longer locked. Then I resized the extended partition to include the unallocated space just preceeding it, and then resize the root partition of ubuntu to include the new unallocated space that I included inside the extended partition. And that was it!! Just apply the changes, and you are done :)
Friday, July 18, 2008
IPv6 Workshop-DNS
In the top of DNS tree there are 13 root servers. Why 13? Because, UDP packets, which is used for DNS, have a header size that can only accomodate 13 entries.
Root servers are called using A, B, C.........M. And some roots are also replicated.
Bangladesh has a replica of F-root.
Underneath root there are top level domains.
Open recursive name servers finds answers for any query coming from anyone. But, the case should be, it should only find answers for his clients. Due to this open recursiveness, there are many DDoS attacks. Reverse DNS is used for security purposes. Many secured servers will not comply to your request if you do not resolve to a reverse DNS query.
In IPv4 for mapping we use 'A' records in zone files, such as
www. A 10.23.2.1
mail. A 10.23.3.1
In IPv6 we use 'quad A' records, such as
www. AAAA 2001:AA::1
A records and quad A records can be mixed in the same zone file.
If zone files have wrong entries about name servers, it is called lame delegation.
For reverse zone records, there is a top level domain named 'arpa', and under that 'in-addr' for inverse address. And then, underneath that we have /8, /16, /24 and then /32 quads in hierarchical order. So while reading we need to read from the bottom, such as, 2.23.10.in-addr.arpa
The catch is, the DNS system is arranged at the classful boundary, but if we have a CIDR addressign like /21 then how can we resolve that? Then we need to go to the nearest classful boundary that we own. For a /21 address, we need to create reverse zone files for all the block of /24 that we own, i.e., all the 8 /24 blocks that are in our /21 domain. And this kind of records are called pointer records or 'ptr' because they point to actual names. So, at the beginning of the reverse zone file, we put the origin of our site which includes everything upto the network part. For example: origin 2.23.10.in-addr.arpa, and then we start putting the seperate machine addresses in different lines. And the lines contain only the machine addresses. For example:
1 PTR www.sumanta.com
2 PTR mail.sumanta.com
Remember, if we dont put any dot after the digits in the left column, DNS assumes that it is not a fully qualified domain name and it appends the origin after it. But if we put dot after it, then the DNS assumes it as a FQDN and doesn't put the origin after it.
Glue records are the records in my name server where I put the name server entries of my own subdomains. For example, if I am sumanta.com and my customer is computing.sumanta.com, then I should have a record in my zone file pointing to the ns server of computing.sumanta.com
Reverse for CIDR addresses:
For CIDR address such as 202.159.0/26 where you cannot keep zone files for any classful boundaries which is lower than the actual classless boundary we use a different trick. They use something like a range. In DNS conf file, the ns server is defined as:
0-63 NS ns.computing.sumanta.com
and in reverse zone files we have records like
$origin 0-63.0.159.202.in-addr.arpa
1 PTR www.computing.sumanta.com
Now, as we didn't put any dot after the left column digit, so the DNS engine will derive the address as 1.0-63.0.159.202.in-addr.arpa, but that is not what we want, we dont want the 0-63 part in the address. That's why we use another trick called CNAME. CNAME is used for synonyms. If we put something like
1.0-63 CNAME 1
then the erroneous 1.0-63 part will be replaced by only 1, which is correct.
IPv6
For IPv6 the hierarchy is root->arpa->ip6->ip6 address divided at every hex boundary
So, at the reverse zone file, we have to write something like 1.0.0.0.0.0E.F.0.0.A.2.2.so on.ip6.arpa PTR www.sumanta.com
But fortunately, we can use the $origin and write all the common part only once and then just write the last part at the PTR records.
Use "DIG" for checking the configuration of the DNS servers.
Root servers are called using A, B, C.........M. And some roots are also replicated.
Bangladesh has a replica of F-root.
Underneath root there are top level domains.
Open recursive name servers finds answers for any query coming from anyone. But, the case should be, it should only find answers for his clients. Due to this open recursiveness, there are many DDoS attacks. Reverse DNS is used for security purposes. Many secured servers will not comply to your request if you do not resolve to a reverse DNS query.
In IPv4 for mapping we use 'A' records in zone files, such as
www. A 10.23.2.1
mail. A 10.23.3.1
In IPv6 we use 'quad A' records, such as
www. AAAA 2001:AA::1
A records and quad A records can be mixed in the same zone file.
If zone files have wrong entries about name servers, it is called lame delegation.
For reverse zone records, there is a top level domain named 'arpa', and under that 'in-addr' for inverse address. And then, underneath that we have /8, /16, /24 and then /32 quads in hierarchical order. So while reading we need to read from the bottom, such as, 2.23.10.in-addr.arpa
The catch is, the DNS system is arranged at the classful boundary, but if we have a CIDR addressign like /21 then how can we resolve that? Then we need to go to the nearest classful boundary that we own. For a /21 address, we need to create reverse zone files for all the block of /24 that we own, i.e., all the 8 /24 blocks that are in our /21 domain. And this kind of records are called pointer records or 'ptr' because they point to actual names. So, at the beginning of the reverse zone file, we put the origin of our site which includes everything upto the network part. For example: origin 2.23.10.in-addr.arpa, and then we start putting the seperate machine addresses in different lines. And the lines contain only the machine addresses. For example:
1 PTR www.sumanta.com
2 PTR mail.sumanta.com
Remember, if we dont put any dot after the digits in the left column, DNS assumes that it is not a fully qualified domain name and it appends the origin after it. But if we put dot after it, then the DNS assumes it as a FQDN and doesn't put the origin after it.
Glue records are the records in my name server where I put the name server entries of my own subdomains. For example, if I am sumanta.com and my customer is computing.sumanta.com, then I should have a record in my zone file pointing to the ns server of computing.sumanta.com
Reverse for CIDR addresses:
For CIDR address such as 202.159.0/26 where you cannot keep zone files for any classful boundaries which is lower than the actual classless boundary we use a different trick. They use something like a range. In DNS conf file, the ns server is defined as:
0-63 NS ns.computing.sumanta.com
and in reverse zone files we have records like
$origin 0-63.0.159.202.in-addr.arpa
1 PTR www.computing.sumanta.com
Now, as we didn't put any dot after the left column digit, so the DNS engine will derive the address as 1.0-63.0.159.202.in-addr.arpa, but that is not what we want, we dont want the 0-63 part in the address. That's why we use another trick called CNAME. CNAME is used for synonyms. If we put something like
1.0-63 CNAME 1
then the erroneous 1.0-63 part will be replaced by only 1, which is correct.
IPv6
For IPv6 the hierarchy is root->arpa->ip6->ip6 address divided at every hex boundary
So, at the reverse zone file, we have to write something like 1.0.0.0.0.0E.F.0.0.A.2.2.so on.ip6.arpa PTR www.sumanta.com
But fortunately, we can use the $origin and write all the common part only once and then just write the last part at the PTR records.
Use "DIG" for checking the configuration of the DNS servers.
Saturday, May 3, 2008
Setting tab stops for equation writing in scientific papers
While writing equations giving equation number at the right side of the column is often a problem. Also while writing the table of content, its a problem to place the page number in the right side. Often we start pressing arbitrary number of tabs and spaces to make it happen or insert table or some other clumsy things. There is a better way in MS word to do this. It is called tab stop. Setting a center tab stop you can instruct the word process or stop at the center each time you press a tab from the beginning of the line. On the other hand, if you set a right tab stop also, then you can press another tab to go to the right end of the line. For doing this, do the following:
- Go to the line you want to format
- In MS word 2007 press the little button at the right botton corner of the "paragraph" ribbon. There will be a new window in which a button named "Tab.." will be in the botton left corner. Press that
- Tab window appears. Now you have to create two tabs except for the default one. In the "tab stop position" text field write in centimeters the (total length of your line) / 2. To know the total length of your horizontal line check the horizontal ruler.
- Then in the "alignment" section select the center radio button and press "set".
- Follow the similar steps for the right tab stop, but in this case write the value of extreme right end of your horizontal rular in the "tab stop position" text field and selct the right radio button and press set.
- So you are ready now. Press OK and go out of the window. Just press tab and you can see your text are moving very elegently.
Good luck!!
Labels:
equation number,
ms word,
right alighment,
scientific paper,
tab stop
Sunday, April 27, 2008
Ubuntu: Disable touchpad while typing
I think one of the most annoying incident while typing in a laptop is the have the mouse cursor do all kind of wired thing, such as sending your typing cursor away, erasing things that you dont want to erase and so many more....
In ubuntu you can disable the touchpad while you are typing, and just the moment you stop typing, it will be enabled again autometically. The original post is here.
I am rewriting it for your advantage:
Procedure:
1. Turn on SHMCONFIG
A. Open a Terminal. Applications -> Accessories -> Terminal
B. Type sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_synbackup
Believe me, it works like charm, and life is much more easy and disturbance free after doing it. :) enjoy
In ubuntu you can disable the touchpad while you are typing, and just the moment you stop typing, it will be enabled again autometically. The original post is here.
I am rewriting it for your advantage:
Procedure:
1. Turn on SHMCONFIG
A. Open a Terminal. Applications -> Accessories -> Terminal
B. Type sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_synbackup
C. Type gksudo gedit /etc/X11/xorg.conf Enter your password if it prompts you.
D. Search for a section that looks like this:
G. Write these commands down just in case this screws up your window system: sudo cp /etc/X11/xorg.conf_synbackup /etc/X11/xorg.conf and sudo killall gdm and sudo gdm
H. This next step will restart your window system, so save any work and close any open applications. Press: Ctrl-Alt-Backspace. This should take you back to your login screen. If it does not, press Ctrl-Alt-F1 and login at the terminal window. After logging in, type the commands that you wrote down from step F in order hitting return after each command.
I. If your login screen came up the first time, continue on to part 2, if not, look over waht you did carefully and see if you can spot any mistakes.
2. Add the Startup Command
A. Open the sessions manager: System -> Preferences -> Sessions
B. Click the far right tab labeled Startup Programs
C. Click the Add button
D. Type in the following: syndaemon -i 1 -d
E. Hit ok then hit close
Congratualations, you are done! Note that this will not take effect until Gnome is restarted or you type the command from 2D in a terminal window. You can restart Gnome with the Ctrl-Alt-Backspace trick (make sure to save everything first!) or you can open a terminal by going to Applications -> Accessories -> Terminal.
And for your information, also the man page of the daemon syndaemon:
D. Search for a section that looks like this:
Section "InputDevice"E. Add a line above the End Section line and put this into it:
Identifier "Synaptics Touchpad"
...
End Section
Option "SHMConfig" "on"F. Save the file and close gedit and the terminal window
G. Write these commands down just in case this screws up your window system: sudo cp /etc/X11/xorg.conf_synbackup /etc/X11/xorg.conf and sudo killall gdm and sudo gdm
H. This next step will restart your window system, so save any work and close any open applications. Press: Ctrl-Alt-Backspace. This should take you back to your login screen. If it does not, press Ctrl-Alt-F1 and login at the terminal window. After logging in, type the commands that you wrote down from step F in order hitting return after each command.
I. If your login screen came up the first time, continue on to part 2, if not, look over waht you did carefully and see if you can spot any mistakes.
2. Add the Startup Command
A. Open the sessions manager: System -> Preferences -> Sessions
B. Click the far right tab labeled Startup Programs
C. Click the Add button
D. Type in the following: syndaemon -i 1 -d
E. Hit ok then hit close
Congratualations, you are done! Note that this will not take effect until Gnome is restarted or you type the command from 2D in a terminal window. You can restart Gnome with the Ctrl-Alt-Backspace trick (make sure to save everything first!) or you can open a terminal by going to Applications -> Accessories -> Terminal.
And for your information, also the man page of the daemon syndaemon:
OPTIONS
-i
How many seconds to wait after the last key press before
enabling the touchpad. (default is 2.0s).
-d Start as a daemon, ie in the background.
-p
Create a pid file with the specified filename. A pid file will
only be created if the program is started in daemon mode.
-t Only disable tapping and scrolling, not mouse movements, in
response to keyboard activity.
-k Ignore modifier keys when monitoring keyboard activity.
-K Like -k but also ignore Modifier+Key combos.
Believe me, it works like charm, and life is much more easy and disturbance free after doing it. :) enjoy
Making Ubuntu ready for C programming
Well, I know Linux has a hell lot of editors to do C programming. To be precise, all the editors support context highlighting etc. But I needed something like Java IDE, so that I can run by pressing the Play button :)
So, I decided why not convert the Netbeans IDE that I have here. So just installed a plugin in netbeans, only 4 megs, and Netbeans is ready to code in C/C++.
Go to, tools->plugins->available plugins and check c/c++ and install. Restart the IDE and you are ready to go. It will use the GCC available in Ubuntu.
But, wait, you are not done yet. Ubuntu is a funny linux. It has gcc installed in a funny way. Guess what!! it doesn't have any libraries installed :D !!! Holly cow....no stdio, no stdlib....
So, just do one thing, open synaptics and install "build-essentials". Or go to terminal and run "apt-get install build-essentials" and you will have all the libraries installed.
So, I decided why not convert the Netbeans IDE that I have here. So just installed a plugin in netbeans, only 4 megs, and Netbeans is ready to code in C/C++.
Go to, tools->plugins->available plugins and check c/c++ and install. Restart the IDE and you are ready to go. It will use the GCC available in Ubuntu.
But, wait, you are not done yet. Ubuntu is a funny linux. It has gcc installed in a funny way. Guess what!! it doesn't have any libraries installed :D !!! Holly cow....no stdio, no stdlib....
So, just do one thing, open synaptics and install "build-essentials". Or go to terminal and run "apt-get install build-essentials" and you will have all the libraries installed.
Sunday, April 6, 2008
Neural Network: Remove confusions
I was really in a dillema on how to design an ANN. I know enough theory (at least gained by browsing and everything) but all of them where how it functions and how the structure is done. But none on how can I specifically design a NN for a specific function. At last, I found a quite good post (tutorial) which is written is really simple language and may help you.
http://www.ai-junkie.com/ann/evolved/nnt1.html
Just some confusions that I have removed while reading this tutorial are:
When do we need a hidden layer?
We need a hidden layer whenever out output space is not linear (like the XOR function). Simple, eh!!
Just how many input nodes do I need?
Input nodes depend on the number of different data you have to feed to the neural net. If you have a matrix of 9 cells and need to feed the matrix to the NN then you will need 9 input nodes. But it is also possible to feed the input as binary combinations. If I want to feed a specific locaiton to the NN from a set of 64 locations then probably a input set of 6 nodes will be enough (2^6 = 64).
How can we get the output?
The output is provided by the output layer of neurons. At each neuron there is a activation function, which takes the weighted sum of inputs and produces an output. This output can be binary, in case of a threshold activation function, or it can be continuous, in case of a sigmoid function.
What is a Bias?
As we know, for a simple Neuron the input is the summation of the input values multiplied by the weight and the output depends on whether this summation is greater than the threshold or not. That is:
x1w1 + x2w2 + ...... + xnwn >= t
If we bring the threshold value on the LHS then the equation becomes:
x1w1 + x2w2 + ...... + xnwn - t >= 0
=>x1w1 + x2w2 + ...... + xnwn + (-1)t >= 0
So, as we can see we can treat t also as an input and its weight is always -1. In this way, the threshold value will also evolve with the network and we dont have to think about it. Another advantage is that even if all the inputs are zero, because of the bias value (t) the output will be something, it will not be zero forever.
How does the NN learn or adapt?
The learning is based on the difference between the actual output and the output of the NN. This error is fed to the layers to correct the weight of the input so that the new output of the node is better than the previous one.
Learning can be done by various methods. Two of them are backpropagation and Genetic algorithm. When using backpropagation the error amount is fed back to the layers of the NN so that the weights and the bias of that layer is modified accordingly.
How can we decide on the number of neurons in the layers?
This is what seemed the most perplexing thing while designing a NN. Its natural that the input and output would be directly proportional to the number of input and the number of output we need, but what about the hidden layer? How many hidden layers do we need and how many neurons per hidden layer?
Well, it seems that one hidded layer is what we need. Almost all the jobs can be done using one hidded layer. And in case of number of neurons, I dont know :) They say that you are going to build a feel of it. There are no hard and fast rule of this. Too few neurons will make your result scratchy. And too many will take longer time and rather fune tune to the training data too much. That means, networks with too many neurons will also adapt to the noise data so much that it will be difficul to generalize it. An excellent resource would be:
http://www.dtreg.com/mlfn.htm
ANN with Genetic Algorithm:
If ANN is used with GA then the learning process is done by GA. The initial weight is fed to the GA along with the fitness function of each member of population. The neural network will evaluate the output of the network and increate or decrease the fitness value of the cromosome accordingly. After some time a new generation is created and the GA is called. The GA will then decide according to the fitness value and generate a new generation. The new generation of population with the new weights are then again fed to the neural nework and the loop continues.
For a Good introduction please refer to:
http://www.ai-junkie.com/ann/evolved/nnt1.html
http://www.ai-junkie.com/ann/evolved/nnt1.html
Just some confusions that I have removed while reading this tutorial are:
When do we need a hidden layer?
We need a hidden layer whenever out output space is not linear (like the XOR function). Simple, eh!!
Just how many input nodes do I need?
Input nodes depend on the number of different data you have to feed to the neural net. If you have a matrix of 9 cells and need to feed the matrix to the NN then you will need 9 input nodes. But it is also possible to feed the input as binary combinations. If I want to feed a specific locaiton to the NN from a set of 64 locations then probably a input set of 6 nodes will be enough (2^6 = 64).
How can we get the output?
The output is provided by the output layer of neurons. At each neuron there is a activation function, which takes the weighted sum of inputs and produces an output. This output can be binary, in case of a threshold activation function, or it can be continuous, in case of a sigmoid function.
What is a Bias?
As we know, for a simple Neuron the input is the summation of the input values multiplied by the weight and the output depends on whether this summation is greater than the threshold or not. That is:
x1w1 + x2w2 + ...... + xnwn >= t
If we bring the threshold value on the LHS then the equation becomes:
x1w1 + x2w2 + ...... + xnwn - t >= 0
=>x1w1 + x2w2 + ...... + xnwn + (-1)t >= 0
So, as we can see we can treat t also as an input and its weight is always -1. In this way, the threshold value will also evolve with the network and we dont have to think about it. Another advantage is that even if all the inputs are zero, because of the bias value (t) the output will be something, it will not be zero forever.
How does the NN learn or adapt?
The learning is based on the difference between the actual output and the output of the NN. This error is fed to the layers to correct the weight of the input so that the new output of the node is better than the previous one.
Learning can be done by various methods. Two of them are backpropagation and Genetic algorithm. When using backpropagation the error amount is fed back to the layers of the NN so that the weights and the bias of that layer is modified accordingly.
How can we decide on the number of neurons in the layers?
This is what seemed the most perplexing thing while designing a NN. Its natural that the input and output would be directly proportional to the number of input and the number of output we need, but what about the hidden layer? How many hidden layers do we need and how many neurons per hidden layer?
Well, it seems that one hidded layer is what we need. Almost all the jobs can be done using one hidded layer. And in case of number of neurons, I dont know :) They say that you are going to build a feel of it. There are no hard and fast rule of this. Too few neurons will make your result scratchy. And too many will take longer time and rather fune tune to the training data too much. That means, networks with too many neurons will also adapt to the noise data so much that it will be difficul to generalize it. An excellent resource would be:
http://www.dtreg.com/mlfn.htm
ANN with Genetic Algorithm:
If ANN is used with GA then the learning process is done by GA. The initial weight is fed to the GA along with the fitness function of each member of population. The neural network will evaluate the output of the network and increate or decrease the fitness value of the cromosome accordingly. After some time a new generation is created and the GA is called. The GA will then decide according to the fitness value and generate a new generation. The new generation of population with the new weights are then again fed to the neural nework and the loop continues.
For a Good introduction please refer to:
http://www.ai-junkie.com/ann/evolved/nnt1.html
Genetic Algorithm: A very simple primer
Here I am going to post a very short intuitive description of Genetic algorithm while I am reviewing and refreshing my knowledge which I gathered in my bachelors fourth year.
Genetic algorithm actually mimics the nature by first selecting the best persons in the population, then reproducing (in AI term, its called crossover) children from the best parents, and then mutating the new generation (as per Darwin).
Population: So what is actually a population. A population is a set of possible solutions to the problem. Normally, we randomly pick some solutions, and call those a population (initial population) and then process each of them through the engine to get their fitness (are they good solutions?) and depending upon that we assign each of the population a fitness value.
Crossover: After we get all the fitnees values, we can choose the best persons from the population and then we do cross over just like DNA crossover in human. It can be of several types. The simplest is in the case of binary input. Say, there are two best persons A and B and they are represented
A: 01010101
B: 11110000
And the crossover rule is to cross after 4th position. So the reproduction would be:
x: 01010000
y: 11110101
Now, to be more precise, crossover is not always done between the best persons in the population. The best persons marely have the best chance to be participating in a crossover funciton. Normally we use a function called a Roulette Wheel. It works like following:
The total population is charted like a pie chart with the people having a slice of the pie proportional to his fitness score. And then randomly choose a position in the pie and take that person.
Crossover rate: This rate defines the probability that two members of the population will have crossover. This probability is set to around 0.7
Mutation: Mutation refers to randomly change some bits of the children for evolution. This rate of mutation can be very small (like 0.001) or quite large (say 0.07) depending upon the scenario. We randomly flip the bits in case of binary population.
Actual Working: So, how the genetic algorithm actually work? With the primer above, you should be able to understand the following:
Generate enough possible random solutions to the problem, create a population of all the solutions. Check the solutions for accuracy. Create rule for fitness. The rule is upto you and depends on the problem in hand. It can be as simple as proportional or inverse proportional to the actual solution and the random solution. Give a fitness value to each member of the population. Apply roullette wheel algorithm to choose person to apply cross over. Then, apply crossover to the picked members and generate a new generation of children by mutating the crossovered members. So, now we got a whole new set of evolved population. Iterate the whole procedure again until the fitness value comes to a certain threshold where we stop and accept that the current population is the best.
A very good primer can be found at: http://www.ai-junkie.com/ga/intro/gat1.html
Subscribe to:
Posts (Atom)