Ubuntu: Connecting to Internet through a Proxy server

You usually either have the proxy server as user:password@host:port or an automatic configuration script like http://some-script-path

Getting Browsers to work:

You would expect that the only setting that needs to be changed is at the ‘Network Proxy’ settings, and then press the ‘Apply system wide’.

[Ubuntu Oneiric Ocelot] System Settings > Network > Network Proxy
[Ubuntu older that Ocelot] System > Preferences > Network Proxy

That is usually enough to get the browser working. However,in my experience this is not enough to get ‘apt-get’, Ubuntu Software Centre, Update manager to work.

Getting ‘apt-get’ to work:

In order to get these working you have to create /etc/apt/apt.conf (if it does not already exist, which in my case never did), and add the following lines to it:

Acquire::http::Proxy "http://user:password@host:port/";
Acquire::ftp::Proxy "http://user:password@host:port/";

Retrieving “host:port” from automatic proxy configuration script:

If you are using an automatic configuration script like ‘http://some-script-path’ then open a terminal and type

wget http://some-script-path

This should save the script in your current working directory. Look into the script, and try to understand the host:port value it is trying to return for your IP address.

Look for statements like:

return "PROXY host1:port1; PROXY host2:port2";

You just need to use one of them. If you cannot determine one of the ‘host:port’s returned by the automatic configuration script then it is out of my scope. I do not know how to configure Ubuntu so that ‘apt-get’, Ubuntu Software Centre, Upgrade manager etc. can make use of automatic proxy configuration script. I think it just does not support this as of this writing.

To know your current IP address try the following command:

/sbin/ip addr show

Setting http_proxy variable:

Certain programs may still fail to work properly. For example, Dropbox could not download its proprietary daemon. To make all things work properly run the following command.

echo export http_proxy=http://user:passwd@host:port/ >> ~/.profile

Then logout, and log back in.

Do not rely on the ping command to verify if your proxy settings are working properly for reasons explained here.

Find all pizzerias that serve every pizza eaten by people over 30

Encountered this Relational Algebra exercise in the Introduction to Databases free online course  offered by Stanford University in Fall, 2011.

Question 9
Find all pizzerias that serve every pizza eaten by people over 30.
(This query is very challenging; extra congratulations if you get it right.)

Person

name age gender
Amy 16 female
Ben 21 male
Cal 33 male
Dan 13 male
Eli 45 male
Fay 21 female
Gus 24 male
Hil 30 female
Ian 18 male

Frequents

name pizzeria
Amy Pizza Hut
Ben Chicago Pizza
Ben Pizza Hut
Cal New York Pizza
Cal Straw Hat
Dan New York Pizza
Dan Straw Hat
Eli Chicago Pizza
Eli Straw Hat
Fay Dominos
Fay Little Caesars
Gus Chicago Pizza
Gus Pizza Hut
Hil Dominos
Hil Pizza Hut
Hil Straw Hat
Ian Dominos
Ian New York Pizza
Ian Straw Hat

Eats

name pizza
Amy mushroom
Amy pepperoni
Ben cheese
Ben pepperoni
Cal supreme
Dan cheese
Dan mushroom
Dan pepperoni
Dan sausage
Dan supreme
Eli cheese
Eli supreme
Fay mushroom
Gus cheese
Gus mushroom
Gus supreme
Hil cheese
Hil supreme
Ian pepperoni
Ian supreme

Serves

pizzeria pizza price
Chicago Pizza cheese 7.75
Chicago Pizza supreme 8.5
Dominos cheese 9.75
Dominos mushroom 11
Little Caesars cheese 7
Little Caesars mushroom 9.25
Little Caesars pepperoni 9.75
Little Caesars sausage 9.5
New York Pizza cheese 7
New York Pizza pepperoni 8
New York Pizza supreme 8.5
Pizza Hut cheese 9
Pizza Hut pepperoni 12
Pizza Hut sausage 12
Pizza Hut supreme 12
Straw Hat cheese 9.25
Straw Hat pepperoni 8
Straw Hat sausage 9.75

These slides explain how to formulate relational algebra queries like the one presented above.