Cheap Bear Canisters

Harbor Freight Bear CanisterHarbor Freight, of all places, sells a bear canister for a mere $29.87. It looks an awful lot like the Garcia Bear-Resistant Container at REI, which sells for $69.95.

I’ve heard this bear canister isn’t approved for use in the Sierra. I have no idea what, if any, certification it’s received.

Posted in Backpacking | 2 Comments

Boot from USB Stick on Biostar TF8200 A2+

I was tired of burning perfectly good DVDs repeatedly for Windows 7 beta testing. Instead, I decided to follow these excellent instructions and copy the contents of the ISO image onto a USB stick and boot from that.

My Biostar TF8200 A2+ motherboard has an American Megatrends BIOS. Configuring it to boot from a thumb drive is a bit tricky. Here are the steps:

  1. Insert the USB thumb drive.
  2. Enter BIOS setup.
  3. Go to Advanced, then USB Configuration, then USB Mass Storage Device Configuration, then select CDROM for Emulation Type.
  4. Press F10 to save BIOS changes and reboot. You must reboot for the BIOS to view the thumb drive as a CD-ROM drive.
  5. Enter BIOS Setup.
  6. Go to Boot, then CD/DVD Drives. Select “USB: USB DISK 2.0” as your 1st CD drive (assuming you have a real CD/DVD-ROM drive).
  7. Go back to Boot Settings Configuration, go to Boot Device Priority, and select USB: USB DISK 2.0 as the 1st boot device.
  8. Save BIOS changes and reboot.
  9. When prompted, press any key to boot from the “CD-ROM” (really the USB stick).

In the end, I wasn’t able to get the system to boot from the USB drive as a virtual CD-ROM drive. It would only boot from the USB drive if I changed the emulation to “Hard disk”.

Posted in Hardware, Technology | Tagged , , , , , , , , , | 5 Comments

Better GMail Causes 100% CPU Usage in Firefox

For the last several weeks, I’ve noticed excessive CPU usage whenever GMail (GAYD-hosted email, specifically) is open in Firefox. By turning off add-ons one at a time, I found that this is caused solely by Better GMail 2.

Firebug, FireGPG, Greasemonkey (on which Better GMail relies), and AdBlock Plus all had no effect on CPU usage.

Posted in OS X, Technology | Leave a comment

Tearing on MythTV with VLC

After updating to Ubuntu 8.10, I started to get tearing artifacts. This crop up especially badly during scenes that involve panning.

The MythTV Wiki explains the fix for tearing:

echo 1024 > /proc/sys/dev/hpet/max-user-freq

Well, it works for me, anyway. I just keep forgetting what to do when it crops up.

Posted in Linux, Technology | Leave a comment

Can’t Log in to VMware Server Console on Ubuntu

As usual, I sped through the VMware Server installation, just using default settings. I then found myself unable to log in to the VMware Server Console. I would always get an error:

You do not have permissions to login to the server.

Some searching turned up a solution which is to log in as root and set a password (root has no password by default on Ubuntu). This is an ugly solution, so I re-ran VMware Server configuration. That’s when I noticed this question:

The current administrative user for VMware Server is 'root'. Would you like
to specify a different administrator? [no]

Answering yes allows you to specify the local account which will be administrator for VMware Server:

Please specify the user whom you wish to be the VMware Server administrator
[root] fitzsimj

Using fitzsimj as the VMware Server administrator.

Posted in Linux, Technology | Leave a comment

Making OS X Command Line Behave More Like Linux (GNU)

The command-line oddities of Mac OS X’s BSD heritage drive me insane. I much prefer the behavior of the GNU toolchain, as provided by Ubuntu Linux.

To begin, first install MacPorts.

MacPorts Installation Variant +with_default_names

With several MacPorts packages, the +with_default_names variant may be specified. This causes package contents to be installed without the default “g” prefix. For example, without +with_default_names, find would be installed as gfind.

Autocompletion

1) Use MacPorts to install the bash-completion package:

sudo /opt/local/bin/port install bash-completion

2) Edit ~/.bash_profile to load the correct autocompletion script:

if [ -f /opt/local/etc/bash_completion ]; then
   /opt/local/etc/bash_completion
fi

Open a new terminal window, and commands should auto-complete according to the GNU specification.

Find

The GNU version of find helpfully assumes that, if no arguments were given, you wish to search the current directory. The OS X (BSD) version has no idea what to do without a directory specification.

sudo /opt/local/bin/port install findutils +with_default_names

This package includes find, gfind, glocate, goldfind, gupdatedb, gxargs, locate, oldfind, updatedb, and xargs.

Core Utilities

This vaguely-named package provides a large number of standard GNU tools.

sudo /opt/local/bin/port install coreutils +with_default_names

Update Path

In order to call the MacPorts-installed tools by default, your path will have to be updated to include /opt/local/libexec/gnubin/. I added the following to ~/.bash_profile:

export PATH="/opt/local/libexec/gnubin/:$PATH"
Posted in OS X, Technology | Tagged , , , , , | 1 Comment

