How to add a ppa key if you are behind a restrictive firewall (port 11371 is blocked)

7 12 2011

Before you can begin to use an Ubuntu ppa you have to add the signing key.

The instruction on the ppa is very clear on how to do this.  (sudo add-apt-repository ppa:user/ppa-name)

The problem with this approach is that gpg will request the key over port 11371 that may be blocked by you corporate firewall. Trying to add the Firefox Stable Channel Packages (https://launchpad.net/~mozillateam/+archive/firefox-stable) with command:

sudo add-apt-repository ppa:mozillateam/firefox-stable

I get the following errors:

gpg: requesting key CE49EC21 from hkp server keyserver.ubuntu.com
gpgkeys: HTTP fetch error 7: couldn’t connect to host
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

The solution to this problem is to download the key from the ubuntu key server manually.

On the ppa page look for the key server link located under the heading “Signing key:” in the case of the firefox ppa the link was:

http://keyserver.ubuntu.com:11371/pks/lookup?search=0x0AB215679C571D1C8325275B9BDB3D89CE49EC21&op=index

Notice how the port 11371 is used ;(

Take the link and change the 11371 to 80 as shown below

http://keyserver.ubuntu.com:80/pks/lookup?search=0x0AB215679C571D1C8325275B9BDB3D89CE49EC21&op=index

Open the changed link in your browser if everything went well you should see a big heading saying “Search results for …..”

Below the heading click on the key id link (it is the first one) in the case of the firefox ppa the link was:

http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x9BDB3D89CE49EC21

You should now see a heading “Public Key Server — Get …..” with the key information below:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.0.10
...
...
...
-----END PGP PUBLIC KEY BLOCK-----

Copy the key text into a new file named key.txt and save the file. (Dont copy the page heading)

Now that you have the key open a terminal and navigate to the same directory were you key is saved. Mine was saved as key.txt in the home directory

Add the key using the command

sudo apt-key add ./key.txt

If all went well you should see the message:

OK

Now you can do the normal sudo apt-get update and sudo apt-get upgrade. Or install the software however you like.

 





2010 in review

2 01 2011

Dear InterWeb

Happy new year !!!!

My new years resolution is to try and understand what is so great about twitter,[IMPOSSIBLE]

and also to write at least one blog post this year [DONE].

In the meanwhile feast your eyes on my wonderful blog stats for 2010 I believe it is only a matter of time before I become an Internet celebrity ;)

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 8,200 times in 2010. That’s about 20 full 747s.

 

In 2010, there were 2 new posts, growing the total archive of this blog to 33 posts.

The busiest day of the year was November 10th with 52 views. The most popular post that day was GIMP for dummies – How to highlight part of image !!!!!!.

Where did they come from?

The top referring sites in 2010 were google.com, search.conduit.com, google.co.in, google.co.za, and hoiantoday.info.

Some visitors came searching, mostly for gimp highlight, banshee media player, gimp for dummies, highlight in gimp, and how to highlight in gimp.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

GIMP for dummies – How to highlight part of image !!!!!! June 2008
12 comments

2

Insert Date Time in NetBeans – Module June 2008
3 comments

3

NetBeans Insert Date Time plug in (module) June 2008
6 comments

4

Afrikaans spell checker in Web-browser (Firefox) July 2008
1 comment

5

How 2: View Images in the Terminal (Command line, Console) July 2008





My Ubuntu IRC friends

4 09 2010

I have never been a heavy IRC user.

IRC version 1

There has been times (long ago) when I would chat around on various South-African servers mostly to try and pickup girls (without any success) or to chat in “hacker” and programming channels trying to impress everyone with my “skillz” (you do stupid things when you are young) I even played a game or two.

IRC version 2

My second go at the IRC thing came in March of this year when when I joined the #ubuntu-za and #ubuntu-afr channels on freenode. I even registered my nick:

-Notice- {from NickServ} Registered : Mar 04 09:44:48 2010 (26 weeks, 2 days, 00:56:03 ago)

The only reason I did this was because I was bored between classes and  I thought  it would be interesting to chat to a few other South-African Linux users.

The first few server and channel combinations did not deliver much. The people mostly want to debate the whole Microsoft vs Linux thing or talk about how bad all the other operating system are. There was also a lot of mine is bigger then yours mostly IRC version 1 stuff

I have not used Ubuntu since the beginning of the year on any of my own systems rather opting for Arch but decided to try the Ubuntu-Za loco channels and I was pleasantly surprised !!! So what makes chatting on the ubuntu-za loco channels so nice ?

  • Everyone is friendly
  • No mine is bigger then yours talk
  • The people
  • I have never seen anyone talk down to new users or say things like RTFM
  • No basing Microsoft constantly
  • Again the people
  • I can speak afrikaans in #ubuntu-afr

I don’t say much most of the time and try to help other people when and where I can. The only strange thing about this is that I now spend time in the channels of a distro that I am no longer using, luckily nobody seems to mind and from what I have seen even Windows / Mac user would be more then welcome.

So if you are looking for a few nice South-Africans who also like open-source and Linux drop in and say hello you might just make a few new Ubuntu IRC friends.

ps.

Need help getting started with IRC ? Just ask your question in the comment section or click here

For more info on Ubuntu-Za click  here to go to their website





My first IDE

2 04 2010

Wikipedia defines an IDE as:

integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, a compiler and/or interpreter, build automation tools, and (usually) a debugger.”

QBasic

The first  programs I wrote was in BASIC  using my P1 75 Mhz computer.

Back in primary school the IT teacher gave BASIC lessons at R10 a hour giving me my first taste of programming.

A little more research on Wikipedia revealed that I was actually using a variant of BASIC called QuickBasic.

So my first ever IDE was QBasic:

QBasic is an IDE and interpreter for a variant of the BASIC programming language which is based on QuickBasic. Code entered into the IDE is compiled to an intermediate form, and this intermediate form is immediately interpreted on demand within the IDE.”

QBasic IDE

Don’t you just love the good old days…





C Tutorial: switch, loops, and recursive functions

25 08 2009

This is the Tutorial I recently created for my Software Design students that we use during lab time here at the university. SFD is a basic intro to C type subject. I cannot post the other tutorials since they have been created by other lecturers but this one I can share. Enjoy !!!

Tutorial 5 (Outcome 3 ,4)

Part 1: switch Multiple-Selection Statement

When testing for many conditions the if statements that will be needed will grow large and make the code of your program harder to read. There is also some performance loss when using the if statement to check the same variable for many conditions. So when checking one variable for many conditions it is better to use the switch statement.

The basic syntax for a switch statement is:

switch (variable)
{

case test :
statement(s) if is case is true
break;

case test :
statement(s) if is case is true
even more statements
break;

default:
statement(s) if not one of the cases evaluated to true
break;

}

variable is the variables value you want to test.
test is the value you want to test variable for.
the statement(s) is the code that is going to be executed if true.
default: contains the code that is going to be executed if not one case evaluates to true.
always remember to end the case with a break;

Lets look at example one that uses a switch statement. In the example the user is asked to enter a number (int) between 1 and 5. The program first checks if the number is between one and five using an if statement. Then it displays on the screen the number the user entered but it shows the number in word format. So if the user enters 5 the program will display FIVE.

Example 1

Example 1

In example 1 the switch statement starts at line 25 and ends at line 47. In line 25 the variable number is sent to the switch. Line 28 contains the first case and checks if the number was 1. If the number was indeed one the program will move to line 29 were the printf() statement is executed. After the printf() in line 29 the program will encounter a break; statement in line 30 letting it know the case is done. If the number was not 1 the program moves to the next case etc.

You would notice that the switch statement in example one does not contain a default case. This is because the default case is optional. We can rewrite the code in example 1 and add a default case to the switch statement. The default case will only be executed if no other cases matched. This means if the user did not enter a number between 1 and 5 the default statement will execute. Since we now have a default case we can remove the if statement on lines 15 – 22 that checks if the number is between 1 and 5. Example 2 contains a switch with a default statement:

Example 2

In example 2 the if statement was removed. Line 38 – 43 now contains a default case. Note that each case including the default case ends with a break; statement. The break statement is very important since it tells the program that the statements in the case was executed and the program can now “break” out of the switch.

Part 2: Loop structures

Most programs contain structures known as loops. Loops allow for repetition in programs. Each loop structure will contain a number of instructions that gets repeated a certain number of times. The three basic loop structures are For, While and Do While.

Although the three types of loop structures do the same thing (repeat instructions) the way that they are implemented and used differ. Deciding on what type of loop structure to use will depend mostly on the type of repetition that is needed. The two types of repetition is Counter-controlled repetition and Sentinel-controlled repetition.

Counter-controlled repetition needs 3 things:

The loop counter that will count how many times the loop has been executed. The loop counter also needs an initial value.

The increment (+) or decrement (-) by which the loop counter is modified each time the loop is executed.

The test to check the loop counter and determine if the loop should be executed again.

Part 2.1: The while loop

The while loop will execute its statements while a certain condition is true. The basic syntax for a while loop is as follows:

while(test condition = = true)
{
//Execute some statements like incrementing the counter
}

Example 3 shows a basic while loop that will loop 10 times and display the counter. On line 8 the variable counter is created. counter Is the variable that will keep track of how many times the loop was executed and gets an initial value of 1. Line 10 – 15 contains the while loop. In line 10 one can see the test for the while loop. This loop will execute only while counter is less then or is 10. In line 14 after all the normal statements but still inside the loop counter is incremented with 1. This is done so that each time the loops executes counter gets larger by one until counter is more then 10 and the loop is not executed. If we do not increment counter at the end of each loop each time we will get what is called an infinite loop.

Infinite loops occur when the loop just gets executed for ever usually there is no way the test can result in false so the loop just keeps going.

Example 3

Part 2.2: The for loop

Unlike when using the while loop with the for loop you can initialise the counter, test the counter and increment / decrement the counter in one line. The syntax for the for loop is as follows:

for(assign value to counter ; test condition ; counter increment / decrement)
{
// Statements to execute
}

Example 4 shows an for loop implementation that does exactly the same thing as example 3.

Example 4

In example 4 a variable counter is declared on line 8. counter Will keep track of how many times the loop has been executed. The for loop is located at line 10 – 13. The counter was set to 1 the test will make sure the counter is not more then ten before the loop is executed and the counter is incremented by 1 each time the loop is executed. This al happens in line 10.

Part 2.3: The do…while loop

Very similar to the while loop the do…while loop is only different in that it tests the loop condition at the end of the loop instead of the beginning. This means that the statements included in the loop body will be executed at least once before the test condition is evaluated. If after the initial execution the test condition evaluates to false the loop will not be executed again. You can use the do…while loop when you want to ensure the statements inside the loop is executed at least once in your application. The syntax for the do…while loop is:

do
{
//Statements to be executed
}
while (condition)

Example 5 shows the do…while in action. Notice that even if the counter variable is set to more then 10 the statements will be executed at least once. This is different to the for and while loops that will first evaluate the test condition before any statements is executed:

Example 5

In example 5 a variable counter with default value 1 is created in line 8. The do…while statement is located in lines 6 -15. Notice how the while is located at the end in line 15. Also be sure to remember to increment the counter each time the loop is executed as in line 13.

Part 2.4: break and continue

We can use the break and continue statements to alter the flow of programs especially inside loops.

The break statement is used to exit the loop completely even if the next condition will still evaluate to true. We have used the break statement in the switch statement before to exit the switch after the cases statements have been executed. break Can perform the same function loops.

The continue statement will continue with next iteration of the loop ignoring any additional statements in the loop body after the statement.

Example program 6 shows the use of break and continue:

Example 6

Example program 6 tracks the numbers of years that the Dalton gang spends in jail. Line 6 -7 contains variables that is used in the program. jail_years is the number of years in jail and rnum is a random number between 0 – 10

Line 13 – 39 contains the for loop. On line 13 a new for loop is created. The for loop is created in such a way that the loop will execute until a break statement is encountered.

The first statement in the the for loop (line 16) will use the the getran() function (line 45 -54) to get a random number between 0 and 10.

The first if in the for loop will execute if the random number is 4 and then break out of the loop. A message is displayed showing that the Dalton gang breaks out of jail.

The second if in the for loop (line 28) will check if the random number is more then 5. If that is the case the number of years in jail will be incremented two times. The continue statement is then executed ignoring any other lines of code in the for loop (lines 37 – 38) .

If the random number was not more then 5 then the jail time is only incremented once in line 37.

Part 2.5: Nested loops

Just like if statements loops can also be nested. A nested loop will contain an outer and inner loop. With nested loops the inner loop is executed for each time that the outer loop is executed. Example 7 shows a nested loop:

Example 7

Part 3: Recursive functions

A recursive function is a function that calls itself repeatedly until some condition is met and the function can return a value. This sounds very much like loops and in a way they are the same. The most basic recursive function you can create is shown in example 8:

Example 8

In Example program 8 the function recurse(int count) (line 15) receives as an argument one integer. Then inside the function on line 18 the function calls itself with the original count + 1. This will lead to each instance of the recurse function receiving an argument that was incremented by one. The recurse function will keep calling itself and never return a value leading to an infinite recurse.

To make sure that the function does not just keep calling itself one needs to add a base case to the function. The base case is a condition that will return something from the function and stop the cycle of calls.

Example 9 shows a recursive function with a base case. The function will receive a number and start counting down until 0 is reached where it will the return 0 :

Example 9








Follow

Get every new post delivered to your Inbox.