Posts filed under 'Tools'
Some Unix command line tools display text in colour, if you run them
in the right kind of terminal, of which the Emacs shell isn’t
one. So far this had not really bothered me since in most cases the
colours do not convey all that much information. However, recently I
was playing with Maude, which colours
terms for
debugging purposes. There is no easy alternative for getting hold of
the same information.
A few minutes of googling and experimenting produced the magic Emacs
command
(require 'ansi-color)
followed by customisation of the ansi-color-for-comint-mode variable
(setting it to t) or calling (ansi-color-for-comint-mode-on). This
applies across all comint sessions, not just shell sessions, so it
also affects things like the interactive Maude mode.
Under Emacs one can go further with M-x ansi-term, which creates a
fully-fledged ansi terminal inside an emacs buffer. Finally we can run
Emacs inside Emacs inside Emacs …! Ansi-term is not available for
XEmacs, probably because it is some ghastly hack.
May 10th, 2006
matthias
We’ve been using cvszilla here at LShift, and
one feature we like that we want in Darcs is the ability for the
version-control system to append notes (containing the log message) to a
Bugzilla bug record every time a commit is accepted by our central
repository.
I asked on the darcs-users mailing list, and the response I got indicated that the required functionality isn’t yet implemented. I’ve just pulled the unstable Darcs source tree. If I make any progress, you’ll hear it here first…
May 9th, 2006
tonyg
My colleagues and I have just spent over a week tracking down a
repeated OutOfMemoryError in a fairly complex web application. In the
process we looked at the jmap and jhat memory profiling tools for the
JVM.
Continue Reading March 8th, 2006
matthias
TiddlyWiki is very customisable WikiWiki that lives in a single HTML file. Recently it had a major version release, with some correspondingly major improvements.
Continue Reading January 16th, 2006
mikeb
Today I implemented a JSON reader/writer library for Squeak, and a small extension to Seaside’s existing LivePage features for doing XMLHttpRequest-based server-push.
The JSON code is available on Squeakmap and also via SqueakSource, under either SqueakL (see here and here) or the MIT license. The Seaside extension is still in flux, but I’ll release something as soon as I have something releasable.
August 17th, 2005
tonyg
Does your internet go away occasionally? Do you have a computer hooked up to a moderately loud stereo system? Want to know as soon as the link comes back? Here’s a script (put it in a file, e.g. ~/bin/audible-ping) that pings some outside host, playing a short .wav file when ping finally starts to get some responses:
#!/bin/sh
ping "$@" | \
grep --line-buffered 'bytes from' 2>&1 | \
perl -e 'while (<>) { `play /path/to/the/ping/sound.wav`; }'
It will play the .wav file once per successful ping packet reply. (Obviously you’ll need to come up with your own short beep-like sound file, and replace the path given above appropriately; use play’s --volume=n parameter to adjust the volume to taste.)
We use it here when our DSL connection goes away, running
$ audible-ping 123.123.123.123
on our jukebox computer. (IP address changed to protect the innocent.) We use a literal IP address rather than a DNS name because if your ‘net is AWOL, the DNS query will time out and ping will exit rather than continuing to retry. The script lets us know the very moment our DSL connection comes back.
August 12th, 2005
tonyg
As widely reported (even enthusiastically by people other than Sun themselves), Java 1.5 (otherwise known as Tiger, otherwise known as 5.0) has generics. This is done by erasure originally for reasons of backwards compatibility. The idea was that Sun wanted to be able to compile source code with generics in it and run the generated bytecode on old JVMs. However, apparently late in the day, Sun decided not to, citing reasons of missing Exception classes which is a fairly surmountable problem.
So, if you have any Java source file and compile it with javac from the Java 1.5 SDK, the resulting .class files blow up JVMs which don’t support Java 1.5. javac has -source and -target flags so you can do javac -source 1.5 -target 1.4 to try to get it to compile code suitable for 1.4 JVMs. javac blows up saying that source release 1.5 requires target release 1.5.
So, I created a very simple HelloWorld style program which didn’t use generics and compiled it twice: firstly with -source 1.4 -target 1.4 and then with -source 1.5 -target 1.5. The resulting .class file has 1 byte difference between the two versions (in fact, just 1 bit difference). So, I then wrote some code that uses generics, compiled with -source 1.5 -target 1.5, checked that it blew up if run on a 1.4 JVM and then edited this 1 byte in the class file. The change worked and as a result I could run the code with generics on a 1.4 JVM.
I then made use of Java libraries that have been genericifiedized, the most obvious example being the Collections API. I made the same hack and sure enough, it worked.
The danger is of course that you write code which uses APIs which were only introduced in Java 1.5 or worse, APIs who’s behaviour has changed between 1.4 and 1.5. Using javac from the 1.5 SDK will compile against the 1.5 libraries. When you run it in a 1.4 JVM, it’ll be run against the 1.4 libraries. So, you could try to change the libraries that javac compiles against, or you could change the libraries that java runs against — you could make the 1.4 JVM use the 1.5 libraries. For that to happen you would have to unpack all of the Jars in the 1.5 JRE, make the hack on every class, reassemble, point the 1.4 JVM at these hacked libraries and then hope that it all works.
Of course, I’m not sure that you would want to run with the 1.4 JVM when the 1.5 JVM is available unless there was specific behaviour that you wanted. If the cost of validating your products against a 1.5 JVM was exhorbitant then you could continue to use a 1.4 JVM but tell your developers to start using generics, hack up a 1.5 javac coupled with the 1.4 libraries and a hack to change this one magic byte as a development environment and get generics at no extra cost.
Oh and the magic byte? Well, look at the .class files in a hex mode (hexl-mode in emacs works well here). The first 4 bytes are ca fe ba be. The next three bytes are all zeros. Then the next byte is 30 (ASCII 0) for 1.4 and 31 (ASCII 1) for 1.5.
August 2nd, 2005
matthew
I spent a good few hours trying to convince Gnus to search my IMAP folders, under XEmacs. Googling turned up quite a lot of stuff, but most of it is wrong/irrelevant. In the end all I needed to do was:
- stick
(require 'nnir) in my XEmacs init file
add (nnir-search-engine imap) to my .gnus file, like so:
(setq gnus-secondary-select-methods
'((nnimap "imap.lshift.net"
(nnimap-stream ssl)
(nnimap-authinfo-file "~/.authinfo")
(nnimap-nov-is-evil t)
(nnir-search-engine imap))))
re-byte-compile the nnir.el file in the XEmacs package directory for gnus - on my system that is /usr/share/xemacs21/xemacs-packages/lisp/gnus. For some reason the nnir.elc that comes with the XEmacs gnus package is broken, so unless it gets produced afresh the use of nnir results in mysterious errors.
After that, marking groups in the group buffer and hitting G G prompts for a search string and proceeds to carry out the search. Nice.
July 21st, 2005
matthias
Next Posts