Queue Implemented Using Stacks

Here are two solutions for using stacks to emulate a queue. The first always keeps one or both stacks empty, shifts the set of values back and forth as the caller switches between enqueuing and dequeueing. The second maintains an input stack and an output stack. All enqueued data goes directly onto the input stack. When dequeue is called, if the output stack has anything on it, it takes the topmost value, otherwise it transfers the entire input stack into the output stack.

The latter implementation is more efficient — transfer between the two stacks occurs only when dequeue is called and the output stack is already empty — as well as more compact and readable.

Stack-Swapping Implementation

This version keeps one stack empty, and swaps all content between the two each time we switch between enqueue and dequeue operations.

#include <stdio.h>
#include <stack>

// This implementation uses two stacks.  It keeps one empty, and swaps content
// whenever we switch between eprforming enqueues and dequeues.
class FakeQueue
{
    std::stack<int> s1;
    std::stack<int> s2;

	// We need to keep track of the last operation (push vs. pop) so that we can
    // resorder our stack whenever we switch between enqueue and dequeue.
	typedef enum { PUSH = 0, POP } STACK_OPS;
	STACK_OPS last_op;

	void SwapStacks();

public:
	void enqueue(int i);
	bool dequeue(int &i);

	FakeQueue() : last_op(PUSH)
	{ /* empty constructor */ }
};

// SwapStacks swaps the stack between s1 and s2.
void FakeQueue::SwapStacks()
{
	if (s1.empty())
	{
		while (!s2.empty())
		{
			s1.push(s2.top());
			s2.pop();
   		}
	}
	else
	{
        while (!s1.empty())
        {
            s2.push(s1.top());
            s1.pop();
        }
    }
}

void FakeQueue::enqueue(int i)
{
	if (last_op == POP)
	{
		SwapStacks();
		last_op = PUSH;
	}

	if (s1.empty())
        s2.push(i);
	else
        s1.push(i);
}

// Retrieves the oldest item in the virtual queue.  If the queue is empty, sets i to
// -1 and returns false.  Otherwise, it returns true.
bool FakeQueue::dequeue(int &i)
{
    if (last_op == PUSH)
    {
        SwapStacks();
        last_op = POP;
    }

    if (!s1.empty())
    {
        i = s1.top();
        s1.pop();
        return true;
    }
    else if (!s2.empty())
    {
        i = s2.top();
        s2.pop();
        return true;
    }
    else
    {
        // Queue is empty.
        i = -1;
        return false;
    }
}

int main(int /*argc*/, char ** /*argv*/)
{
    FakeQueue queue;
    int i;

    // Perform a variety of queues and dequeues to show that the queue order is
    // always maintained.

    queue.enqueue(1);
    queue.enqueue(2); // contains { 1, 2 }

    queue.dequeue(i);
    printf("Dequeued %d\n", i);

    queue.enqueue(3);
    queue.enqueue(4); // contains { 2, 3, 4 }

    queue.dequeue(i);
    printf("Dequeued %d\n", i);

    queue.enqueue(5); // contains { 3, 4, 5 }

    while (queue.dequeue(i))
    {
        printf("Dequeued %d\n", i);
    }

    return 0;
}

Input-Output Stack Implementation

This version uses dedicated input and output stacks. All input goes on the input stack. When dequeue is called, if the output stack has anything on it, it takes the topmost value, otherwise it transfers the entire input stack into the output stack.


#include <stdio.h>
#include <stack>

// The second implementation uses dedicated input and output stacks.
class FakeQueue
{
    std::stack<int> in;
    std::stack<int> out;

public:
    void enqueue(int i);
    bool dequeue(int &i);
};

void FakeQueue::enqueue(int i)
{
    in.push(i);
}

bool FakeQueue::dequeue(int &i)
{
    // Abort if our queue is empty.
    if (in.empty() && out.empty())
    {
        i = -1;
        return false;
    }

    // If the "out" stack is empty, shift the contents of the "in" stack into
    // it...
    if (out.empty())
    {
        while (!in.empty())
        {
            out.push(in.top());
            in.pop();
        }
    }

    // Pop the return value from the "out" stack:
    i = out.top();
    out.pop();

    return true;
}

int main(int /*argc*/, char ** /*argv*/)
{
    FakeQueue queue;
    int i;

    // Perform a variety of queues and dequeues to show that the queue order is
    // always maintained.

    queue.enqueue(1);
    queue.enqueue(2); // contains { 1, 2 }

    queue.dequeue(i);
    printf("Dequeued %d\n", i);

    queue.enqueue(3);
    queue.enqueue(4); // contains { 2, 3, 4 }

    queue.dequeue(i);
    printf("Dequeued %d\n", i);

    queue.enqueue(5); // contains { 3, 4, 5 }

    while (queue.dequeue(i))
    {
        printf("Dequeued %d\n", i);
    }

    return 0;
}
Posted in Algorithms, C++ | Tagged | Leave a comment

Cambodia: Sexy Time!

So, if you tell people in the US that you’re going to Thailand, they’ll often start wiggling their eyebrows, jab you in the ribs with an elbow, and mutter something about ladyboys.

