linux

You are currently browsing articles tagged linux.

This is mostly just a note for myself, since I always seem to forget it when I set up a new OSX machine.

When SSH’ed into remote machines, usually Linux boxes running Debian, I’ve found that my backspace key doesn’t work properly in OSX Terminal. There’s a fix you can do in termcap that’s probably more robust, but I’ve found that setting your terminal type to rxvt does the trick nicely:

rxvt OSX Terminal Setting

Tags: , , , , ,

Lately I’ve been working on a pretty hefty spec for work (hint hint… it’s a REST API spec). I like writing my specs in TextMate using MediaWiki markup, so I can easily post them to our internal wiki once they’re ready.

One of the annoying things about this spec is that it involves dozens of examples in XML and JSON that are embedded in <pre> tags. I wanted to be able to develop and edit these samples as native XML and JSON files for convenience, but it was becoming a real pain to keep them updated in the main document via cut and paste. The obvious solution to this problem is a text preprocessor that would allow you to include a .xml file in the main .wiki document. There are dozens of these, but they’re all a pain in the butt to use and I didn’t feel like setting them up.

The solution, which couldn’t possibly be more obvious, was suggested, somewhat jokingly, by a coworker of mine:

cpp

Yup, the good old GNU C Preprocessor. If you run Linux, or you have a Mac (basically, any *nix), or you do any development whatsoever, chances are you have one hiding out on your machine somewhere. Chances are you’re also familiar with the #include "foo.h", which you’ve used since freshman year to have the preprocessor include the header for another C file before it passes it off to the actual compiler. But you never thought about using it to help you with your homework (or your specs) before.

Well cpp has a handy -P parameter that tells it to forgo the inclusion of the normal linemarkers it includes for the benefit of the compiler. This makes it perfect for simple stuff like embedding one text file in another.

In your main document, use a #include statement to include your example file:

document.txt:

== XML Example ==
The following is an example of the server's response in XML:

<pre>
#include "example.xml"
</pre>

example.xml:

<example>
      <message>Hello World!</message>
</example>

Then use a simple Makefile to build your output document:

Makefile:

all:
        cpp -P document.txt document.out.txt

Using a Makefile means you can use TextMate’s Makefile bundle to quickly and easily build your document.

There you go, a completely “duh” way of doing simple text includes on any *nix system.

Tags: , , , , , , ,

Maybe this will save somebody else some time, because I just spend about 3 hours banging my head against the wall on it.

PowerBook Stickers

If you’re getting a “550-Sender verify failed” error when Monit starts because its trying to send you an email via SMTP to let you know it’s started (or if you’re getting that error for just about any other reason), make sure that the email address that the message is being sent “from” actually exists.

If “monit@yourhostname.com” doesn’t exist, your SMTP server will likely reject the message and cause you all sorts of trouble.

Tags: , , ,

Sam's

Yeah, that hurt. Well, everything seems to be working again…

Tags: , , ,

For the longest time I avoided using ACPI for power management on my Thinkpad X31 (instead I stuck with APM) because I could never get all the little hacks lined up properly. ACPI, since it is done primarily in hardware, requires a lot of tricks to get your machine to suspend and resume properly. Switching out of X, turning off LCD backlights, resetting graphics cards, etc etc. Its a real hassle.

However, if you’re fortunate enough to be running Debian Linux, you can install the “hibernate” package. Hibernate is basically sophisticated Bash script with pluggable options for all the most common ACPI hacks. I had ACPI up and running within minutes.

If you’ve got a Thinkpad X31 or similar machine, feel free to download my hibernate.conf and tweak it to your purposes. The only additions beyond a fairly standard hibernate configuration I had to make were adding hooks to turn the Radeon backlight on and off.

Tags: ,

« Older entries