Monday, September 17, 2007

corkscrew (not screwdriver!)

I can't believe I didn't have a post about corkscrew already!

This is a great link:

http://www.mtu.net/~engstrom/ssh-proxy.php

install corkscrew via apt (synaptic/aptitude/apt-get whatever)

Edit your ~/.ssh/config file:


Host my.server my.other.server
    ProxyCommand corkscrew proxy.domain.com 8080 %h %p ~/.ssh/proxy_auth
    User remoteuser


in ~/.ssh/proxy_auth put:


username:password


It's a pain if you don't use the Host line because you have to comment the ProxyCommand line when you need to access a local machine (i.e. not through the proxy server)

Talking about proxies... a LONG time ago in another country (oots mon!) I used to use APS - I don't know if I'll need it again, but just in case, there it is.

Friday, September 14, 2007

VMware

I'm using the Debian Etch image from here with VMware Player

To get it to use a UK keyboard mapping I needed to do

loadkeys uk

for console, and

dpkg-reconfigure xserver-xorg
and/or
setxkbmap -layout "gb"

for X.

You also might need to start networking manually, and I exported my proxy details:


export http_proxy="http://proxy-server:port/"


Then ran synaptic - NICE - hadn't used it before.
Upgraded to a 686 kernel from the 486 one, stripped out all the gnome packages and put in fluxbox and wdm instead - it's much faster now.

I also did this

dhclient kept overwriting /etc/resolv.conf so I added this to /etc/dhcp/dhclient.conf


supersede domain-name-servers ns1-ip-address, ns2-ip-address;
supersede domain-name "domain.com";


as per one of the answers here: http://forums.debian.net/viewtopic.php?t=7239

Tuesday, August 28, 2007

Perl scalar assignment

The difference between:


my $var = EXPRESSION;


and


my ($var) = EXPRESSION;


is in whether EXPRESSION returns an array...

Of course in list context an array produces a list of the items in the array, but in scalar context it produces the number of items in the array...

By putting the parentheses around the scalar you are populating an array, and $var is asking for the first element of EXPRESSION if it returns a list, so:


#!/usr/bin/perl

use warnings;
use strict;

my @array = ('a', 'b', 'c');

my $var1 = @array;

my ($var2) = @array;

print "var1: [$var1]\nvar2: [$var2]\n";


returns:


var1: [3]
var2: [a]


Thus if your expression unexpectedly returns an array you at least get some useful value rather than a mysterious number. :-)

Thursday, August 23, 2007

Dumping all param values with mod_perl

It's as simple as:




use strict;
use CGI ( );

my $cgi = new CGI;
print $cgi->header('text/plain');
print "DEBUG:\n", join('', map({"$_: [".$cgi->param($_)."]\n"} $cgi->param)), $/;


From: http://modperlbook.org/html/ch10_01.html#pmodperl-CHP-10-EX-11

Tuesday, August 21, 2007

Using netcat to run a port listener.

If you want to have a port listening on a machine just so another host can test connecting to it (e.g. you want to see whether your "Connection refused" message is caused by your socket application failing to serve, or if it is serving but the connection is being blocked by a firewall)...

First make sure that the application that would normally listen to that port is stopped, then run up netcat:

nc -l -p 1234

where 1234 is the port you want to listen on...

Now from the other host:

telnet hostname.domain.com 1234

where hostname.domain.com is the machine you're running netcat on.

This is a failure:

$ telnet hostname.domain.com 1234
Trying 10.11.12.13...
telnet: Unable to connect to remote host: Connection refused

This is a successful connection:

$ telnet hostname.domain.com
Trying 10.11.12.13...
Connected to hostname.domain.com (10.11.12.13).
Escape character is '^]'.

If you get a connection then the network probably isn't the problem...

Once you're connected you can then either use ^D (<Ctrl-d>) to get out, or use ^] (<Ctrl-]>) to get a telnet prompt, then type close:

$ telnet hostname.domain.com
Trying 10.11.12.13...
Connected to hostname.domain.com (10.11.12.13).
Escape character is '^]'.
^]

telnet> close
Connection closed.

Monday, August 20, 2007

Permanently setting font and theme for gvim

To set the font permanently:

set guifont=Fixed\ 9

or try:


set gfn=fixed
set guifont=courier\ 8


