- Check what the clipboard contents are: xsel -b
- Put foo in the primary X selection: echo foo | xsel -p
- Copy the clipboard to the primary X selection: xsel -b | xsel -p
This is just a hint on how to copy/paste between X programs that cannot agree on which X buffer to use. Say you have the xterm which uses the primary selection, and you have some silly java program program which only uses the clipboard. What do you do if middle click doesn’t want to paste your console output.
An ugly workaround is to fire some editor that supports both and keep pasting with one method and copying with the other before pasting in the final destination. Middle click in gvim to paste what you selected in your xterm, then select the text in gvim and copy it to the clipboard.
Or, you can use xsel. The simple features of xsel are to put something in one of the selections (if there is anything coming on STDIN) or to output the content of a buffer. So, to put the primary (the one you get when you select text in X) in the clipboard (what editors put their stuff in when you do Ctrl+C) you can do xsel -p | xsel -b.
Posted by chutz on January 7, 2010 at 1:12 am under Software.
Tags: linux
Comment on this post.
I just had a very hard time trying to change my address on the JAL Mileage Bank page. They still had my address from about 4 years ago which changed at least a couple of times since then. When I tried to change it I realized why.
I submitted the form, properly filled with full-width characters (including the digits) and on the confirmation screen I get the same form filled with mojibake asking me to complete it correctly. You have guessed already - nothing I type in there would actually help.
Firebug to the rescue! I opened the form in Firebug, added an enctype=”multipart/form-data” to the form element and surprise, surprise - my input was accepted.
Posted by chutz on November 10, 2009 at 12:30 am under Software.
Tags: cjk, Web
Comment on this post.

