Wednesday, June 30, 2010

Imperial College printing from linux laptop

Well, this does not work perfectly for me and some problems may come up (e.g. when printing multiple pdf pages in a single page) but generally it works well. Strangely enough, there are instrunctions for this on the DoC's CSG old site but I couldn't find them on the new one. The old site's link is http://www.doc.ic.ac.uk/csg-old/ . click on the lab printers section and follow the instructions on the bottom of the screen. Basically, all you need to do is add the following lines at /etc/cups/printers.conf (replace username with your IC username): (https://www.doc.ic.ac.uk/csg-old/labprinters/printers.conf)

Restart cups and that should do the trick. The site suggests to also install the PPD file, you can do that, but as I metioned, I still got issues from time to time.
(tested on debian testing)

How to: Debian and nokia smartphone as modem

The following has been tested for Debian Testing (Squeeze), Nokia E51 and usb connection.

You will need to install wvdial (#apt-get instal wvdial). Then add the following lines to /etc/wvdial.conf (create it if it does not already exist)

[Dialer vfuk]
Modem = /dev/ttyACM0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Password = web
Username = pass
Phone = *99#
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","Internet"

Note that you should adjust the password, username and access point ("Internet") (under Init3) to comply with your mobile network settings. The settings above are for Vodafone UK. For example, for Cosmote Greece the configuration file should look like this:

[Dialer cote]
Modem = /dev/ttyACM0
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Password = user
Username = pass
Phone = *99#
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","Internet"

Before trying to connect to the internet, stop any network connection manager (e.g. wicd, #/etc/init.d/wicd stop) and disable the rest of the network interfaces (e.g. ifconfig wlan0 down). This is to ensure that all the network traffic will be routed via the mobile phone.

Finally in order to connect run: wvdial vfuk (replace vfuk with the name of the dialer specified in the configuration file). Confirm that this connection is actually used by viewing the routing table information (route -n).


Configure apache to run php scripts as cgi

The default configuration for apache in debian is to run php scripts using phpmod. Thus, adding the #!/usr/bin/php line at the begining of each php scripts is not required. On the contrast, this line will be printed on the user's browser and will cause errors if session functions are used in the script.
Recently, I was working on a php project for univerisity. The university's server configuration required this directive while my local apache installion that I was using for development did not. Adding and removing this line each time I loaded the code in the university's server was not a practical solution.
First of all, php5-cgi needs to be installed:

#apt-get install php5-cgi

Then mod_php should be disabled (#a2dismod php5) and the actions module should be used instead (#a2enmod actions). In addition, add these lines to /etc/apache2/httpd.conf (create it if it does already exists):

AddHandler php-script .php
Action php-script /cgi-bin/php5

That's all. Then restart apache (#apache2ctl restart).
In order to verify that apache was configured correctly create the following test.php file and make it executable (chmod 775 test.php):

#!/usr/bin/php

Upload it on your site. The server API section should be set to: CGI/FastCGI.

Hello world

This is my first blog post (after 3-4 years since I created a blogger account). Welcome everyone. I' ll post hear whatever I consider useful/interesting when I have free time.

Enjoy! :P