( see http://www.troubleshooters.com/linux/vifont.htm )
( nice: http://www.proggyfonts.com/ )

To set the colour scheme permanently use:

colorscheme

In your .vimrc

(or color )

When in command mode type :help colorscheme for some help on this subject.

and:

syntax on

to make use of it.

(or:)


" have syntax highlighting in terminals which can display colours:
" > if has('syntax') && (&t_Co > 2)
syntax on
" > endif


I also have a post on toggling search highlighting...

Tuesday, August 14, 2007

How do I find the version of my current (running) bash or ksh shell?

If you just want to check from the command line:
bash --version
is OK, but that's not interactive - if you do that you're starting a new bash
which isn't necessarily the same version the current shell instance.

ksh:

In ksh you can display the version of the shell interactively by typing ^V

bash:

In bash you can do ^X^V (C-x C-v)

NB:
This works in set -o emacs.
If like me you prefer to live in the set -o vi world you may need to change to set -o emacs to check it and then back again.

There are also the BASH_VERSINFO array and BASH_VERSION variables

BASH_VERSINFO is immutable so you should be able to rely on it,
but BASH_VERSION could be set somewhere else so don't rely on it.

http://www.gnu.org/software/bash/manual/bashref.html#SEC110
has:

display-shell-version (C-x C-v)
Display version information about the current instance of Bash.

(thanks to jm_ on #debian for help with the research)

Monday, August 13, 2007

How to change the Theme in Firefox

Problem:

You have found a cool Firefox theme on the web and want to download and try it,
but have never used another theme in Firefox before...

You download it and can install it OK, but now how the heck do you switch it on?

You go to Google and search and up comes spam in the form of a www.surveymonkey.com survey, ever so helpfully titled "Firefox Theme Tutorial" asking questions like:

1. Describe your experience with Firefox Themes.
-> I only use the default because I can't figure out how to change them.

2. Would you be interested in a detailed step by step how to guide for (*snip*) Firefox themes?

3. Would you be willing to pay for this guide?

4. How much would you be willing, if any, to pay for this guide?

Just damn cruel when that's the only thing that's in your face when you're looking for help!


OK, so you go to Help in Firefox and search for "theme"... you get:

Add-ons (extensions and themes)
Switching Themes
Using a High Contrast Theme


Hmm... "Switching Themes" is clearly the one I need... *click*:

Switching Themes

To switch between your installed themes, select the Themes panel, select the
theme of your choice, and click its Use Theme button. You need to
restart Firefox for changes to take effect.

Oh great... so I just need to select the Themes panel...
Click "Tools -> Options" - nope, not in there...
Check all the other menus:
File (didn't really think it would be there)
Edit (why would it be there?)
View (COULD be there... nope)
Tools (SHOULD be there, but can't see anything about themes)

the really helpful (NOT!) bit is that without scrolling backwards and forwards in the help page
there's no indication of where you FIND this "Themes panel"!

So after a bit more Googling I went to Intranet Exploder and tried out some of the YouTube tutorials...
(I don't install Flash in my Firefox - because I prefer not to have flash spam in pages...
the only time I start up IE is for something I *need* that uses Flash,
or for broken pages I have to use for work that don't validate and won't work in Firefox)

Yay! the answer \o/
http://youtube.com/watch?v=NvU4D-Buseo
http://youtube.com/watch?v=kykO8J0XA5c
http://youtube.com/watch?v=JjnCIRO9Jg4

I don't think I'd ever used YouTube to learn something technical before - but it certainly works!

In summary - the Themes are Add-ons - as are Extensions...
so the "Themes panel" is found under "Tools -> Add-ons"

I hadn't looked in there because I use Tools -> Add-ons quite regularly (for Extensions)
so didn't bother to look in there because I didn't remember noticing the Themes panel icon before.

Thursday, March 01, 2007

Accessing sshfs with Thunar

I mounted a directory using sshfs:


sshfs user@host: /mnt/host


and found that while I could cd into it and ls it and do things with the files fine... Thunar (and Gentoo) didn't seem to know it existed.

I found the answer was to use -o allow_other when mounting the fuse-filesystem.


sshfs user@host: /mnt/host -o allow_other


all better :o)

Monday, February 19, 2007

bzip2 errors running apt-get update

I kept getting an error like this running apt-get update (I'm pretty sure it was immediately following adding a new line to /etc/apt/sources.list):


Get:5 http://ftp.debian.org etch/main Sources [1222kB]
79% [4 Packages bzip2 3911680] [5 Sources 50355/1222kB 4%] 25.2kB/s
46sbzip2: Data integrity error when decompressing.
Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

Err http://ftp.debian.org etch/main Packages
Sub-process bzip2 returned an error code (2)
Fetched 5616kB in 1m32s (60.6kB/s)
Reading package lists... Done


That wasn't my actual screen scrape - that's Brian May's off Google... because mine scrolled out of my history before I thought to grab it... but...

What I did was to comment out the sources in /etc/apt/sources.list that were erroring, then re-ran apt-get update again, and it worked OK.

After I'd finished the update I uncommented the lines and re-ran apt-get update and it worked fine.