Procrastiblog

February 8, 2007

Ubuntu’s GCC 4.1 and -fstack-protector

Filed under: Linux, Tech — Chris @ 1:54 am

Ubuntu quietly made -fstack-protector (i.e., ProPolice support) the default in their GCC 4.1 binary. (I think it’s also the default in OpenBSD.) Unfortunately, this breaks some builds, especially (I think) if you’re trying to build a kernel module. If you get an error that mentions the symbol __stack_chk_fail_local, like the one below, you got bit by this bug.


/usr/bin/ld: .libs/cr_checkpoint: hidden symbol `__stack_chk_fail_local' in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

Either re-build your libraries with -fstack-protector or add -fno-stack-protector to CFLAGS. If this doesn’t work, you can try gcc-4.0, which predates the introduction of ProPolice, but this probably won’t work if you’re compiling a kernel module, because they have to be compiled with the same compiler as the kernel.

February 7, 2007

Fi, O Fi

Filed under: Emacs, Linux, Tech — Chris @ 7:52 pm

When I cut-and-paste from PDF into Emacs, ligatures come out weird. “specific” comes out . (Note that I had to make that an image, because pasting the same text into a Firefox window renders the ligature correctly. The gobbledygook is a control code that is properly understood by the standard GUI fonts. Note also that the cut-and-paste version is a ligature (fi), but the version I type in directly is not (fi).) Of course, there’s ligatures besides “fi”, and hyphenation is always a problem. Is there a magic Emacs incantation to make this work correctly?

Pop-ups, a Third Way

Filed under: Tech, Waste of Time — Chris @ 4:19 pm

If you set Firefox to block pop-ups, you get this message when a page requests a pop-up:

This is accompanied by a Preferences button with the following options:

Why only “allow pop-ups for this site”? Why not “allow this one pop-up that I’m pretty sure I want to see, but protect me from future nefarious pop-ups”?

This properly belongs in Bugzilla, but I’m sure the developers would tell me I’m stupid and ignore me. See, e.g., this bug that I voted for, like, two years ago.

UPDATE: As I suspected, Bugzilla has entries for why this isn’t really a bug and why you don’t want what you think you want.

January 27, 2007

Linux Wireless: Almost There

Filed under: Linux, Tech — Chris @ 11:44 pm

I finally gave up on ever getting my old Broadcom BCM4401 wireless card to work under Linux, so I went out and bought an Intel 3945ABG card (which is actually one of the cards Dell ships with my laptop model, just not the one I happened to get (through no fault of my own)). Out-of-the-box support from the stock ipw3945 driver. Plays nice with the Network Manager and the proprietary nVidia driver. Suspend works. Sweet.

Having taken a moment to appreciate this vast improvement in my computing situation, I will now proceed to bitch. Every now and then—say every 3rd or 4th time I suspend—the wireless card doesn’t come on after I resume. All I have to do is “rmmod ipw3945; modprobe ipw3945” and it comes back fine (which is better than manually fussing with the ESSID, which I have often had to do in the past).

I filed a bug on this and one of the maintainers suggested I add the module to the “suspend blacklist”. I politely asked both the maintainer and Google what and where the “suspend blacklist” is, but I’ve gotten no answers. There’s a bunch of scripts in /etc/acpi that seem relevant, but from what I can tell, they should already being doing what I want to hack them to do. Which might mean they’re not even being used anywhere anyway…

At less frequent intervals—say every 9th or 10th time I suspend—the module is “busy” when I try the unload/reload step and I have to reboot to get things back in order. I can’t figure out how to find out which process has a lock on the module either…

Bah!

January 22, 2007

Printing on Index Cards*

Filed under: Tech — Chris @ 1:59 am

Fun! Preferably, the document in question will already be in a 3×5 layout. I recommend Adobe Acrobat Reader and not one of your light-weight and/or free alternatives. Now, just because you have a printer preset called “Index Cards” doesn’t mean you can just go hitting Ctrl-P and expect things to work. Go to “File -> Print Settings” and choose “Index Cards” in there. Now hit Ctrl-P and maybe “Index Cards” is already chosen or maybe you should choose it now. Cross your fingers and go for it.

* This post assumes that you already set up your index card presets a year ago and have merely forgotten how to use them. I.e., that you are me. Good luck to everybody else.

January 18, 2007

Wiki Spam II

Filed under: Tech — Chris @ 4:58 am

The preceding flurry of posts was brought on by the imminent demise of my Columbia student account, my inability to get the PHP-based PmWiki working on the NYU servers, and my realization that all of the code supporting community editing of this stuff was a waste of bits. Whereas this blog is the most parsimonious use of bits imaginable. Have a nice day.

LaTeX

Filed under: Tech — Chris @ 4:44 am

[Editor’s Note] This is old material imported from my now-defunct Wiki

Here’s where things about LaTeX get discussed. I’ll have you know that WikiWords kind of drive me nuts and the title of this page should give you a hint why.

The single best hint I can give anyone using LaTeX is to bookmark /usr/share/texmf/doc/index.html. (This is assuming a standard teTeX installation (including the package tetex-doc) on Red Hat Linux or Ubuntu. On Mac OS X, fink installs the docs in /sw/share/texmf-dist/doc.) For some reason, it took me several years to discover this documentation and it has almost totally replaced the Lamport and Goossens books for everyday reference. One problem with the books (especially the graphics book) is that they are out of date and some of the key packages documented have changed. The online documentation is also out of date, but not quite so much. The documentation is mostly in DVI format, so you will have to have a working DVI viewer (e.g., xdvi) or convert them to PS/PDF.

UPDATE: I recently acquired the 2nd edition of the companion book and it is really great. It answers a lot of the questions I wanted to cover on this page, particularly about fonts!

pdfLaTeX and letter paper

On many systems, pdfLaTeX defaults to A4 output, even with the letterpaper option to the article class. The simplest solution: add \usepackage{hyperref} to your preamble. hyperref sets the right paper size for PDF output (as if by magic). Thanks for this tip goes to Oliver Haynold at Northwestern University.

NOTE: The tip works, but I’d like more info on root causes.

Future Work

Some things I’d like to put here:

  • A definitive discussion of Type 1 fonts, etc. What is the difference between “\usepackage[T1]{fontenc}” and “\usepackage{times}” (and the like)? What is the purpose of “dvips -P cmz” or “dvips -P pdf“?
  • How to fix the braces in alltt without breaking math mode.
  • Tips for dealing with pstricks, .eps files, and positioning graphics.
  • Paper sizes… or, why can’t letter and A4 get along?
  • Prosper, HA-Prosper, slideware, ugh…

January 17, 2007

Printing LNCS format PDFs

Filed under: Tech — Chris @ 4:53 am

[Editor’s Note] This is old material imported from my now-defunct Wiki

(Non-academics: just scratch your head and walk away…)

LNCS format papers from SpringerLink have always been a frustration to me. They are an odd digest size (not letter, A4, or A3, AFAIK) with wide margins. Printing them 1-to-1 on letter paper is a waste—the font blows up to almost 14 points with 2 inch margines. Printing them naively 2-to-1 landscape letter makes the font too small and the margins too big (especially down the middle).

I just spent a few minutes hacking up a solution with pstops (part of psutils). Here it is:

acroread -toPostScript -size letter lncsdoc.pdf
pstops '2:0L@.7(8in,0)+1L@.7(8in,5in)' lncsdoc.ps lncsdoc.2up.ps
ps2pdf lncsdoc.2up.ps lncsdoc.2up.pdf

I’ve tested this on a few papers and it seems to work.

Caveats: It might generate sub-optimal or even broken Postscript (Acrobat Reader seems less happy with the final PDF than it is with the original, maybe just because there’s twice as much PS data on each page). The file lncsDoc.2up.ps doesn’t have the right size and orientation parameters in GhostView. The parameters to pstops may be installation-specific.

For the pstops-curious, the second command does the following:

2: – groups the input pages by twos
0L – takes the first page of each pair and rotates it left
@.7 – then scales it down by 0.7
(8in,0) – then moves it 8 inches down (the point of rotation seems to be the lower left corner, meaning without translation, the rotated (logical) page is no longer on the (physical) page)
+1L – takes the second page of each pair and rotates it left
@.7 – then scales it down by 0.7
(8in,5in) – then moves it 8 inches down and 5 inches across (I guess the left/right pages start from the same point!)

Modifications to the scaling factor and translation are all that should be necessary for personal taste/local compatibility.

NOTE: This may be applicable to other Springer formats, but I’m not familiar with them.

[UPDATE 3/12/2007] The right parameters for this turn out to be a constantly moving target. Here’s the command that currently works best for me on Ubuntu Gutsy:

pstops '2:0L@.8(8.5in,-.25in)+1L@.8(8.5in,4.5in)' lncsdoc.ps lncsdoc.2up.ps

[/UPDATE]
Alternative One-liner

cat lncsdoc.pdf | acroread -toPostScript -size letter | pstops '2:0L@.7(8in,0)+1@.7L(8in,5in)' > lncsdoc.2up.ps

Caveats: The generated PS file doesn’t work with ps2pdf, for some reason. It also didn’t print the last page, when I used lpr on it. It looks like somehow the PS file doesn’t get properly closed off. Suggestions are welcome.

Alternative Non-Adobe Solution

The following works, but produces awful screen output. I guess pdf2ps doesn’t get the right fonts or something. It also has the wrong orientation in both GhostView and Acrobat Reader.

pdf2ps lncsdoc.pdf lncsdoc.ps
pstops '2:0L@.85(7.75in,0.5in)+1L@.85(7.75in,5.5in)' lncsdoc.ps lncsdoc.2up.ps
ps2pdf lncsdoc.2up.ps lncsdoc.2up.pdf

I’m not sure if pdf2ps is a standard utility or just some random thing I downloaded (from here for example). It boils down to the following:

gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -sOutputFile=lncsdoc.ps -c save pop -f lncsdoc.pdf

Where gs is your friendly local GhostScript install.

Windows XP to A4 paper

pstops '2:0L@.85(9.5in,-.5in)+1L@.85(9.5in,5in)' lncsdoc.ps lncsdoc.2up.ps

Or is it better to just scale up with pstops and let psnup do the rest?

pstops '2:0@1.3(-22mm,-58mm),1@1.3(-48mm,-58mm)' lncsdoc.ps | psnup -2 > lncsdoc.2up.ps

The former file is a little smaller. And they both look bad in GSview.

[UPDATE] So you can make up your own mind whether I’m crazy for giving this any thought at all, here’s a comparison on a paper I just happen to be reading today.

Standard LNCS format (2 pages):

Those are (approximately) 2 inch margins and a 12+ point font. (The copyright notice eats into the bottom margin a bit at left, but it’s not present past page one.)

Using GNOME/Evince standard “Pages per side: 2” print option:

Look at that gutter! The bottom margin is more than 3 inches.

Using acroread -toPostScript and the above pstops command:

Better…

It’s totally not worth it, is it?

[UPDATE 2] I’ve created a shell script that simplifies the process described above: it takes an LNCS-formatted PDF or Postscript file and generates a 2-up Postscript using acroread (for PDF inputs) and pstops. Download here. Note: The script will probably have to be tweaked for system-specific pstops settings, as above.

Development Tools on Mac OS X

Filed under: Tech — Chris @ 4:48 am

[Editor’s Note] This is old material imported from my now-defunct Wiki

I’ve been using Mac OS X 10.3 (Panther) since it was released. I regularly use Unix tools like make, gcc, latex, etc. I recently had a catastrophic hard disk failure and just got around to re-installing my development environment. The hard disk came from the shop loaded with the OS, but no Developer Tools. I put in my XCode Tools install disc and installed all of the Apple Developer Tools. Afterwards, I got the following error trying to run gcc on anything:

  % gcc t.cld: can't locate file for: -lcrt1.o

Thanks to Dan Smith on MacInTouch I discovered my re-install routine wasn’t sufficient. The repair shop probably installed the OS off a backup disk that didn’t include development libraries; the XCode disc isn’t careful about checking library dependencies.

If you’re installing development tools on a fresh hard disk (or even a brand new Mac, probably), you need to make sure you have the following files in /usr/lib: bundle1.o, crt1.o, dylib1.o and gcrt1.o. If they’re not there, either: (1) do a fresh install off the OS discs, or (2) download and run the full XCode 1.1 or 1.2 installer from the Apple Developer Site (Log In (free registration) -> Downloads -> Mac OS X -> XCode Tools).

Problems with Ghostview

After installing Fink 0.7.2 and using it to install Ghostview 3.6.1-4, I got the following error trying to run gv:

  % gvWarning: Representation size 4 must match superclass's to override highlightedBackgroundWarning: Unsupported shape style for Command widget "toggleCurrent"Warning: Unsupported shape style for Command widget "toggleEven"Warning: Unsupported shape style for Command widget "toggleOdd"Warning: Unsupported shape style for Command widget "unmarkAll"Warning: Unsupported shape style for Command widget "autoResize"Warning: Representation size 2 must match superclass's to override internalWidthBus error

This is apparently a problem with the Fink binary distro of gv. If you rebuild from source (i.e., fink rebuild gv) it should work fine (assuming that all of your X11 dev libraries are set up right—don’t let Fink install XFree86 over your Apple X11 install! (Unless, of course, you know what you are doing)), .

Links

MacInTouch has an incredibly large collection of tips for Panther users, as well as for all kinds of other Mac-related subjects.

January 10, 2007

JPEGs in Subversion

Filed under: Tech — Chris @ 8:41 pm

If you’ve got a JPEG under Subversion and it looks like this

when it should look like this
,
maybe Subversion thinks it’s a text file. Try

svn propdel svn:eol-style MY.jpg
svn propset svn:mime-type image/jpeg MY.jpg

Brought to you courtesy of this guy

Bonus fact: if you’re accessing Subversion via svn+ssh and it asks for your password more than once, fret not. Subversion and SSH are just really dumb. See here.

« Newer PostsOlder Posts »

Create a free website or blog at WordPress.com.