xterm*toolBar: false
A place for John to record his techy notes, both to refer back to when needed, and as a help for others...
Wednesday, November 25, 2009
To turn off the menu in xterm
Add this to your ~/.Xdefaults file or to /etc/X11/app-defaults/XTerm
Monday, November 23, 2009
Excel 2007 'Cannot empty the Clipboard.'

If you drag and drop a cell in Excel 2007 and get a pop error with "Cannot empty the Clipboard.":
Check to see if you have any applications running that interact with the clipboard.
In my case, it was MultiMonitor TaskBar from http://www.mediachance.com/free/multimon.htm
To turn this off:
Right-click on the MultiMonitor TaskBar
-> Click "Properties"
-> Uncheck "Add Multi-Text Clipboard"
There are other solutions for this here:
http://www.online-tech-tips.com/ms-office-tips/cannont-empty-clipboard/
Friday, November 20, 2009
SQLite guis for Windows
I have tried quite a few from:
http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
These are OK:
SQLite2009Pro-v3.6.20.zip
sqlitebrowser-1.3-win.zip
SqliteDev357.zip
SQLiteExpertPersSetup.exe
http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
These are OK:
SQLite2009Pro-v3.6.20.zip
sqlitebrowser-1.3-win.zip
SqliteDev357.zip
SQLiteExpertPersSetup.exe
Multiple field primary key in sqlite
BEGIN TRANSACTION;
CREATE TABLE test_table(
field1 text not null,
field2 text not null,
field3 text not null,
PRIMARY KEY(field1, field2)
);
INSERT INTO "test_table" VALUES('a', 'a', '1');
INSERT INTO "test_table" VALUES('a', 'b', '2');
INSERT INTO "test_table" VALUES('a', 'c', '3');
COMMIT;
http://groups.google.com/group/android-developers/browse_thread/thread/948acbc9358a3095
Wednesday, October 28, 2009
Create a hash referece from two arrays using a hash slice.
Given http://www.perlmonks.org/?node_id=4402
and http://www.nntp.perl.org/group/perl.beginners/2009/03/msg106746.html
and the ouput of:
...this works:
In case I need it again...
and http://www.nntp.perl.org/group/perl.beginners/2009/03/msg106746.html
and the ouput of:
my $command = '/bin/rpm -qa "--queryformat=%{Name}\t%{Version}\t%{Arch}\t%{Epoch}\t%{Release}\n"';
...this works:
#
# Create a hash referece from two arrays using a hash slice.
#
my $pkg;
@{$pkg}{qw( name ver arch epoch rel )} = split(/\t/, $rpm_qa);
In case I need it again...
Tuesday, October 27, 2009
Scripting differences between ksh and bash
Test this:
vs
bash seems to run the while in a sub shell, while ksh saves the pipeline up and runs it in its own instance.
Using:
may help in bash.
#!/bin/bash
SET_VAR="didn't"
ls -l | while read LINE
do
SET_VAR="did"
done
echo "I $SET_VAR set var"
vs
#!/bin/ksh
SET_VAR="didn't"
ls -l | while read LINE
do
SET_VAR="did"
done
echo "I $SET_VAR set var"
bash seems to run the while in a sub shell, while ksh saves the pipeline up and runs it in its own instance.
Using:
while ...
do
...
done <<< "$(command)"
may help in bash.
Monday, October 26, 2009
Import a csv file into SQLite
#!/bin/bash
DIR=/tmp
rm $DIR/create.sql $DIR/load.sql $DIR/files.db
ls -l | sed 's/\s\s*/,/g' | tail -n +2 > $DIR/import.csv
cat < $DIR/load.sql
CREATE TABLE FILES(perms text,links int,user text,groups text,bytes int,mon text,day int,time_year text,file text);
.schema files
.separator ","
.import $DIR/import.csv FILES
.separator "\t"
select * from FILES;
.output $DIR/create.sql
.dump FILES
.output stdout
.backup main $DIR/files.db
.q
EOT
echo ".read $DIR/load.sql" | ./sqlite3
If you're working on an older version of sqlite3 that doesn't support .backup, you can create the database by running:
sqlite3 file.db
where file.db is a new file to create, then create the tables and import the data.
CREATE TABLE FILES(host text,perms text,links int,user text,groups text,bytes int,mon text,day int,time_year text,file text);
.schema files
.separator ";"
.import results.csv FILES
.separator "\t"
select * from FILES;
.output results.sql
.dump FILES
.output stdout
.q
git $PATH problems with ssh
If your git binaries are in a non-standard location you may have problems with the hard-coded path in sshd, which can mean any $PATH definitions in your remote .profile, .kshrc & .bashrc are ignored:
This should work as a temporary fix:
or
for short.
(where git/bin is the path to your git binaries at the remote end)
If you want to permanently set this once you've cloned it,
cd into the directory and issue the commands:
These links may help:
$ ssh host 'echo $PATH'
/usr/local/bin:/bin:/usr/bin
$ git clone ssh://host/$HOME/git/repo test
Initialized empty Git repository in /home/user/test/.git/
ksh: line 1: git-upload-pack: not found
fatal: The remote end hung up unexpectedly
This should work as a temporary fix:
git clone --upload-pack=git/bin/git-upload-pack ssh://host/$HOME/git/repo test
or
git clone -u git/bin/git-upload-pack ssh://localhost/$HOME/git/repo test
for short.
(where git/bin is the path to your git binaries at the remote end)
If you want to permanently set this once you've cloned it,
cd into the directory and issue the commands:
$ git config remote.origin.uploadpack git/bin/git-upload-pack
$ git config remote.origin.receivepack git/bin/git-receive-pack
These links may help:
- https://37s.backpackit.com/pub/1465067
- http://stackoverflow.com/questions/1603739/ssh-ksh-git-not-found
- http://go.hopx.net/2009/03/using-git-where-git-is-not-installed.html
- http://kernel.org/pub/software/scm/git/docs/git-clone.html
- http://projectmouse.org/git-clone.html
- http://www.bluestatic.org/blog/2007/08/01/git-public-push-ing/
Wednesday, October 21, 2009
bash 2.x prompt gotcha...
In my .bashrc I had:
On bash 2.x, this meant that every time I displayed my bash prompt it needed to run tty twice.
This had a nasty gotcha...
The echo $? on a line by itself was dutifully reporting the exit code of the last tty command executed in the PS1 variable!
Removing the commands from PS1 made the problem go away:
It then behaves as expected...
(NB: I didn't seem to get the same problem in bash 3.x)
I have now changed my prompt to:
PS1='\e]0;\u@\h:\w [`tty`]\a\u@\h:\w [`tty`]\n\$ '
On bash 2.x, this meant that every time I displayed my bash prompt it needed to run tty twice.
This had a nasty gotcha...
john@hostname:~ [/dev/pts/0]
$ bash --version ; echo "yes" | grep "no" ; echo $?
SunOS
GNU bash, version 2.03.0(1)-release (sparc-sun-solaris)
Copyright 1998 Free Software Foundation, Inc.
1
john@hostname:~ [/dev/pts/0]
$ echo "yes" | grep "no"
john@hostname:~ [/dev/pts/0]
$ echo $?
0
The echo $? on a line by itself was dutifully reporting the exit code of the last tty command executed in the PS1 variable!
Removing the commands from PS1 made the problem go away:
$ PS1="$ "
$ echo "yes" | grep "no" ; echo $?
1
$ echo "yes" | grep "no"
$ echo $?
1
It then behaves as expected...
(NB: I didn't seem to get the same problem in bash 3.x)
I have now changed my prompt to:
MYTTY=$(tty)
PS1='\e]0;\u@\h:\w [${MYTTY:5}]\a\u@\h:\w [${MYTTY:5}]\n\$ '
ssh-agent script
From: http://mah.everybody.org/docs/ssh
and add this to your .bashrc / .kshrc
#!/bin/sh
SSH_ENV="$HOME/.ssh/environment.$HOSTNAME"
if [ -x /usr/bin/ssh-agent ]
then
SSH_AGENT=/usr/bin/ssh-agent
SSH_ADD=/usr/bin/ssh-add
else
echo "Can't find ssh-agent"
SSH_AGENT=/bin/false
SSH_ADD=/bin/false
fi
start_agent () {
printf "Starting new SSH agent... "
$SSH_AGENT > "${SSH_ENV}"
if [ $? = 0 ]
then
echo "OK"
printf "3s|^echo|#echo|\nw\n\q\n" | ed "${SSH_ENV}" >/dev/null 2>&1
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}"
else
echo "ERROR"
fi
$SSH_ADD -l | grep : || {
$SSH_ADD;
}
}
#
# Source SSH settings, if there
#
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}"
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -fu$LOGNAME | grep ${SSH_AGENT_PID}.*ssh-agent$ >/dev/null
if [ $? != 0 ]
then
start_agent;
else
$SSH_ADD -l | grep : || {
echo "Agent is running, but has no keys..."
$SSH_ADD
}
fi
else
start_agent;
fi
and add this to your .bashrc / .kshrc
alias ssh_agent='. $HOME/.ssh/ssh_agent'
SSH_ENV="$HOME/.ssh/environment.$HOSTNAME
Subscribe to:
Posts (Atom)