Archive for the ‘How To’ Category

How to change your default shell

Tuesday, August 12th, 2008

I ain’t never going to remember this, so into the blog it goes:

$ chsh -s /path/to/fish

Masochists should substitute “fish” for whatever less friendly shell they prefer.

apache2: apr_sockaddr_info_get() failed for somehost

Thursday, August 7th, 2008

Hypothetically speaking of course, let’s assume you forget to renew a domain name. And suddenly that domain’s email is not working. And then you notice the site is down. The next step is, logically speaking, to panic, followed by an attempt to figure out what the hell is going on. Which usually means restarting Apache. Which results in:

apache2: apr_sockaddr_info_get() failed for yourhost

Which is, wow, an exotic new error. If you see this it means that, even though Apache says its restarting, really its probably not. And now all your other sites are down. And, so, more panic. More panic for you.

Now that you’ve probably realized that the default domain name has expired, you will want to get Apache back up on a different, actually non-expired domain. Like this:

$ hostname actual-non-expired-domain-name.com

Now restart.

Alternatively if your hostname is set to something like “www”, probably you can change the default site in vhosts so that Apache can connect the hostname to the tld.

This is all hypothetical of course.

Sherlocking Linux Distros

Wednesday, July 16th, 2008

You login to a mysterious new box. There is no login message. You poke around and before long you start to wonder “So what the heck distro is this anyway?”

$ uname -a
just tells you all about the kernel. Hmmm.  A mystery.

