Micha Niskin

16 days ago
Category  

Another way to configure the bash shell so that it doesn’t alert you to new email is to set the MAILCHECK environment variable to zero or a negative number, like this:

/home/micha/.bashrc:

export MAILCHECK=0

From the bash(1) manpage:

Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking.

Comment

Alan Dipert

30 days ago
Category  

On CentOS the default /etc/profile sets the environment variable MAIL to the path of the user’s mailbox:

/etc/profile, line 35:

MAIL="/var/spool/mail/$USER"

Because of this, bash periodically interrupts my shell sessions and lets me know that I have mail. And I don’t really care because I get my mail through IMAP.

To shut it up, I unset it in my ~/.profile:

/home/alan/.profile:

export MAIL=""

Fancy.

Comment

Alan Dipert

37 days ago
Category  

A common technique for implementing so-called “clean URLs” in lighttpd for use with TextPattern is this (from this post):

server.error-handler-404 = "/index.php"

That’s a bit hackish and displeasing to me for some reason. What about a regular URL rewrite? Try this in your lighttpd.conf:

url.rewrite-final = (
    "^/([^.?]*)$" => "/index.php/$1"
)

It’s adapted from an example by the Drupal people.

Comment

Alan Dipert

53 days ago
Category  

MacFUSE is an OS X kernel extension that can load usermode filesystem modules. One of the filesystems you can integrate directly into the Finder is really a pseudo filesystem: SSH. This is really handy especially since the Finder’s FTP functionality is limited to read-only. Most people who want to use the Finder or something like it for web work either buy Fetch, use Fugu, or opt for ftp, ncftp, or sftp on the command line. But MacFUSE is free, easy, secure, and rocks.

Once you have MacFUSE Core and the SSHFS application installed, you’re cooking. But how do you connect to and mount SSHFS volumes automatically?

Well, it turns out inside the sshfs.app application bundle, there’s a CLI flavor of the sshfs mounter. It’s located here:

/Applications/sshfs.app/Contents/Resources/sshfs-static-10.5

Steps for Beginners. Guru? Skip to 4

1. If you don’t already, it’s not a bad idea to take advantage of a /usr/local directory hierarchy for incidental or home-rolled command line binaries and jazz. We’re about to make a symlink to the sshfs-static-10.5 binary, and we need a spot to put the target. Below is a command which creates the specified directory as well as directories above it, as required, as instructed with the ‘p’ flag:

sudo mkdir -p /usr/local/bin

2. So now we have a spot for a symbolic link to the sshfs.app CLI that we can update in the future (for instance, for sshfs-static-10.6). We just need to add /usr/local/bin to the list of directories searched for executables. This line will do the trick:

export PATH=$PATH:/usr/local/bin

You can stick that in ~/.profile or ~/.bash_profile and it will be executed every time you open a shell.

3. I have a symbolic link from /usr/local/bin/sshfs to the above program, which I created with this line:

sudo ln -s /Applications/sshfs.app/Contents/Resources/sshfs-static-10.5 /usr/local/bin/sshfs

4. Now that we have an environment that knows about the command line version of sshfs, consider the following, an excerpt from my .bashrc:

#mount remote home directory
MOUNTPOINT=/Volumes/uberhome
REMOTE=alan@ubergibson.com:/home/alan
OPTIONS=-oping_diskarb,volname=uberhome
TESTHOST=ubergibson.com
#test if sshfs already mounted
if ! [ -e $MOUNTPOINT ]
then
        #test if connected to internet
        if ! [ -z "`ping -c 1 $TESTHOST 2>/dev/null | grep "time="`" ]
        then
                mkdir $MOUNTPOINT
                sshfs $REMOTE $MOUNTPOINT $OPTIONS
                echo "$REMOTE mounted on $MOUNTPOINT"
        else
                echo "Network down, unable to mount $REMOTE"
        fi
fi

The variable assignments are self-explanatory, and are unique to my setup.

The first if statement checks if the file /Volumes/uberhome exists with the -e flag. If it doesn’t exist, meaning the volume has not yet been mounted, move on to the next test.

The next test tries to ping ubergibson.com. Successful runs of ping always result in output that contains the string “time=”, so we grep for it. The -z flag tests the result of the ping/grep for whether or not it is null. If it isn’t, mkdir a mount point and run sshfs. Then, say it worked.

My script gets run every time I open a shell. There are fancier ways of going about automounting, like customizing your login and logout with scripts and applications

There are a billion ways to skin a cat. But I hope you have fun with this one. Happy computations.

Comment

Micha Niskin

87 days ago

So this afternoon I see a number of new stop signs near where my mom lives in Miami Beach. These weren’t regular stop signs, but more like what I would call “harassing” stop signs. These signs were not put in a normal intersection. No, they were put on all sides of a tee intersection, where a little side road meets the main road. There is absolutely no need for a stop sign there at all, to say nothing of an all-way stop situation like they have there now. I assume they’re there in some kind of attempt to slow the traffic, or maybe to discourage outsiders from using the road. Who knows. Whatever.

But now that I’m thinking about stop signs, I think it’s even dumber than it seems. What the hell are stop signs for anyway? I am totally not a stop sign kind of guy. I roll through those fuckers on a daily basis if nobody’s coming the other way. As a reasonable human with half a brain should do. There is absolutely no need for a person with higher than brussel sprout IQ to come to a complete stop if there are no other cars on the roads. Duh. But no, that kind of common sense thinking can get you a ticket or worse around here. Bah.

See, what I would do, if I were boss of the world, would be to use yield signs. You hardly ever see those things, and I think it’s a shame because all stop signs can be replaced by yield signs. It’s very simple. There you go. If you’re in a really really really tricky spot you could use a traffic circle, but that should be discouraged as much as possible in the interest of simplicity.

This would clearly define the responsibilities of the drivers who use the intersection, and assign guilt in the case of an accident. Responsibility, people. We need to get out of the uncle-sam-is-my-mommy-and-will-protect-us-from-our-stupid-selves mindset and start taking ownership of how we interact with eachother in our society. We are not mentally challenged children who need to be taken by the hand and walked to the bus stop by Big Brother. I think that everyone deserves to be given enough rope to hang themselves. Without the scope of free will to exercise your responsibility what kind of citizens can we ever be? I’ll tell you: we’ll be the kind who ask not what we can do for our country, but what our country can do for us.

Comment

Previous