Posts in June, 2003
Taken from this week's Gentoo Linux Newsletter .
Code listing 9.1: Local machine:
// This command allows the machine with the IP 192.168.1.3 to connect
# xhost +192.168.1.3
On the remote machine, you need to export the $DISPLAY variable to
your local machine. After that, you should be ready to run GUI programs
remotely.
Code listing 9.2: Remote machine:
# export DISPLAY="192.168.1.2:0.0"
# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.
Note
This is very unsecure and not recommended since everything you
type including passwords will be transmitted over the network
unencrypted.
To tunnel the connection over SSH and thus encrypt the traffic edit your
/etc/sshd2_config file.
Code listing 9.3: /etc/sshd2_config:
// Add or edit the following line
ForwardX11 yes
Now connect from the local machine to the remote machine via ssh and
start your X application.
Code listing 9.4: Remote machine:
# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.
Notice that you don't have to set the DISPLAY variable, ssh
automagically does that for you. You do however have to allow access to
your local machine's X server (see above).
I came across an announcment of a Subversion plugin for Eclipse .
I'd love to see one for jEdit. It's written using svnup , so
a jEdit plugin should be possible - maybe as a VFS?
I've just released SendKeys module 0.3 for Python. SendKeys is a
Python module for Windows (R) which can be used to send one or more keystrokes
or keystroke combinations to the active window.
It's been a little while in coming, as I started it roughly 6 or 7 weeks ago,
but it's already been through a few iterations. First, I wrote the
low-level win32 code, using ctypes . Second, I wrote a Python
extension module using Pyrex , instead of ctypes . Lastly, I re-wrote
the extension module in c.
In this week's Gentoo Weekly Newsletter , there's
a link to an article on Gentoo Forums on setting
up a local rsync mirror for portage.
Earlier today, version 0.4 of the Configurable Fold Handler Plugin
was announced on jedit-devel. Using the following regexps,
one can fold VB code. Improvements or suggestions welcome.
- Fold start string:
- ^(?:Public|Private)?\s*\b(?:Sub|Function|Property|Type)\b
- Fold end string:
- ^End\s+(?:Sub|Function|Property|Type)\b
A co-worker of mine, Tim Perry, sent me a useful link today.
If you've ever used cvs, at some point you've probably added an
image or some other binary file to the repository, w/o using
cvs add -kb <filename>. Here's an example of using cvs admin
to fix the problem:
$ echo '$Id$' > kotest
$ cvs add -m"A test file" kotest
$ cvs ci -m"First checkin; contains a keyword" kotest
$ cvs admin -kb kotest
$ cvs update -A kotest
# For non-unix systems:
# Copy in a good copy of the file from outside CVS
$ cvs commit -m "make it binary" kotest
These days, most of my attempts to do anonymous checkouts or updates
from SF.net's CVS repositories result in timeouts. For projects I'm
a member of, I can use my account, but for others I just have to keep
trying until an attempt doesn't timeout. After getting sick of doing
that, I wrote a little script to do it for me.
The script below keeps trying to update until it's successful. After
each failed attempt, it pauses for 5 seconds before trying again.
#!/usr/bin/env python
import os, sys, time
DEFAULT_CVS_ARGS = '-z9 -q up -dP'
SLEEP = 5 # seconds
def main(args=None):
if args is None:
args = sys.argv
cvs_args = ' '.join(args[1:])
if not cvs_args:
cvs_args = DEFAULT_CVS_ARGS
cmd = 'cvs %s' % cvs_args
print 'running %s...' % cmd
while 1:
r = os.system(cmd)
if not r:
break
for i in range(SLEEP):
time.sleep(1)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
# :indentSize=4:lineSeparator=\n:noTabs=true:tabSize=4:
Here's what it looks like running:
C:\sandbox\ctypes>cvsup
running cvs -z9 -q up -dP...
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
cvs [update aborted]: Error reading from server cvs.sourceforge.net: -1
cvs [update aborted]: Error reading from server cvs.sourceforge.net: 0
P setup.py
M samples/Windows/FindFile.py
M samples/Windows/wtl/readme.txt
P source/_ctypes.c
P source/callproc.c
P source/ctypes.h
P win32/com/register.py
P win32/com/server.py
P win32/com/samples/server/test_w32.py
P win32/com/tools/readtlb.py
C:\sandbox\ctypes>
With jEdit 4.2 (currently in development), jEdit can be used by other
applications as an external editor. Using the -wait command line
argument, jEdit can open a view and wait for the view or buffer to be
closed before the process exits. Note that this works whether or not
jEdit is already running.
With the following in my "AUTOEXEC.BAT" file, I can use jEdit to edit
commit messages when using CVS or Subversion:
SET EDITOR=c:\j2sdk1.4.2b2\bin\java -jar c:\jEdit\jedit.jar -wait -newplainview
Note that this will NOT work using the jEdit Launcher for Windows, as that
doesn't handle all command line arguments that jEdit supports.
Earlier this afternoon, I blundered across a post by Paul Moore, on
python-list which showed how to use Twisted for port forwarding.
Here's the relavent snippet:
$ mktap portforward -p 8000 -h remote -d 20
$ twistd -f portforward.tap