Finally! A set of fonts that look good and properly display Japanese and Cyrillic. That is, the Cyrillic is half-width as it is supposed to be. For Gentoo users the package is media-fonts/efont-unicode or there is the official page for everyone else. Some characters like the lowercase б and д are oddly designed but that’s a very small price to pay for the pleasure of not having to mix and match different fonts in my terminal configuration.
I wish I’d known that a little earlier.
Posted by chutz on October 11, 2009 at 4:18 pm under Software.
Tags: cjk, fonts, linux
Comment on this post.
The built-in SD card reader on my Thinkpad x60 has been always giving me headaches. It works reliably well, but when copying files my system becomes very unresponsive. The mouse is jerky and the CPU usage jumps through the roof. Obviously, DMA is not being used.
I couldn’t find much about it for a while but just today, when I included the chip id R5C822 of the reader in the search I found this thread.
However, instead of patching the source itself, it is quite easy to force the quirk when loading the sdhci module. Put the following in modprobe.conf or /etc/modprobe.d/local.conf and everything will be fine after you reboot.
options sdhci debug_quirks=2
You can also reload the module to check if it is fine even now.
- umount any SD cards that you have mounted
- modprobe -r sdhci-pci
- modprobe -r sdhci
- modprobe sdhci-pci
That’s all folks. Enjoy a true multitasking Linux.
Posted by chutz on August 15, 2009 at 6:31 pm under Hardware, Kernel.
Comment on this post.
When trying to install grub2 (whatever snapshot was current as of today) I kept getting the following error:
$ sudo /sbin/grub-setup -v --directory=/media/sysrescd/boot/grub \
--device-map=/media/sysrescd/boot/grub/device.map -r '(hd1,1)' '(hd1)'
.... snip ...
grub-setup: error: Cannot read `/media/sysrescd/boot/grub/core.img' correctly
The error was not very descriptive because grub was apparently able to read other important files like boot.img and such. The filesystem on my USB stick was identical (feature wise) to the /boot on my HDD — ext2. And the same command worked just fine for installing to my hard disk.
Digging through the code revealed where the problem is. The error was caused by grub-setup being unable to embed core.img in the MBR. The core.img prepared by grub-mkimage was 25k big. That is about 50 sectors. The first partition on my hard disk starts on sector 63. The first partition on my USB stick was starting on sector 32 (or was it 31?). 32 < 50 => core.img cannot be embedded. If only the error message had been a little clearer it would have saved me some headache.
Destroying the first partition on the USB stick and recreating it starting from sector 63 fixed the problem.
Posted by chutz on May 6, 2009 at 2:53 pm under Software.
Tags: linux
4 Comments.
Me, a long-term Windowmaker user, recently switched to Gnome. There main reason is that I had wanted to drop Windowmaker for a while now. There has been no development for a while now and I don’t really like the fonts or the lack of themability of window borders and such.
I decided to give Gnome a try because I’ve always liked the appearance of Gtk applications and a full Gnome desktop can run without having to run a zillion processes in the background. I have looked at KDE but it just doesn’t feel right.
One feature I really liked in Gnome was the automounting of removable media. It didn’t work smoothly because there are a few prerequisites:
- Your user must be in the plugdev group
- You must not have an entry for the device in /etc/fstab
The last one is mostly speculation, but when I removed the lines in /etc/fstab (leftovers from the windowmaker era) it all started working.
I still prefer the Windowmaker style Alt+<Right Click and Drag> to resize a window. With Gnome (or more correctly, with metacity) it is Alt+Middle click and drag… and that’s not too convenient.
Posted by chutz on January 4, 2009 at 2:06 am under Software.
Tags: gnome, windowmaker
1 Comment.
A common issue — setting the onSubmit event handler of a form with JavaScript. I mean, it’s easy enough to set it with
<form id='theForm' onsubmit="return confirm('Really submit?');">
but here is how to do it with JavaScript
<script type='text/javascript'>
document.getElementyById('theForm').onSubmit =
function() { return confirm('Really submit?'); };
</script>
Posted by chutz on August 14, 2008 at 5:50 pm under JavaScript.
Tags: HTML, JavaScript
Comment on this post.
I have had to write an HTML parser a few times already and I’ve always used HTML::Parser. Because it’s simple and because I never bothered to do it anohter way. I always wanted to ideally do some parsing with XPath because that way I can easily find what I need with one or two queries. Unfortunately, XPath only works on properly formatted XML documents, so unless the page I am parsing is XHTML, I couldn’t do much.
I also wanted to somehow convert the HTML to properly formatted XHTML and use XPath with that. Unfortunately, I didn’t know an easy way to do that either. Well, now I do. I can use the HTML::TreeBuilder module from HTML-Tree CPAN distribution. It is easy enough to use the module itself for parsing:
my $tree = HTML::TreeBuilder->new_from_file("test.html");
my @img = $tree->look_down('tag', 'img',
sub { $_[0]->attribute(”src”) =~ m!thumbnail!; }
However, as I would rather use XPath, here is how to easily convert the HTML to XML so that is parseable with XPath:
my $xml = HTML::TreeBuilder->new_from_file("test.html")->as_XML();
my $xp = XML::XPath->new( xml => $xml );
my @img = $xp->find('//img[contains(@src, 'thumbnail')]);
And as always, use whichever approach is fit for the task at hand.
Posted by chutz on August 8, 2008 at 1:47 pm under Perl.
Tags: HTML, Perl, XML, XPath
4 Comments.
Visual Studio 2005 does not want to profile my ASP.NET project! What’s up with that?
This is with the Team Edition that has the quite useful “Performance Tools” included. However, when I start a new Performance Wizard I don’t see my ASP.NET web site project in the list of profileable projects.
To make a long story short, the solution is to not select the “No Start Page” option in the debug dialog as shown in the following figure.

Checking “Current Page” does not work either. Just to be safe, go with “Specific Page” and pick something from the list.
Posted by chutz on August 7, 2008 at 12:20 pm under Software.
Tags: .NET, ASP
Comment on this post.
A nice feature in XEN that I miss in KVM is the ability to use a single partition as a disk image. In XEN you can do
disk = [ 'file:/dev/vg0/img_root,sda1,r' ]
and you can also safely mount /dev/vg0/img_root when the virtual machine is not powered on.
With KVM you’re out of luck, or at least my googling returned lots of questions and no solutions.
Well, there is a not so hard way of working around the issue.
Continue reading ‘KVM: virtualize a single partition’ »
Posted by chutz on July 17, 2008 at 12:49 pm under Virtualization.
Tags: kvm, Virtualization, xen
Comment on this post.