Back to a Walking Speed

May 7, 2010

Well the Firefox slow down has finally gotten out of hand.  I’ve installed Swiftfox, which is basically Firefox but supposedly optimized for speed.  If you want to try it then just do a Google search for Swiftfox, and click on just about any link of your choice.

In the previous post I provided a link that showed how to supposedly fix the problem.  More or less what it instructed you to do was disable IPv6 in Firefox.  Well this didn’t work for me (though it might for you so I suggest you try it anyway).  After realizing that this didn’t work I found another site that showed how to disable IPv6 system wide.  Here is what the site says to do;

First check to see if IPv6 is enabled. If the following returns 0 then it is, otherwise it’s not.

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

If it is enabled the you need to run the following and then restart your system.

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

Just to be safe however, I installed Google Chrome anyway.  My system still freezes every now and then, but it’s no longer as bad as it used to be.  At this point I think that it’s something else (probably flash, who knows).

Another problem I’ve encountered is that Pidgin isn’t as responsive as it was back when I used 8.04.  But that could be due to the Facebook plugin, I’ve experienced this before so fixing it shouldn’t be too difficult.

Well my next post will most likely be about more problems I have with 10.04 (thank god this is a LTS, because it seems like the problems don’t stop).

EDIT: I totally forgot to mention what the tee command does.  It reads from standard in and writes to either standard out or a file.  When used with the -a flag it appends to the end of the designated file(s). Therefore, the following commands will have the same (overall) result.

echo "I can append to a file" >> my_file
echo "I can append to a file" | tee -a my_file

Similarly the same is true of the following.

echo "I can overwrite a file" > my_file
echo "I can overwrite a file" | tee my_file


On my First Script

July 15, 2009

Well as promised it is time to explain parts of my script. Well I shall start at the beginning.  The !#/bin/bash tell the OS where the interpretor for the script can be found. The following line is just a place where most of the work will be done.  This should actually be changed to cd ~ if I were planning on sharning this script (which I am).

Now for the more “interesting” aspects.

ls -a | grep “^\.” > temp

This line will first list all the fils found in a directory (ls -a). Then it will find those that begin with a ‘.’ (dot) and print them to a file called temp.  This is done through the use of grep “^\.” grep works with regx, and in the one used here it will match ‘phrases’ that begin with a ‘.’ (dot).  Pretty much grep can do a lot of things (or so I have read) but they rely on regx so needless to say I am currently working on learning regx.  Anyway back to the code. After this I do a search to find a file called .myPw, this is where the password will be stored.  So if the file doesn’t exist we shall create it, along with a password to place into it.

After this I basically use some basic loops to test the user’s input to see if it matches the password.  I won’t talk about the loop structure since 1: this isn’t a tutorial on bash, and 2: it is easy enough to figure out from just reading the code.  I won’t explain what echo does, if you don’t know just click on the man link at the top of this blog and then click on echo.  It’s actually a pretty “simple” command.

One last thing, I would like to point out that after making the file temp I deleted it once I no longer needed it. This turns out to be somewhat optinal (I’ll explain in a moment), but I think it’s just “polite” to delete temporary files you put on someone else’s system.  Now for why this is optional.  The way the code is set up, if there already exist a file called temp it will overwrite it.  If however I had used

ls -a | grep “^\.” >> temp

It would append the output to the end of the file (in which case who knows what was in there before and how much you will have to seach through while looking for .myPw).  So there is a BIG difference between > and >>, both direct output to a file but in differnt fashions.


First Complete Script

July 12, 2009

Here is my first “real” script. It does what it was designed to do, but not as nicely as I would have liked. So needless to say there will be some updating.  As for the script itself it is supposed to prompt the user for a password before opening firefox.  If a password doesn’t currently exist it will ask them to make a new one, that will be saved into a “hidden” file. Really it’s pretty easy to get around but it should be enough to keep your computer illiterate friends away/busy at least.

Here is the script:

#!/bin/bash

cd <path> #location of password file
there=false
ls -a | egrep '^\.' > mytemp

#chek if file with password exists
while read f
do
	if [ "$f" = ".myPw" ]; then
		there=true;
	fi
done < mytemp
rm mytemp 

#if not make it
if [ "$there" = "false" ]; then
   echo "Enter a password:"
   read newPass
   echo $newPass > .myPw
   chmod 777 .myPw #make possible to read and write to file (needed for later on)
fi

input=:
correct=false
j=:

#get actuall password
while read j
do
	PW=$j
done < .myPw

#read until correct pw is given
while [ "$correct" = "false" ]
do
	echo "Enter password or ^C (Ctrl + C) to quit:"
	read input
	if [ "$input" = "$PW" ]
	then
		correct=true
	else
		echo "Incorrect password"
	fi
done
firefox&

while :
do
   ii=2
done

Sorry it’s not in the best font but at least the formatting is there. Anyway the part I don’t like is the infinite loop at the end. However, I haven’t found a way to keep firefox open if it’s not there. With out it, once the correct password is entered the script will end but firefox won’t start.

Well in my next post I’ll try to explain what each line does. Should be a good exercise in talking about terminal commands.


Bash

July 10, 2009

Well today I decided to learn Bash.  One of the tutorials (though not all that great) had a pretty good introduction on some terminal commands.  The best job was done with the echo command.  First I’ll show some examples then explain what they each do.

  • echo "hello     world"
  • echo hello     world
  • echo “Number2 Atoms Zzz…” | tr ” ” “\n” | sort

The first line will print “hello      world” to the screen, while the second will print “hello world”. Notice how the extra space disappeared.  This is because the string is not in quotation marks.  The final example will display

Atoms

Number2

Zzz…

This is due the fact that the tr command will replace all the spaces with new lines, then sort will sort them in lexicographic order. I’ll hopefully explain more about tr in later post since it seems that it can use regx. But basically echo prints whatever follows it to the screen. Finally the pipeline, ‘ | ‘, will cause the result of running the previous command to be used as the input for the following command.  This to will be talked about later, mainly because I am tired and am going to end this post now.