To pull up details on the distribution, take a peak in /etc/issue. This text file is often what is presented to users after they login, and typically contains distribution specific details. Likewise, look for /etc/*release or /etc/*version, which various distributions use to tag the release version.

Elementary!

Emacs Japanese Input

Saturday, July 12th, 2008

If you ever find yourself stuck relying on the IME built-into Emacs (rather than the IME native to your OS), here are the essential key strokes you’ll need to know.

  • C-\:  toggle input mode (ime on or off)
  • C-h:  shows conversion options if used when in conversion mode
  • SPC: transform input to kanji, or show the next conversion candidate
  • DEL:  abort conversion
  • C-n: show the next conversion candidate
  • C-p: show the previous conversion candidate
  • C-o: lengthen conversion bunsetsu
  • C-i, TAB: shorten conversion bunsetsu
  • Shift-k:  toggle between hiragana and katakana
  • qq:  toggle between alphabet and kanji modes
  • qz:  turn on zenkaku alphabet mode
  • qh:  turn off zenkaku alphabet mode

Also useful:

  • C-x RET l:  set the buffer language environment
  • C-x RET C-\:  select the input method

How to automatically carbon copy all of your email to George W. Bush

Friday, July 11th, 2008

Now that the Senate has decided to grant retroactive immunity to the telecoms (video), it probably won’t be long before the Bush Administration starts routinely tracking your search habits, mining your email, and monitoring your phone calls.  This kind of automated profiling will allow the NSA to determine, among other things, your propensity for terror.  Yes, soon the Bush Administration will be protecting us all from ourselves.

But I say, why wait?! I want the Bush Administration to protect me from myself right now!  Am I a subversive?  Could I be a terrorist?  I need to know!  And I’m sure you do as well.

That’s why I have started automatically carbon copying all of my email to George W. Bush.  Okay, well, technically I’m carbon copying them all to Dick Cheney because it would appear that Cheney reads Bush’s email for him.  But I have every confidence that Mr. Cheney will keep the president abreast of my goings on.

If you’re a Microsoft Outlook user, here’s how you too can automatically carbon copy all of your email to the White House.

  1. In Mail, on the Tools menu, click Rules and Alerts.automatic-carbon-copy-1 How to automatically carbon copy all of your email to George W. Bush
  2. On the E-mail Rules tab, click New Rule.
    automatic-carbon-copy-2 How to automatically carbon copy all of your email to George W. Bush
  3. In the Rules Wizard dialog box, under Start from a blank rule, click Check messages after sending, and then click Next.
  4. Click Next.
  5. A confirmation will appear, notifying you that this rule will apply to every message that you send. Click Yes.
  6. Under Step 1: Select action(s), select the Cc the message to people or distribution list check box.
    automatic-carbon-copy-3 How to automatically carbon copy all of your email to George W. Bush
  7. Under Step 2: Edit the rule description (click an underlined value), click people or distribution list.
  8. In the Rule Address dialog box, click a name or distribution list, and then click To. Repeat this step until all names or distribution lists you want to add are included in the To box.
  9. Click OK.
  10. In the Rules Wizard dialog box, click Next.
  11. Click Next.
  12. Under Step 1: Specify a name for this rule, enter a name that you will recognize for this rule.
    automatic-carbon-copy-4 How to automatically carbon copy all of your email to George W. Bush
  13. Click Finish.

That’s it!  Now all of your email will be automatically carbon copied to Dick Cheney at the White House, who will update President George W. Bush, who will work with the NSA to figure out if you are a terrorist or not.  Because, let’s face it, who knows what you’re capable of?  Act now before it’s too late!

Remote PHP Debugging with Emacs

Saturday, June 21st, 2008

It’s an Emacs weekend here at blog.arithm.

I was recently asked if it was possible to do remote PHP debugging with Emacs. We’re talking about Emacs, so the answer is:  Of course!  How to do it:

  1. Grab Tohru Fujinaka’s GEBEN library.  It’s an aging alpha release, but works fairly well.
  2. Make sure you also have CEDET installed.  I’m using the 1.0 pre4 release.
  3. Drop debugclient somewhere in your path.  (Here Emacs is running on Windows, so I just threw it into the C:\WINDOWS\ directory.)  Make sure the executable is named “debugclient” and not “debugclient-0.9.0″ or whatever.
  4. If you’re using the standard xdebug port 9,000 (recommended), make sure that port is open on your firewall.  For most folks these days that means opening up the default OS firewall as well as forwarding a port from the router.  See the exceptional portforward.com for more information on router port forwarding specifics.

Now, assuming you already have xdebug plugged into PHP, modify php.ini or an .htaccess file with the following settings:

  • xdebug.remote_enable = true
  • xdebug.remote_handler = dbgp
  • xdebug.remote_host = your_client_ip

For security reasons it’s wiser to do this via .htaccess on directories that permit only authenticated access.

To debug, ask Emacs to listen for connections by going into GEBEN Mode with Meta-x geben. You should see “xdebug started.” in the status row at the bottom of the Emacs window.

Run your PHP script with the xdebug switch on, eg.

http://www.example.com/script.php?XDEBUG_SESSION_START

If everything is setup correctly, Emacs will load the source of script.php (be wary of security!) and allow you to step through the code.

Available commands are:

spc step into/step over
i   step into
o   step over
r   step out
b   set a breakpoint at a line
u   unset a breakpoint at a line
g   run
q   stop

Some gotchas: I’ve noticed the GEBEN expects the first keystroke to be “space”; often it will freeze otherwise.  GEBEN may also run into problems on certain session-related PHP commands.

Happy debugging!

Set Emacs’ HOME directory in Vista

Saturday, June 21st, 2008

Rather than allow Emacs to assume HOME is c:\ (which will cause Vista to winge every time you want to modify your .emacs file), try the following:

setx HOME "%USERPROFILE%"

This will make home something like c:\Users\username.

Now you can keep your .emacs in a far more rational place and not have to wake up the Vista security troll whenever you want to do some tweaking.

Undo in Emacs

Friday, June 20th, 2008

There are a variety of ways to “undo” something in Emacs.  Unfortunately some of the keystrokes work in some environments, while others do not.  Here’s a quick rundown:

  1. Meta-x undo — Will undo only the most recent changes.  Cannot be used multiple times.
  2. Ctrl-x u — Undo.  Consecutive repetitions will undo earlier and earlier changes.
  3. Ctrl-_ or Ctrl-/ — Same as Ctrl-x u, however does not work in some envrionments.
  4. Ctrl-Shift-Minus — Same as Ctrl-x u, however does not work in some environments.

For whatever reason I can never remember the Ctrl-Shift-Minus sequence when I find myself in an environment where Ctrl-_ and Ctrl-/ don’t work.

Keep in mind that Emacs undo is a bit different from traditional undo:  Undo actions themselves are recorded as actions.  This can be confusing.

In some environments, Ctrl-x Ctrl-_ will reverse the order of undo.  I avoid this out of fear that it will cause the universe to implode.

See the Emacs info node for more good undo lore, such as how to use “selective undo” which restricts undo actions to changes performed in the current active region.  (Very useful.)

Portage Logging

Thursday, June 5th, 2008

Something else I should have known about long ago.   To turn on logging in portage, simply add the following to /etc/make.conf:

PORTAGE_ELOG_CLASSES="warn error log"
PORTAGE_ELOG_SYSTEM="save"

The will add log files for each package to /var/log/portage/elog/:

# ls -lah
total 108K
drwxrws--- 2 portage portage 4.0K 2008-06-06 01:13 .
drwxr-xr-x 3 root    root    4.0K 2007-10-04 12:29 ..
-rw-r--r-- 1 root    portage  200 2008-06-06 00:58 dev-db:postgresql-8.0.15:20080605-155810.log
-rw-rw-r-- 1 root    portage  72K 2008-06-06 00:44 summary.log
-rw-r--r-- 1 root    portage   67 2008-06-06 01:06 sys-apps:coreutils-6.10-r2:20080605-160624.log
-rw-r--r-- 1 root    portage  108 2008-06-06 01:08 sys-apps:shadow-4.0.18.2:20080605-160842.log

Useful to have around when you miss a barrage of announcements after a large emerge.

Fix the mktemp / coreutils block in Gentoo

Friday, May 30th, 2008

Looks like mktemp is now provided by coreutils.  No wonder.  This block has been bugging me (read: I’ve been ignoring it) for months.

To fix just unmerge mktemp and update coreutils.

Update: Same for the setarch / util-linux block should you come across it.  Unmerge setarch.