This morning, I was at the Ekkamai bus station in Bangkok, waiting for my bus to Cambodia. A Thai guy, apparently a worker for one of the bus lines, started up conversation, “Hello, where you go?”

That, by the way, is basically what they say to each other all the time as a greeting. However, that’s also what all the annoying touts and taxi drivers say, which I typically ignore or answer with a confusing, “everywhere.” I haven’t yet had the nerve to respond, “your mom’s house.”

Anyway, I respond, “Cambodia. Cambusha.” A typical conversation ensues. America, San Francisco, wow, yeah, America is big, and so on.

Up waddles captain sweaty, who appears to know this man. “He’s going to Cambodia!” says my new friend. “Aha, Cambodia,” says Sweaty with a knowing wiggle of the ol’ caterpillars. He then puts one hand on the back of the other and starts pumping them.

Now, one hand on top of the other, thumbs out, happens to indicate “sea turtles” when diving, so I was a bit confused. Nooo, I’m not going to Cambodia for sea turtles…?

He saw the look of bewilderment and switched his hands around a bit. Palm to palm with some suggestive thrusting and grunting.

Oh! Oh. No! No, I’m not going to Cambodia for sex! Man, I just can’t get a break…

Posted in Travel | Tagged , , , | Leave a comment

Welcome to Cambodia

So, here’s my brief summary of how I got to Angkor Wat from Bangkok, Thailand, by land:

  1. Take a government bus from the Eastern or Northern Bangkok bus stations. Leave by 7:30am. You can probably buy your ticket the same day, just show up at 6:00am. (190 baht) You should be going to Aranyaprathet, which is on the Thailand side of the border from Poipet.
  2. I don’t think it matters much whether you get your visa in advance in Bangkok. They didn’t hassle us. Perhaps if you’re in a flood of tourists off a tour bus, you might have trouble. If they try to get more than 1,100 Thai baht, demand a receipt, get their name, and report them to the Cambodian tourism board.
  3. Immediately upon leaving the Cambodian immigration, you are required to get onto a free bus to the bus station. If the police (who are lounging off to the right, in the shade) see you getting on the back of a motorcycle taxi or into a car, they will probably stop the car and fine one or both of you. To my knowledge, nothing is stopping you from walking out of the area.
  4. The bus station is basically empty. I think you just catch a taxi there.
  5. Our taxi cost $50 for three of us to Siem Reap. We had no US dollars on us, so we paid in Thai baht, 600 each. I was later told that a taxi should cost $25 for the entire car.
  6. The taxi will drop you outside Siem Reap and hand you off to motorcycle taxies and tuk-tuks. I think these guys basically try to take you to places where they get a commision. I insisted on Two Dragons, and my driver reluctantly took me there. I then paid him $6 to haul me to Angkor Wat to see the sunset, then bring me back. I was later told that this should cost $2 or $3. Still, he was a nice guy…

Random things about Cambodia that I didn’t know:

  • The Riel (local currency) is about 4000 to one US dollar. So they pretty much just use dollars. When they give change, they’ll give partial dollars in Riel notes. I haven’t seen a US coin yet.
  • The local language is Khmer. Maybe I’m just ingorant, but it wasn’t obvious to me and I didn’t want to offend anyone by asking how to say things in “Cambodian” if that’s an external name.
  • Numbers one through ten seem unique to Khmer, but from 11 on, it sounds almost identical to Thai! I have no idea the linguistic history which causes this.
  • There is a no-man’s land between Thailand and Cambodia. There are hotels and casinos here. It’s kind of weird. Big, glitzy casinos and in front of them roll some bare-footed Cambodians pushing a home-made cart loaded with a half-ton of ice. Yep, weird.
Posted in Travel | Tagged , , , , , , | Leave a comment

Where the Hell is the Cambodian Embassy in Bangkok?

I blew nearly two days just trying to get my Cambodian visa in order to visit Angkor Wat. All this to save, what, a few minutes at the border?

So, it turns out that the Cambodian embassy is not in Lhumpin Park anymore. As of around October, 2007, it has moved to the Northeast of Bangkok, near Huai Khwang. To get there, take the “M” line to Huai Khwang or the Thailand Cultural stop on MRT. Then, ask a taxi or motorcycle to take you to the Cambodian Embassy. I’ll post the Thai for that later.

The exact coordinates are N0313.76809,E100.59631. It’s on Pratcha Uthit at Saha Kan Pramun.

Incidentally, Saha Kan Pramun is where the Harley Davidson dealership is. I don’t recommend going there, however, since Harleys are crap and their simple tee shirts are 1,200 baht!

Cambodian visa details: 1,100 baht as of January 6, 2009. Requires a passport photo and a photocopy of your current passport (10 baht if you don’t bring it, don’t know how much if you forget the passport photo). Takes about 15 minutes from the time you file your paper work. The embassy closes for lunch from, if I recall correctly, noon until 2:00pm.

Posted in Travel | Tagged , , , , | Leave a comment